bug comment ordering broken

Bug #52934 reported by James Henstridge
6
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
High
Christian Reis

Bug Description

I am seeing some problems with bug comment ordering. This problem seems to have been introduced in r3768, which changes how the MessageChunks for the comments are requested from the database.

The new code does the following:

1. Bug.getMessageChunks() returns a SelectResults of the chunks associated with the bug. It is ordered by MessageChunk.sequence, which doesn't imply much order other than that MessageChunks from the same Message will occur in order.

2. build_comments_from_chunks() constructs BugComment instances from this SelectResults. It creates one BugComment for each Message, and assigns them increasing indices in the order they are created.

In what looks like a bug, chunks after the first for a message are not added to the corresponding BugComment instance.

3. get_comments_for_bugtask() then sorts the the BugComment instances by their index attribute. This provides no special ordering because the MessageChunks in (1) were not sorted in a meaningful way (e.g. by Message.datecreated like bug.messages does).

The result is that we can get an incorrect ordering of bug comments. Things to fix:

 * Bug.getMessageChunks() should sort by (Message.datecreated, MessageChunk.sequence).
 * make build_comments_from_chunks() add second, third, etc chunks to the BugComment instances.

CC'ing Kiko because this was his patch and Brad because he reviewed it.

Tags: lp-bugs
Changed in malone:
importance: Untriaged → High
Christian Reis (kiko)
Changed in malone:
assignee: nobody → kiko
status: Unconfirmed → In Progress
Brad Bollenbach (bradb)
Changed in malone:
status: In Progress → Fix Committed
Christian Reis (kiko)
Changed in malone:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.