From 5a575bfac0f4d1135139d575fea56fa577d3a1e2 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 13 Nov 2020 16:06:25 +0000 Subject: [PATCH] Bug 27002: (follow-up) Fix empty Koha::Item->pickup_locations In Koha::Item pickup_locations we were using the Koha::Objects->empty to return an effectively empty Koha::Libraries object. However, this only sets the result cache to an empty arrayref and as such only affect iterators and not subsequent chained queries (like the get_column I call to get back a DBIx::Class:ResultSetColumn in this patchset). As such, this patch updates the Koha::Item->pickup_locations method to use an always empty search ->search(\'0 = 1') to fulfil the same purpose as the prior call to empty and return an empty set that is available for both iterating and query chaining. --- Koha/Item.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 10d4eb2c48..2d4a5882a2 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -573,8 +573,8 @@ sub pickup_locations { C4::Circulation::GetBranchItemRule( $circ_control_branch, $self->itype ); if(defined $patron) { - return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} == 3 && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} ); - return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} == 1 && $self->home_branch->branchcode ne $patron->branchcode; + return Koha::Libraries->search(\'0 = 1') if $branchitemrule->{holdallowed} == 3 && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} ); + return Koha::Libraries->search(\'0 = 1') if $branchitemrule->{holdallowed} == 1 && $self->home_branch->branchcode ne $patron->branchcode; } my $pickup_libraries = Koha::Libraries->search(); -- 2.20.1