diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-06-18 17:16:13 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-06-18 17:16:13 +0000 |
commit | f62507dae53a7eb5880322e03dbf0f0a49e3d311 (patch) | |
tree | be95c1446f7f95fdc086f1f72d1896a513cb0a7a /app/models/issue.rb | |
parent | 9e878a938438337f6c2ea0d96f3f05031906afc8 (diff) | |
download | redmine-f62507dae53a7eb5880322e03dbf0f0a49e3d311.tar.gz redmine-f62507dae53a7eb5880322e03dbf0f0a49e3d311.zip |
Fixed that deleting a project with subtasks may fail (#11185).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9858 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 118b8acf1..96c3f8526 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -124,6 +124,28 @@ class Issue < ActiveRecord::Base end end + # AR#Persistence#destroy would raise and RecordNotFound exception + # if the issue was already deleted or updated (non matching lock_version). + # This is a problem when bulk deleting issues or deleting a project + # (because an issue may already be deleted if its parent was deleted + # first). + # The issue is reloaded by the nested_set before being deleted so + # the lock_version condition should not be an issue but we handle it. + def destroy + super + rescue ActiveRecord::RecordNotFound + # Stale or already deleted + begin + reload + rescue ActiveRecord::RecordNotFound + # The issue was actually already deleted + @destroyed = true + return freeze + end + # The issue was stale, retry to destroy + super + end + # Overrides Redmine::Acts::Customizable::InstanceMethods#available_custom_fields def available_custom_fields (project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : [] |