From: Moritz Bunkus Date: Mon, 15 Jul 2013 10:32:07 +0000 (+0200) Subject: DBUpgrade2: verhindern, dass $::form->get_standard_dbh eine zweite Verbindung öffnet X-Git-Tag: release-3.1.0beta1~165 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6844d581bac018c7892e6b1c458a981b5e3ff313;p=kivitendo-erp.git DBUpgrade2: verhindern, dass $::form->get_standard_dbh eine zweite Verbindung öffnet Ansonsten sind Deadlocks absolut möglich. --- diff --git a/SL/DBUpgrade2.pm b/SL/DBUpgrade2.pm index eba336fe2..3cdb9a44b 100644 --- a/SL/DBUpgrade2.pm +++ b/SL/DBUpgrade2.pm @@ -243,6 +243,7 @@ sub process_perl_script { $dbh->begin_work; # setup dbup_ export vars & run script + my $old_dbh = $::form->set_standard_dbh($dbh); my %dbup_myconfig = map { ($_ => $::form->{$_}) } qw(dbname dbuser dbpasswd dbhost dbport dbconnect); my $result = eval { SL::DBUpgrade2::Base::execute_script( @@ -255,6 +256,8 @@ sub process_perl_script { my $error = $EVAL_ERROR; + $::form->set_standard_dbh($old_dbh); + $dbh->rollback if 1 != ($result // -1); return $error if $self->{return_on_error} && (1 != ($result // -1)); diff --git a/SL/Form.pm b/SL/Form.pm index 79ff7034f..b18bc67b5 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1403,6 +1403,14 @@ sub get_standard_dbh { return $standard_dbh; } +sub set_standard_dbh { + my ($self, $dbh) = @_; + my $old_dbh = $standard_dbh; + $standard_dbh = $dbh; + + return $old_dbh; +} + sub date_closed { $main::lxdebug->enter_sub();