From 3ecc6fd8c68af0ed410ee2ea77060999993220a7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 2 Aug 2017 11:49:08 -0300 Subject: [PATCH] Bug 19025: Move GetReserveInfo to Koha::Holds This subroutine is only used once and can be replaced with a call to Koha::Holds->find It will avoid unnecessary joins. Test plan: - Define a HOLD_SLIP template notice using fields from the tables reserves, branches, borrowers, biblio, biblioitems and items. - Generate one and make sure the values are correctly filled Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- C4/Reserves.pm | 3 ++- t/db_dependent/Holds.t | 9 ++------- t/db_dependent/Reserves/GetReserveFee.t | 1 - 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 50982306a1..04bd7d9d36 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -2178,7 +2178,8 @@ sub ReserveSlip { biblionumber => $biblionumber, borrowernumber => $borrowernumber }) or return; - my $reserve = GetReserveInfo($reserve_id) or return; + my $reserve = Koha::Holds->find($reserve_id) or return; + $reserve = $reserve->unblessed; return C4::Letters::GetPreparedLetter ( module => 'circulation', diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index ad87b26129..584acb281d 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -7,7 +7,7 @@ use t::lib::TestBuilder; use C4::Context; -use Test::More tests => 58; +use Test::More tests => 57; use MARC::Record; use C4::Biblio; use C4::Items; @@ -211,11 +211,6 @@ ModReserveMinusPriority( $itemnumber, $reserve->{'reserve_id'} ); $holds = $patron->holds; is( $holds->next->itemnumber, $itemnumber, "Test ModReserveMinusPriority()" ); - -my $reserve2 = GetReserveInfo( $reserve->{'reserve_id'} ); -ok( $reserve->{'reserve_id'} eq $reserve2->{'reserve_id'}, "Test GetReserveInfo()" ); - - $holds = $biblio->holds; $hold = $holds->next; AlterPriority( 'top', $hold->reserve_id ); @@ -323,7 +318,7 @@ my $reserveid2 = C4::Reserves::GetReserveId( CancelReserve({ reserve_id => $reserveid1 }); -$reserve2 = GetReserve( $reserveid2 ); +my $reserve2 = GetReserve( $reserveid2 ); is( $reserve2->{priority}, 1, "After cancelreserve, the 2nd reserve becomes the first on the waiting list" ); ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1 } , $bibnum); diff --git a/t/db_dependent/Reserves/GetReserveFee.t b/t/db_dependent/Reserves/GetReserveFee.t index 97d870a1e7..80d428b0b5 100755 --- a/t/db_dependent/Reserves/GetReserveFee.t +++ b/t/db_dependent/Reserves/GetReserveFee.t @@ -193,7 +193,6 @@ subtest 'Integration with AddIssue' => sub { $dbh->do( "DELETE FROM issues WHERE borrowernumber = ?", undef, $patron1->{borrowernumber} ); my $id = addreserve( $patron1->{borrowernumber} ); - my $r = C4::Reserves::GetReserveInfo($id); is( acctlines( $patron1->{borrowernumber} ), 0, 'any_time_is_collected - Patron should not be charged yet (just checking to make sure)'); C4::Circulation::AddIssue( $patron1, $item1->{barcode}, '2015-12-31', 0, undef, 0, {} ); is( acctlines( $patron1->{borrowernumber} ), 1, 'any_time_is_collected - Patron should not be charged when checking out an item which was not placed hold for him' ); -- 2.39.5