Defect #17852
closedIssue journals should be ordered by created_on, not id
0%
Description
After migration to Redmine form another system, I noticed issue journals were not in the right order.
Our migration added file attachment journals last, so the ID was higher than the rest of the journals.
While this was incidental to the way we migrated and would probably nor occur in most Redmine installations, this issue could also occur under certain circumstances if, for example, Redmine was backed by a multimaster replicated database.
The correct(er) way to get the journals would be to sort them by the created_on column
--------------------------------
--- issues_controller.rb.ori Sun Jul 6 14:44:08 2014
+++ issues_controller.rb Fri Sep 12 08:05:33 2014@ -104,7 +104,7
@ class IssuesController < ApplicationController
end
def show
- @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all
+ @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.created_on ASC").all
@journals.each_with_index {|j,i| j.indice = i+1}
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
Journal.preload_journals_details_custom_fields(@journals)
Please find the diff attached, as well as the migration diff to add the index.
Files
Related issues