From 04479c02711b7b49ffc6f2228615aed373b83a01 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Mon, 19 Nov 2018 10:29:36 +0100 Subject: [PATCH] disable_one_time_config: Transaktionssicher --- SL/DB/PeriodicInvoicesConfig.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/SL/DB/PeriodicInvoicesConfig.pm b/SL/DB/PeriodicInvoicesConfig.pm index dd70206e2..c1dc15eb7 100644 --- a/SL/DB/PeriodicInvoicesConfig.pm +++ b/SL/DB/PeriodicInvoicesConfig.pm @@ -140,9 +140,17 @@ sub disable_one_time_config { # A periodicity of one time was set. Deactivate this config now. if ($self->periodicity eq 'o') { _log_msg("setting inactive\n"); - $self->active(0); - $self->order->update_attributes(closed => 1); - $self->save; + if (!$self->db->with_transaction(sub { + 1; # make Emacs happy + $self->active(0); + $self->order->update_attributes(closed => 1); + die; + $self->save; + 1; + })) { + $::lxdebug->message(LXDebug->WARN(), "disalbe_one_time config failed: " . join("\n", (split(/\n/, $self->{db_obj}->db->error))[0..2])); + return undef; + } return $self->order->ordnumber; } return undef; -- 2.20.1