From: Sven Schöling Date: Wed, 17 Aug 2016 13:51:24 +0000 (+0200) Subject: single-dbh: Fehler in Transaktionen immer weiterwerfen X-Git-Tag: release-3.5.4~2069 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6b23fb212fb1cee6e1034601d3ceb22a182e50f0;p=kivitendo-erp.git single-dbh: Fehler in Transaktionen immer weiterwerfen --- diff --git a/SL/AM.pm b/SL/AM.pm index a17286711..a1ad0bcf9 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -498,7 +498,8 @@ sub delete_lead { SL::DB->client->with_transaction(sub { $query = qq|DELETE FROM leads WHERE id = ?|; do_query($form, SL::DB->client->dbh, $query, $form->{id}); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -606,7 +607,8 @@ sub save_language { ") VALUES (?, ?, ?, ?, ?, ?)"; } do_query($form, $dbh, $query, @values); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -627,7 +629,8 @@ sub delete_language { $query = "DELETE FROM language WHERE id = ?"; do_query($form, $dbh, $query, $form->{"id"}); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -796,7 +799,8 @@ sub closebooks { # set close in defaults do_query($form, $dbh, $query, @values); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -1097,7 +1101,8 @@ sub add_unit { } $sth->finish(); } - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -1375,7 +1380,8 @@ sub delete_tax { SL::DB->client->with_transaction(sub { $query = qq|DELETE FROM tax WHERE id = ?|; do_query($form, SL::DB->client->dbh, $query, $form->{id}); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -1400,7 +1406,8 @@ sub save_price_factor { } do_query($form, $dbh, $query, @values); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -1443,7 +1450,8 @@ sub delete_price_factor { SL::DB->client->with_transaction(sub { do_query($form, SL::DB->client->dbh, qq|DELETE FROM price_factors WHERE id = ?|, conv_i($form->{id})); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -1480,7 +1488,8 @@ sub save_warehouse { $sth->finish(); } - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -1512,7 +1521,8 @@ sub save_bins { } $sth->finish(); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } diff --git a/SL/AP.pm b/SL/AP.pm index ae75dc909..6de1b158b 100644 --- a/SL/AP.pm +++ b/SL/AP.pm @@ -403,7 +403,8 @@ sub delete_transaction { SL::DB->client->with_transaction(sub { my $query = qq|DELETE FROM ap WHERE id = ?|; do_query($form, SL::DB->client->dbh, $query, $form->{id}); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); diff --git a/SL/AR.pm b/SL/AR.pm index 510cc5d29..3b795d492 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -452,7 +452,8 @@ sub delete_transaction { # acc_trans entries are deleted by database triggers. my $query = qq|DELETE FROM ar WHERE id = ?|; do_query($form, SL::DB->client->dbh, $query, $form->{id}); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); diff --git a/SL/ARAP.pm b/SL/ARAP.pm index 4d5c564aa..121ea065a 100644 --- a/SL/ARAP.pm +++ b/SL/ARAP.pm @@ -154,7 +154,8 @@ sub close_orders_if_billed { SL::DB->client->with_transaction(sub { my $query = qq|UPDATE oe SET closed = TRUE WHERE id IN (| . join(', ', ('?') x scalar @close_oe_ids) . qq|)|; do_query($form, $dbh, $query, @close_oe_ids); - }); + 1; + }) or do { die SL::DB->client->error }; } $main::lxdebug->leave_sub(); diff --git a/SL/AccTransCorrections.pm b/SL/AccTransCorrections.pm index 1dad0724f..fff16f759 100644 --- a/SL/AccTransCorrections.pm +++ b/SL/AccTransCorrections.pm @@ -796,7 +796,8 @@ sub fix_ap_ar_wrong_taxkeys { $h_taxkey_only->finish(); $h_taxkey_chart_id->finish(); - }); + 1; + }) or do { die SL::DB->client->error }; } $main::lxdebug->leave_sub(); @@ -872,7 +873,8 @@ sub fix_invoice_inventory_with_taxkeys { } $sth->finish(); - }); + 1; + }) or do { die SL::DB->client->error }; } $main::lxdebug->leave_sub(); @@ -922,7 +924,8 @@ sub fix_wrong_taxkeys { $h_taxkey_only->finish(); $h_taxkey_chart->finish(); $h_transdate->finish(); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -949,7 +952,8 @@ sub delete_transaction { do_query($form, $dbh, qq|DELETE FROM ap WHERE id = ?|, conv_i($params{trans_id})); do_query($form, $dbh, qq|DELETE FROM gl WHERE id = ?|, conv_i($params{trans_id})); do_query($form, $dbh, qq|DELETE FROM acc_trans WHERE trans_id = ?|, conv_i($params{trans_id})); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } diff --git a/SL/BP.pm b/SL/BP.pm index 711b988e7..9cf0750e8 100644 --- a/SL/BP.pm +++ b/SL/BP.pm @@ -261,7 +261,8 @@ sub delete_spool { unlink(qq|$spool/$form->{"spoolfile_$i"}|); } } - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); return 1; diff --git a/SL/Common.pm b/SL/Common.pm index 31fbba9fe..28a3d5a14 100644 --- a/SL/Common.pm +++ b/SL/Common.pm @@ -434,7 +434,8 @@ sub save_email_status { do_query($form, $dbh, qq|UPDATE $table SET intnotes = ? WHERE id = ?|, $intnotes, $form->{id}); $form->save_status($dbh); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } diff --git a/SL/DATEV.pm b/SL/DATEV.pm index eb23cf284..be3ec958c 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -293,7 +293,8 @@ sub save_datev_stamm { my $query = "INSERT INTO datev (" . join(', ', @columns) . ") VALUES (" . join(', ', ('?') x @columns) . ")"; do_query($::form, $self->dbh, $query, map { $data->{$_} } @columns); - }); + 1; + }) or do { die SL::DB->client->error }; } sub export { diff --git a/SL/DO.pm b/SL/DO.pm index 0e143192e..4ba482850 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -578,7 +578,8 @@ sub mark_orders_if_delivered { foreach my $oe_id (keys %ship) { do_query($form, $dbh,"UPDATE oe SET delivered = ".($ship{$oe_id}->{delivered}?"TRUE":"FALSE")." WHERE id = ?", $oe_id); } - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -605,7 +606,8 @@ sub close_orders { my $query = qq|UPDATE delivery_orders SET closed = TRUE WHERE id IN (| . join(', ', ('?') x scalar(@{ $params{ids} })) . qq|)|; do_query($form, $dbh, $query, map { conv_i($_) } @{ $params{ids} }); - }); + 1; + }) or die { SL::DB->client->error }; $form->new_lastmtime('delivery_orders'); diff --git a/SL/FU.pm b/SL/FU.pm index b98687f3e..8a2f2698a 100644 --- a/SL/FU.pm +++ b/SL/FU.pm @@ -81,7 +81,8 @@ sub finish { SL::DB->client->with_transaction(sub { do_query($form, SL::DB->client->dbh, qq|UPDATE follow_ups SET done = TRUE WHERE id = ?|, conv_i($params{id})); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -105,7 +106,8 @@ sub delete { do_query($form, $dbh, qq|DELETE FROM follow_up_links WHERE follow_up_id = ?|, $id); do_query($form, $dbh, qq|DELETE FROM follow_ups WHERE id = ?|, $id); do_query($form, $dbh, qq|DELETE FROM notes WHERE (trans_id = ?) AND (trans_module = 'fu')|, $id); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -444,7 +446,8 @@ sub save_access_rights { } $sth->finish(); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } diff --git a/SL/GL.pm b/SL/GL.pm index bd8113eaf..1b71c9440 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -52,7 +52,8 @@ sub delete_transaction { SL::DB->with_transaction(sub { do_query($form, SL::DB->client->dbh, qq|DELETE FROM gl WHERE id = ?|, conv_i($form->{id})); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } diff --git a/SL/IR.pm b/SL/IR.pm index f1a1b7c17..4a5b22e15 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -933,7 +933,8 @@ sub delete_invoice { ); map { do_query($form, $dbh, $_, @values) } @queries; - }); + 1; + }) or do { die SL::DB->client->error }; return 1; } diff --git a/SL/Notes.pm b/SL/Notes.pm index d7d657ce4..1d768f375 100644 --- a/SL/Notes.pm +++ b/SL/Notes.pm @@ -34,7 +34,8 @@ sub save { push @values, $params{subject}, $params{body}, conv_i($params{id}); do_query($form, $dbh, $query, @values); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); @@ -79,7 +80,8 @@ sub delete { do_query($form, $dbh, qq|DELETE FROM follow_up_links WHERE follow_up_id IN (SELECT DISTINCT id FROM follow_ups WHERE note_id = ?)|, $id); do_query($form, $dbh, qq|DELETE FROM follow_ups WHERE note_id = ?|, $id); do_query($form, $dbh, qq|DELETE FROM notes WHERE id = ?|, $id); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } diff --git a/SL/OE.pm b/SL/OE.pm index 0e671bd38..cc2851740 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -885,8 +885,8 @@ sub _close_quotations_rfqs { $query = qq|UPDATE oe SET closed = TRUE WHERE id IN (| . join(', ', ('?') x scalar @close_ids) . qq|)|; do_query($form, $dbh, $query, @close_ids); } - - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } @@ -905,7 +905,7 @@ sub delete { unlink map { "$spool/$_" } @spoolfiles if $spool; 1; - }); + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); diff --git a/SL/SEPA.pm b/SL/SEPA.pm index 074673261..b8cdee03f 100644 --- a/SL/SEPA.pm +++ b/SL/SEPA.pm @@ -280,7 +280,8 @@ sub close_export { my $query = qq|UPDATE sepa_export SET closed = TRUE WHERE id IN ($placeholders)|; do_query($form, $dbh, $query, map { conv_i($_) } @ids); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); } diff --git a/SL/TODO.pm b/SL/TODO.pm index c575fa847..ff29abb0a 100644 --- a/SL/TODO.pm +++ b/SL/TODO.pm @@ -95,7 +95,8 @@ sub save_user_config { push @values, $id; do_query($form, $dbh, $query, @values); - }); + 1; + }) or do { die SL::DB->client->error }; $main::lxdebug->leave_sub(); }