Bugzilla – Attachment 20110 Details for
Bug 10685
Inappropriate uses of finish() in C4::Accounts.pm
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10685: Inappropriate uses of finish in C4::Accounts.pm
Bug-10685-Inappropriate-uses-of-finish-in-C4Accoun.patch (text/plain), 4.40 KB, created by
kenza
on 2013-08-05 14:07:27 UTC
(
hide
)
Description:
Bug 10685: Inappropriate uses of finish in C4::Accounts.pm
Filename:
MIME Type:
Creator:
kenza
Created:
2013-08-05 14:07:27 UTC
Size:
4.40 KB
patch
obsolete
>From 9cfbee1819479a8743e48c60e3ab4be6529841cb Mon Sep 17 00:00:00 2001 >From: Kenza Zaki <kenza.zaki@biblibre.com> >Date: Mon, 5 Aug 2013 15:55:40 +0200 >Subject: [PATCH] Bug 10685: Inappropriate uses of finish in C4::Accounts.pm > >This patch gets rid of finish. > >From the man page > >finish() >Indicate that no more data will be fetched from this statement handle >before it is either executed again or destroyed. >You almost certainly do not need to call this method. > >Adding calls to "finish" after loop that fetches all rows is a common >mistake, don't do it, it can mask genuine problems like uncaught fetch errors. >--- > C4/Accounts.pm | 15 --------------- > 1 file changed, 15 deletions(-) > >diff --git a/C4/Accounts.pm b/C4/Accounts.pm >index f087b7a..4b4ae04 100644 >--- a/C4/Accounts.pm >+++ b/C4/Accounts.pm >@@ -202,7 +202,6 @@ sub makepayment { > my $sth = $dbh->prepare("SELECT * FROM accountlines WHERE accountlines_id=?"); > $sth->execute( $accountlines_id ); > my $data = $sth->fetchrow_hashref; >- $sth->finish; > > my $payment; > if ( $data->{'accounttype'} eq "Pay" ){ >@@ -214,7 +213,6 @@ sub makepayment { > " > ); > $udp->execute($accountlines_id); >- $udp->finish; > }else{ > my $udp = > $dbh->prepare( >@@ -224,7 +222,6 @@ sub makepayment { > " > ); > $udp->execute($accountlines_id); >- $udp->finish; > > # create new line > my $payment = 0 - $amount; >@@ -237,7 +234,6 @@ sub makepayment { > VALUES ( ?, ?, now(), ?, ?, 'Payment,thanks', 'Pay', 0, ?, ?)" > ); > $ins->execute($borrowernumber, $nextaccntno, $payment, $data->{'itemnumber'}, $manager_id, $payment_note); >- $ins->finish; > } > > if ( C4::Context->preference("FinesLog") ) { >@@ -279,7 +275,6 @@ sub makepayment { > my $sthr = $dbh->prepare("SELECT max(accountlines_id) AS lastinsertid FROM accountlines"); > $sthr->execute(); > my $datalastinsertid = $sthr->fetchrow_hashref; >- $sthr->finish; > return $datalastinsertid->{'lastinsertid'}; > } > >@@ -364,7 +359,6 @@ sub chargelostitem{ > VALUES (?,?,now(),?,?,'L',?,?,?)"); > $sth2->execute($borrowernumber,$accountno,$amount, > $description,$amount,$itemnumber,$manager_id); >- $sth2->finish; > > if ( C4::Context->preference("FinesLog") ) { > logaction("FINES", 'CREATE', $borrowernumber, Dumper({ >@@ -532,7 +526,6 @@ sub fixcredit { > my $sth = $dbh->prepare($query); > $sth->execute( $borrowernumber, $item->{'itemnumber'} ); > $accdata = $sth->fetchrow_hashref; >- $sth->finish; > if ( $accdata->{'amountoutstanding'} < $amountleft ) { > $newamtos = 0; > $amountleft -= $accdata->{'amountoutstanding'}; >@@ -547,7 +540,6 @@ sub fixcredit { > WHERE (accountlines_id = ?)" > ); > $usth->execute( $newamtos, $thisacct ); >- $usth->finish; > $usth = $dbh->prepare( > "INSERT INTO accountoffsets > (borrowernumber, accountno, offsetaccount, offsetamount) >@@ -555,7 +547,6 @@ sub fixcredit { > ); > $usth->execute( $borrowernumber, $accdata->{'accountno'}, > $nextaccntno, $newamtos ); >- $usth->finish; > } > > # begin transaction >@@ -586,7 +577,6 @@ sub fixcredit { > WHERE (accountlines_id = ?)" > ); > $usth->execute( $newamtos, $thisacct ); >- $usth->finish; > $usth = $dbh->prepare( > "INSERT INTO accountoffsets > (borrowernumber, accountno, offsetaccount, offsetamount) >@@ -594,9 +584,7 @@ sub fixcredit { > ); > $usth->execute( $borrowernumber, $accdata->{'accountno'}, > $nextaccntno, $newamtos ); >- $usth->finish; > } >- $sth->finish; > $type = "Credit " . $type; > UpdateStats( $user, $type, $data, $user, '', '', $borrowernumber ); > $amountleft *= -1; >@@ -652,7 +640,6 @@ sub refund { > WHERE (accountlines_id = ?)" > ); > $usth->execute( $newamtos, $thisacct ); >- $usth->finish; > $usth = $dbh->prepare( > "INSERT INTO accountoffsets > (borrowernumber, accountno, offsetaccount, offsetamount) >@@ -660,9 +647,7 @@ sub refund { > ); > $usth->execute( $borrowernumber, $accdata->{'accountno'}, > $nextaccntno, $newamtos ); >- $usth->finish; > } >- $sth->finish; > return ($amountleft); > } > >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10685
:
20110
|
20615
|
20647