Opened 9 years ago
Last modified 6 years ago
#12714 new defect
Wrong comment id when comment gets edited
Reported by: | anonymous | Owned by: | lucid |
---|---|---|---|
Priority: | normal | Component: | PullRequestsPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: |
Description
In source:pullrequestsplugin/trunk/pullrequests/web_ui.py@14804:143#L122 there's this code:
comment_number = (ticket.get_comment_number(ticket['changetime']) or 0) + 1
This is a hack to work around a Trac API limitation. ITicketManipulator .validate_ticket
is called when new comments are added, but it's difficult to find the comment number of the new comment.
So instead this assumes the ticket changetime can be used to find the last previous comment, and adding 1 yields in the new comment. Or no previous comment is found, so the new comment is comment number one.
But this fails when the ticket was last changed for other reasons than adding a comment, e.g. for editing a comment. In that case searching for a "previous comment" created at the ticket changetime fails and comment_number
is 1, which is wrong!
See t:ticket:12414