This patch makes Koha::Biblio->items use _new_from_dbic instead of
calling Koha::Items->search. This allows calling it with prefetch
enabled for the items relationship. No noticeable behaviour change takes
place besides this.
To test:
- Run:
$ kshell
k$ prove t/db_dependent/Koha/Biblio.t
=> SUCCESS: Tests pass!
- Apply this patch
- Run:
k$ prove t/db_dependent/Koha/Biblio.t
=> SUCCESS: Tests still pass!
- Sign off :-D
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
sub items {
my ($self) = @_;
- $self->{_items} ||= Koha::Items->search( { biblionumber => $self->biblionumber() } );
+ my $items_rs = $self->_result->items;
- return wantarray ? $self->{_items}->as_list : $self->{_items};
+ return
+ wantarray
+ ? Koha::Items->_new_from_dbic($items_rs)->as_list
+ : Koha::Items->_new_from_dbic($items_rs);
}
=head3 itemtype