Bug 36362: Only call Koha::Libraries->search() if necessary in Item::pickup_locations
To test: 1) Make sure the following tests pass: - t/db_dependent/Koha/Item.t - t/db_dependent/Koha/Biblios.t - db_dependent/Koha/Biblio.t Sponsored-by: Gothenburg University Library Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
1a154f1f0e
commit
2c1e955621
1 changed files with 14 additions and 5 deletions
19
Koha/Item.pm
19
Koha/Item.pm
|
@ -1000,10 +1000,16 @@ sub pickup_locations {
|
||||||
my $branchitemrule =
|
my $branchitemrule =
|
||||||
C4::Circulation::GetBranchItemRule( $circ_control_branch, $self->itype );
|
C4::Circulation::GetBranchItemRule( $circ_control_branch, $self->itype );
|
||||||
|
|
||||||
return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_local_hold_group' && !$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} );
|
if (
|
||||||
return Koha::Libraries->new()->empty if $branchitemrule->{holdallowed} eq 'from_home_library' && $self->home_branch->branchcode ne $patron->branchcode;
|
$branchitemrule->{holdallowed} eq 'from_local_hold_group' &&
|
||||||
|
!$self->home_branch->validate_hold_sibling( {branchcode => $patron->branchcode} ) ||
|
||||||
|
$branchitemrule->{holdallowed} eq 'from_home_library' &&
|
||||||
|
$self->home_branch->branchcode ne $patron->branchcode
|
||||||
|
) {
|
||||||
|
return Koha::Libraries->new()->empty;
|
||||||
|
}
|
||||||
|
|
||||||
my $pickup_libraries = Koha::Libraries->search();
|
my $pickup_libraries;
|
||||||
if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup') {
|
if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup') {
|
||||||
$pickup_libraries = $self->home_branch->get_hold_libraries;
|
$pickup_libraries = $self->home_branch->get_hold_libraries;
|
||||||
} elsif ($branchitemrule->{hold_fulfillment_policy} eq 'patrongroup') {
|
} elsif ($branchitemrule->{hold_fulfillment_policy} eq 'patrongroup') {
|
||||||
|
@ -1013,7 +1019,9 @@ sub pickup_locations {
|
||||||
$pickup_libraries = Koha::Libraries->search({ branchcode => $self->homebranch });
|
$pickup_libraries = Koha::Libraries->search({ branchcode => $self->homebranch });
|
||||||
} elsif ($branchitemrule->{hold_fulfillment_policy} eq 'holdingbranch') {
|
} elsif ($branchitemrule->{hold_fulfillment_policy} eq 'holdingbranch') {
|
||||||
$pickup_libraries = Koha::Libraries->search({ branchcode => $self->holdingbranch });
|
$pickup_libraries = Koha::Libraries->search({ branchcode => $self->holdingbranch });
|
||||||
};
|
} else {
|
||||||
|
$pickup_libraries = Koha::Libraries->search();
|
||||||
|
}
|
||||||
|
|
||||||
return $pickup_libraries->search(
|
return $pickup_libraries->search(
|
||||||
{
|
{
|
||||||
|
@ -1025,7 +1033,8 @@ sub pickup_locations {
|
||||||
) unless C4::Context->preference('UseBranchTransferLimits');
|
) unless C4::Context->preference('UseBranchTransferLimits');
|
||||||
|
|
||||||
my $limittype = C4::Context->preference('BranchTransferLimitsType');
|
my $limittype = C4::Context->preference('BranchTransferLimitsType');
|
||||||
my ($ccode, $itype) = (undef, undef);
|
my $ccode;
|
||||||
|
my $itype;
|
||||||
if( $limittype eq 'ccode' ){
|
if( $limittype eq 'ccode' ){
|
||||||
$ccode = $self->ccode;
|
$ccode = $self->ccode;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue