Defect #17852

Issue journals should be ordered by created_on, not id

Added by name zero about 3 years ago. Updated almost 3 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Issues
Target version:-
Resolution:Duplicate Affected version:2.5.2

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.

issues_controller.rb.diff Magnifier (644 Bytes) name zero, 2014-09-12 08:34

007_create_journals.rb.diff Magnifier (605 Bytes) name zero, 2014-09-12 08:34


Related issues

Duplicates Redmine - Defect #14881: Issue journals should be ordered by created_on, not id Closed

History

#1 Updated by Go MAEDA almost 3 years ago

  • Duplicates Defect #14881: Issue journals should be ordered by created_on, not id added

#2 Updated by Go MAEDA almost 3 years ago

  • Status changed from New to Closed
  • Resolution set to Duplicate

This issue duplicates with #14881.

Also available in: Atom PDF