Project

General

Profile

Actions

Defect #15135

closed

Issue#update_nested_set_attributes comparing nil with empty string

Added by Rafał Lisowski about 11 years ago. Updated about 11 years ago.

Status:
Closed
Priority:
Low
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

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

Actions #1

Updated by Jean-Philippe Lang about 11 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.

Actions

Also available in: Atom PDF