From d1090a8c6956e968fd2964505fa1e04ca0b4db27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 2 Aug 2016 12:59:32 +0200 Subject: [PATCH] common.pl: single-dbh --- bin/mozilla/common.pl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index cba9e2244..d01d19f58 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -11,6 +11,7 @@ use SL::Common; use SL::DB::Helper::Mappings; +use SL::DB; use SL::DBUtils qw(do_query); use SL::Form; use SL::MoreCommon qw(restore_form save_form); @@ -493,10 +494,12 @@ sub mark_as_paid_common { my $locale = $main::locale; if($form->{mark_as_paid}) { - my $dbh ||= $form->get_standard_dbh($myconfig); - my $query = qq|UPDATE $db_name SET paid = amount, datepaid = current_date WHERE id = ?|; - do_query($form, $dbh, $query, $form->{id}); - $dbh->commit(); + SL::DB->client->with_transaction(sub { + my $dbh ||= SL::DB->client->dbh; + my $query = qq|UPDATE $db_name SET paid = amount, datepaid = current_date WHERE id = ?|; + do_query($form, $dbh, $query, $form->{id}); + 1; + }) or do { $::form->error(SL::DB->client->error) }; $form->redirect($locale->text("Marked as paid")); } else { -- 2.20.1