id,summary,reporter,owner,description,type,status,priority,component,severity,resolution,keywords,cc,release
9743,Exception when latest change on referenced ticket is not a comment,ejucovy,rjollos,If you reference a ticket whose latest modification is not a comment_ the plugin will fail with an error.  To reproduce:\r\n\r\n 1. Create a ticket\r\n 1. Comment on that ticket\r\n 1. Change the ticket's priority from major to minor\r\n 1. Create a second ticket\r\n 1. Comment on the second ticket with a reference to the first ticket\r\n\r\nThe plugin will fail with a `ValueError`_ because it assumes that the latest changelog entry in `t.get_changelog()` will always be a comment.\r\n\r\nWhen running against trac trunk_ the plugin raises an exception:\r\n{{{\r\nFile "ve/src/trac/trac/ticket/model.py"_ line 360_ in save_changes\r\n  listener.ticket_changed(self_ comment_ author_ old_values)\r\nFile "ve/src/tracbacksplugin/tracbacks/tracbacks.py"_ line 103_ in ticket_changed\r\n  cnum_lastcomment = int(cnum_lastchange[-1])\r\nValueError: invalid literal for int() with base 10: 'minor'\r\n}}}\r\n\r\nI haven't tested against earlier versions of Trac to see if it's a new issue.  It does seem to be related to #9008 -- and a commenter ([/ticket/9008#comment:1 comment:1:ticket:9008]) posted a traceback there_ against trac 0.12.2_ which is functionally identical to the traceback I'm seeing.\r\n\r\nThe following patch fixes the problem by filtering the referenced-ticket's changelog to only include comments:\r\n{{{\r\n#!diff\r\nIndex: tracbacks/tracbacks.py\r\n===================================================================\r\n--- tracbacks/tracbacks.py	(revision 11214)\r\n+++ tracbacks/tracbacks.py	(working copy)\r\n@@ -95_7 +95_7 @@\r\n                 # by the TicketChangePlugin to identify the comment being\r\n                 # edited_ so we make sure to add it here.\r\n                 cnum_thischange = 1                \r\n-                change_log = t.get_changelog()\r\n+                change_log = [i for i in t.get_changelog() if i[2] == "comment"]\r\n                 if change_log != []:\r\n                     lastchange = change_log[-1]\r\n                     cnum_lastchange = lastchange[3].rsplit('.'_ 1)\r\n}}},defect,closed,normal,TracBacksPlugin,normal,fixed,,,0.12
