From 5873771874342c44ae69817946d80a2b9f152a07 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 4 Dec 2013 12:33:54 +0100 Subject: [PATCH] Bug 11336: Priority is not updated on deleting holds There are a lot of places where a hold deletion is possible. But I just found 1 place where it works! To reproduce: - select or create 2 users U1 and U2 - select or create an holdable item - place on hold for both U1 and U2. U1 has priority 1 and U2 has priority 2. - delete the hold for U1 - go on circ/circulation.pl?borrowernumber=XXXX for U2 (or in the DB directly) and verify the priority has not been set to 1 The issue is repeatable (at least) on these 2 pages: * circ/circulation.pl?borrowernumber=XXXX (tab 'Holds', select "yes" in the dropdown list and submit the form) * reserve/request.pl?biblionumber=XXXX (clic on the red cross) The CancelReserve calls _FixPriority with a reserveid. _FixPriority try to retrieve the reserve with this reserveid but it does not exist anymore... Signed-off-by: Christopher Brannon --- C4/Reserves.pm | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index d1bca25..d04996d 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1003,6 +1003,7 @@ sub CancelReserve { my $reserve_id = $params->{'reserve_id'}; $reserve_id = GetReserveId( $params ) unless ( $reserve_id ); + my $reserve = GetReserve( $reserve_id ); return unless ( $reserve_id ); @@ -1034,7 +1035,7 @@ sub CancelReserve { $sth->execute( $reserve_id ); # now fix the priority on the others.... - _FixPriority( $reserve_id ); + _FixPriority( undef, undef, undef, $reserve->{biblionumber} ); } =head2 ModReserve @@ -1625,16 +1626,16 @@ in new priority rank =cut sub _FixPriority { - my ( $reserve_id, $rank, $ignoreSetLowestRank ) = @_; + my ( $reserve_id, $rank, $ignoreSetLowestRank, $biblionumber ) = @_; my $dbh = C4::Context->dbh; my $res = GetReserve( $reserve_id ); + $biblionumber ||= $res->{biblionumber}; if ( $rank eq "del" ) { CancelReserve({ reserve_id => $reserve_id }); } elsif ( $rank eq "W" || $rank eq "0" ) { - # make sure priority for waiting or in-transit items is 0 my $query = " UPDATE reserves @@ -1656,7 +1657,7 @@ sub _FixPriority { ORDER BY priority ASC "; my $sth = $dbh->prepare($query); - $sth->execute( $res->{'biblionumber'} ); + $sth->execute( $biblionumber ); while ( my $line = $sth->fetchrow_hashref ) { push( @priority, $line ); } -- 1.7.2.5