Edgewall Software

Ticket #3654: notify-on-create.patch

File notify-on-create.patch, 1.2 KB (added by timwatt+trac@…, 5 years ago)

Fix ticket creator notification (and generally don't let updater-related exceptions stop notification)

  • trac/ticket/notification.py

    old new  
    220220 
    221221        # Suppress the updater from the recipients 
    222222        if not notify_updater: 
    223             cursor.execute("SELECT author FROM ticket_change WHERE ticket=%s " 
    224                            "ORDER BY time DESC LIMIT 1", (tktid,)) 
    225             (updater, ) = cursor.fetchone()  
     223            updater = None 
     224            try: 
     225                cursor.execute("SELECT author FROM ticket_change WHERE ticket=%s " 
     226                               "ORDER BY time DESC LIMIT 1", (tktid,)) 
     227                (updater, ) = cursor.fetchone()  
     228            except TypeError, e: 
     229                # assume it was because fetchone returned no results (e.g., new ticket) 
     230                try: 
     231                    cursor.execute("SELECT reporter FROM ticket WHERE id=%s LIMIT 1", (tktid,)) 
     232                    (updater, ) = cursor.fetchone()  
     233                except Exception, e: 
     234                    self.log.exception("Failure identifying updater on ticket #%s: %s" % (tktid, e)) 
    226235            torecipients = [r for r in torecipients if r and r != updater] 
    227236 
    228237        return (torecipients, ccrecipients)