Defect #15135
Issue#update_nested_set_attributes comparing nil with empty string
Status: | Closed | Start date: | ||
---|---|---|---|---|
Priority: | Low | Due date: | ||
Assignee: | % Done: | 0% | ||
Category: | Code cleanup/refactoring | |||
Target version: | 2.4.0 | |||
Resolution: | Fixed | Affected version: | 2.3.3 |
Description
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
to
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
Fixed that issue nested set update is triggered even if parent is not changed (#15135).
History
#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.