Defect #15135

Issue#update_nested_set_attributes comparing nil with empty string

Added by RafaƂ Lisowski almost 9 years ago. Updated almost 9 years ago.

Status:ClosedStart date:
Priority:LowDue date:
Assignee:Jean-Philippe Lang% Done:


Category:Code cleanup/refactoring
Target version:2.4.0
Resolution:Fixed Affected version:2.3.3


I had problem with slow issue update. Issue have ~20 subtasks and 1 related issue. Update on that task always ended with timeout error.
It's appears that Issue#update_nested_set_attributes (after_save hook) there is comparision parent_issue_id != parent_id.
In my case parent_issue_id was nil and parent_id empty string, it's leads to unnecessary code execution.
When I change:

elsif parent_issue_id != parent_id

elsif parent_issue_id.to_i != parent_id.to_i

update is now 4 times faster.

Ruby: 1.9.3-p429
Rails: 3.2.13
Redmine: 2.3.3

Associated revisions

Revision 12226
Added by Jean-Philippe Lang almost 9 years ago

Fixed that issue nested set update is triggered even if parent is not changed (#15135).


#1 Updated by Jean-Philippe Lang almost 9 years ago

  • Category changed from Issues to Code cleanup/refactoring
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.4.0
  • Resolution set to Fixed

I fixed the root cause in parent_issue_id= rather than the comparaison and added a few tests to make sure that this code is called only when needed (r12226), thanks for pointing this out.

Also available in: Atom PDF