From be5f6c19ecd278f9b34679e2b21543f5ac4f8c94 Mon Sep 17 00:00:00 2001 From: Kenza Zaki Date: Mon, 5 Aug 2013 11:50:40 +0200 Subject: [PATCH] Bug 10682 : Inappropriate uses of finish() in C4::Reserves 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/Reserves.pm | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 1f89127..d340759 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -611,7 +611,6 @@ sub GetReserveFee { my $sth = $dbh->prepare($query); $sth->execute($borrowernumber); my $data = $sth->fetchrow_hashref; - $sth->finish(); my $fee = $data->{'reservefee'}; my $cntitems = @- > $bibitems; @@ -652,7 +651,6 @@ sub GetReserveFee { } } } - $sth1->finish; my $cntitemsfound = @biblioitems; my $issues = 0; my $x = 0; @@ -995,7 +993,6 @@ sub CancelReserve { "; my $sth = $dbh->prepare($query); $sth->execute( $reserve_id ); - $sth->finish; $query = " INSERT INTO old_reserves @@ -1078,7 +1075,6 @@ sub ModReserve { "; my $sth = $dbh->prepare($query); $sth->execute( $reserve_id ); - $sth->finish; $query = " INSERT INTO old_reserves SELECT * @@ -1102,7 +1098,6 @@ sub ModReserve { "; my $sth = $dbh->prepare($query); $sth->execute( $rank, $branchcode, $itemnumber, $reserve_id ); - $sth->finish; if ( defined( $suspend_until ) ) { if ( $suspend_until ) { @@ -1148,7 +1143,6 @@ sub ModReserveFill { my $sth = $dbh->prepare($query); $sth->execute( $biblionumber, $borrowernumber, $resdate ); ($priority) = $sth->fetchrow_array; - $sth->finish; # update the database... $query = "UPDATE reserves @@ -1160,7 +1154,6 @@ sub ModReserveFill { "; $sth = $dbh->prepare($query); $sth->execute( $biblionumber, $resdate, $borrowernumber ); - $sth->finish; # move to old_reserves $query = "INSERT INTO old_reserves @@ -1502,7 +1495,6 @@ sub ToggleLowestPriority { my $sth = $dbh->prepare( "UPDATE reserves SET lowestPriority = NOT lowestPriority WHERE reserve_id = ?"); $sth->execute( $reserve_id ); - $sth->finish; _FixPriority( $reserve_id, '999999' ); } @@ -1537,7 +1529,6 @@ sub ToggleSuspend { push( @params, $reserve_id ); $sth->execute( @params ); - $sth->finish; } =head2 SuspendAll @@ -1593,7 +1584,6 @@ sub SuspendAll { $dbh = C4::Context->dbh; $sth = $dbh->prepare( $query ); $sth->execute( @query_params ); - $sth->finish; } @@ -1677,7 +1667,6 @@ sub _FixPriority { $j + 1, $priority[$j]->{'reserve_id'} ); - $sth->finish; } $sth = $dbh->prepare( "SELECT reserve_id FROM reserves WHERE lowestPriority = 1 ORDER BY priority" ); -- 1.7.9.5