From fc0f76e48391f6ad8b13a447e40d979bb8f4ba4e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 8 May 2020 10:04:30 -0300 Subject: [PATCH] Bug 25421: Remove use of Koha::Libraries->pickup_locations The current implementation uses Koha::Libraries->pickup_locations which is problematic and due to be removed by bug 24368. This patch makes the trivial change of just searching for libraries that are marked with pickup_location => 1. Calls to Koha::Item->pickup_locations and Koha::Biblio->pickup_locations are as well adapted to the new arrayref return value. To test: 1. Pick a record with only one item 2. Place a biblio-level hold on it 3. Edit the items: remove the item 4. Go to the Holds tab => FAIL: It explodes 5. Apply this patch and restart: $ sudo koha-plack --restart kohadev 6. Go back and go to the holds tab again => SUCCESS: No failure! 7. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: Didier Gautheron Signed-off-by: Jonathan Druart --- Koha/Template/Plugin/Branches.pm | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index 2d246c0a72..e5c8bdc9b5 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -113,17 +113,25 @@ sub pickup_locations { $patron = Koha::Patrons->find($patron); } - if($item) { - $item = Koha::Items->find($item) unless ref($item) eq 'Koha::Item'; - @libraries = map { $_->unblessed } $item->pickup_locations( {patron => $patron} ) if defined $item; - } elsif($biblio) { - $biblio = Koha::Biblios->find($biblio) unless ref($biblio) eq 'Koha::Biblio'; - @libraries = map { $_->unblessed } $biblio->pickup_locations( {patron => $patron} ) if defined $biblio; + if ($item) { + $item = Koha::Items->find($item) + unless ref($item) eq 'Koha::Item'; + @libraries = @{ $item->pickup_locations( { patron => $patron } ) } + if defined $item; + } + elsif ($biblio) { + $biblio = Koha::Biblios->find($biblio) + unless ref($biblio) eq 'Koha::Biblio'; + @libraries = @{ $biblio->pickup_locations( { patron => $patron } ) } + if defined $biblio; } - } - @libraries = Koha::Libraries->pickup_locations() unless @libraries; + @libraries = Koha::Libraries->search( { pickup_location => 1 }, + { order_by => ['branchname'] } )->as_list + unless @libraries; + + @libraries = map { $_->unblessed } @libraries; for my $l (@libraries) { if ( defined $selected and $l->{branchcode} eq $selected -- 2.20.1