From d49485e0704b04de63cdbb316d4ff4c4a299b27e Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 25 Nov 2010 15:17:35 +0100 Subject: [PATCH] =?utf8?q?Bei=20save/delete=20das=20richtige=20Ergebnis=20?= =?utf8?q?zur=C3=BCckgeben?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Und zwar das von RDBO::save/delete, und nicht das von do_transaction. --- SL/DB/Object.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/SL/DB/Object.pm b/SL/DB/Object.pm index 4e6e15c4c..a80640cad 100755 --- a/SL/DB/Object.pm +++ b/SL/DB/Object.pm @@ -110,24 +110,30 @@ sub load { sub save { my ($self, @args) = @_; - my $worker = sub { + + my $result; + my $worker = sub { SL::DB::Object::Hooks::run_hooks($self, 'before_save'); - my $result = $self->SUPER::save(@args); + $result = $self->SUPER::save(@args); SL::DB::Object::Hooks::run_hooks($self, 'after_save', $result); }; - return $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); + $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); + return $result; } sub delete { my ($self, @args) = @_; - my $worker = sub { + + my $result; + my $worker = sub { SL::DB::Object::Hooks::run_hooks($self, 'before_delete'); - my $result = $self->SUPER::delete(@args); + $result = $self->SUPER::delete(@args); SL::DB::Object::Hooks::run_hooks($self, 'after_delete', $result); }; - return $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); + $self->db->in_transaction ? $worker->() : $self->db->do_transaction($worker); + return $result; } 1; -- 2.20.1