Bugzilla – Attachment 129081 Details for
Bug 29807
Branches template plugin doesn't handle empty lists correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29807: Make Branches plugin handle empty pickup locations list
Bug-29807-Make-Branches-plugin-handle-empty-pickup.patch (text/plain), 2.96 KB, created by
Martin Renvoize (ashimema)
on 2022-01-06 13:36:30 UTC
(
hide
)
Description:
Bug 29807: Make Branches plugin handle empty pickup locations list
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-01-06 13:36:30 UTC
Size:
2.96 KB
patch
obsolete
>From c6f7bd5e8f94affee0d9a1cece5760a7958bfb2f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 6 Jan 2022 08:53:30 -0300 >Subject: [PATCH] Bug 29807: Make Branches plugin handle empty pickup locations > list > >This patch makes the plugin handle empty Koha::Biblio->pickup_locations >and Koha::Item->pickup_locations correctly. > >It does so by explicitly calling ->as_list. It also restores the logic >that was changed by 6cd1ffab4e491349c99769018a7df33dc8a8aabf so, now >that ->empty is handled correctly, it doesn't return ALL the pickup >locations when the item/biblio doesn't have valid pickup locations. > >To test: >1. Apply the regression tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/Template/Plugin/Branches.t >=> FAIL: Awful error >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Template/Plugin/Branches.pm | 20 +++++++++----------- > 1 file changed, 9 insertions(+), 11 deletions(-) > >diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm >index a4db89b61c..8f82e0217a 100644 >--- a/Koha/Template/Plugin/Branches.pm >+++ b/Koha/Template/Plugin/Branches.pm >@@ -111,33 +111,31 @@ sub pickup_locations { > my $selected = $params->{selected}; > my @libraries; > >- if(defined $search_params->{item} || defined $search_params->{biblio}) { >- my $item = $search_params->{'item'}; >+ if ( defined $search_params->{item} || defined $search_params->{biblio} ) { >+ my $item = $search_params->{'item'}; > my $biblio = $search_params->{'biblio'}; > my $patron = $search_params->{'patron'}; > >- unless (! defined $patron || ref($patron) eq 'Koha::Patron') { >+ unless ( !defined $patron || ref($patron) eq 'Koha::Patron' ) { > $patron = Koha::Patrons->find($patron); > } > > if ($item) { > $item = Koha::Items->find($item) > unless ref($item) eq 'Koha::Item'; >- @libraries = $item->pickup_locations( { patron => $patron } ) >+ @libraries = $item->pickup_locations( { patron => $patron } )->as_list > if defined $item; >- } >- elsif ($biblio) { >+ } elsif ($biblio) { > $biblio = Koha::Biblios->find($biblio) > unless ref($biblio) eq 'Koha::Biblio'; >- @libraries = $biblio->pickup_locations( { patron => $patron } ) >+ @libraries = $biblio->pickup_locations( { patron => $patron } )->as_list > if defined $biblio; > } >+ } else { >+ @libraries = Koha::Libraries->search( { pickup_location => 1 }, { order_by => ['branchname'] } ) >+ unless @libraries; > } > >- @libraries = Koha::Libraries->search( { pickup_location => 1 }, >- { order_by => ['branchname'] } ) >- unless @libraries; >- > @libraries = map { $_->unblessed } @libraries; > > for my $l (@libraries) { >-- >2.20.1
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 29807
:
129056
|
129057
|
129065
|
129066
|
129080
| 129081