Patch #29632

Redmine::SortCriteria#normalize! does not limit properly the number of elements

Added by Mizuki ISHIKAWA 3 months ago. Updated 2 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Code cleanup/refactoring
Target version:4.0.0

Description

Only three sorting criteria can be selected on the query edit screen.
With code before r16390, only three items could be saved as data according to screen specifications.

However, since "slice(0,3)" was changed to "slice!(3)" at r16390, the following result is returned now.

# slice(0,3)
sort_criteria = [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc'], ['id', 'asc'], ['project', 'asc'], ['subject', 'asc']]
p sort_criteria.slice(0,3)
=> [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc']]

# slice!(3)
# The number limit is not made
sort_criteria .slice!(3)
p sort_criteria 
=> [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc'], ['subject', 'asc']]


I think it should be restricted to only three from the beginning like the case of "slice(0, 3)".
The attached file is a patch for fix.

edit_query.png (23.3 KB) Mizuki ISHIKAWA, 2018-09-18 09:43

restrict_the_number_of_elements_of_sort_criteria.patch Magnifier (1.23 KB) Mizuki ISHIKAWA, 2018-09-18 09:44

Associated revisions

Revision 17494
Added by Go MAEDA 3 months ago

Redmine::SortCriteria#normalize! does not limit properly the maximum number of elements (#29632).

Patch by Mizuki ISHIKAWA.

History

#1 Updated by Go MAEDA 3 months ago

  • Target version set to 4.1.0

#2 Updated by Go MAEDA 3 months ago

I have confirmed the problem and set the target version to 4.1.0.

source:tags/3.4.6/lib/redmine/sort_criteria.rb#L91 removes only the third element, but normalize! method is expected to keep the first three elements and remove the rest.

#3 Updated by Go MAEDA 3 months ago

  • Subject changed from The number of sort_criteria is not limited to Redmine::SortCriteria#normalize! does not limit properly the number of elements
  • Category changed from Issues filter to Code cleanup/refactoring
  • Status changed from New to Closed
  • Target version changed from 4.1.0 to 4.0.0

Committed. Thank you for reporting and fixing the issue.

#4 Updated by Go MAEDA 2 months ago

  • Assignee set to Go MAEDA

Also available in: Atom PDF