From f3aa68189371cfcbde72a40f4a909356e14e3c94 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 3 May 2013 09:33:49 +0200 Subject: [PATCH] =?utf8?q?Refactoring:=20explizites=20$rspec->delete=5Fite?= =?utf8?q?ms=20vor=20->copy=5Ffrom=20inzwischen=20unn=C3=B6tig?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ...seitdem die BEFORE-DELETE-Trigger für die Items richtig funktionieren. --- SL/Controller/RequirementSpec.pm | 1 - SL/DB/RequirementSpec.pm | 23 ----------------------- 2 files changed, 24 deletions(-) diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index aa259f6f0..b72a8c4b4 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -185,7 +185,6 @@ sub action_revert_to { my $versioned_copy = SL::DB::RequirementSpec->new(id => $::form->{versioned_copy_id})->load; - $self->requirement_spec->delete_items; $self->requirement_spec->copy_from( $versioned_copy, version_id => $versioned_copy->version_id, diff --git a/SL/DB/RequirementSpec.pm b/SL/DB/RequirementSpec.pm index 5cfb5dcfe..12afb2483 100644 --- a/SL/DB/RequirementSpec.pm +++ b/SL/DB/RequirementSpec.pm @@ -156,29 +156,6 @@ sub copy_from { return $self; } -sub delete_items { - my ($self) = @_; - - my $worker = sub { - # First convert all items to sections so that deleting won't - # violate foreign key constraints on parent_id. - SL::DB::Manager::RequirementSpecItem->update_all( - set => { parent_id => undef, item_type => 'section' }, - where => [ - requirement_spec_id => $self->id, - '!parent_id' => undef, - ]); - - # Now delete all items in one go. - SL::DB::Manager::RequirementSpecItem->delete_all(where => [ requirement_spec_id => $self->id ]); - - # Last clear values in ourself. - $self->items([]); - }; - - return $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); -} - sub previous_version { my ($self) = @_; -- 2.20.1