If you reference a ticket whose latest modification is not a comment, the plugin will fail with an error. To reproduce:
- Create a ticket
- Comment on that ticket
- Change the ticket's priority from major to minor
- Create a second ticket
- Comment on the second ticket with a reference to the first ticket
The plugin will fail with a ValueError, because it assumes that the latest changelog entry in t.get_changelog() will always be a comment.
When running against trac trunk, the plugin raises an exception:
File "ve/src/trac/trac/ticket/model.py", line 360, in save_changes
listener.ticket_changed(self, comment, author, old_values)
File "ve/src/tracbacksplugin/tracbacks/tracbacks.py", line 103, in ticket_changed
cnum_lastcomment = int(cnum_lastchange[-1])
ValueError: invalid literal for int() with base 10: 'minor'
I 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 (comment:1:ticket:9008) posted a traceback there, against trac 0.12.2, which is functionally identical to the traceback I'm seeing.
The following patch fixes the problem by filtering the referenced-ticket's changelog to only include comments:
--- tracbacks/tracbacks.py (revision 11214)
+++ tracbacks/tracbacks.py (working copy)
@@ -95,7 +95,7 @@
# by the TicketChangePlugin to identify the comment being
# edited, so we make sure to add it here.
cnum_thischange = 1
- change_log = t.get_changelog()
+ change_log = [i for i in t.get_changelog() if i == "comment"]
if change_log != :
lastchange = change_log[-1]
cnum_lastchange = lastchange.rsplit('.', 1)