Bug 27071: (follow-up) Get rid of loop
This patch gets rid of a loop on the librarary's groups siblings, and
acknowledges ->get_hold_libraries returns a proper Koha::Libraries
iterator that can be chained with a new query on the passed branchcode.
This way we only fetch a count from the DB and no loop needs to take
place on the code.
To test:
1. Apply this patch
2. Run:
$ kshell
k$ prove t/db_dependent/Koha/Libraries.t
=> SUCCESS: Tests pass!
3. Sign off :-D
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 3495a7e9af)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
17bcc1aeea
commit
3525fc03c6
|
|
@ -244,8 +244,8 @@ sub validate_hold_sibling {
|
|||
return 1 if $params->{branchcode} eq $self->id;
|
||||
|
||||
my $branchcode = $params->{branchcode};
|
||||
my @hold_libraries = $self->get_hold_libraries;
|
||||
return grep {$_->branchcode eq $branchcode} @hold_libraries;
|
||||
return $self->get_hold_libraries->search( { branchcode => $branchcode } )
|
||||
->count > 0;
|
||||
}
|
||||
|
||||
=head2 Internal methods
|
||||
|
|
|
|||
Loading…
Reference in New Issue