From 79d4dbf7b004446010590ae2a64fffad9469716f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 29 Jul 2022 13:06:48 +0200 Subject: [PATCH] Bug 27272: Call search_ordered when GetItemsInfo was called before --- basket/basket.pl | 2 +- basket/sendbasket.pl | 2 +- opac/opac-detail.pl | 8 ++++---- opac/opac-reserve.pl | 4 ++-- opac/opac-sendbasket.pl | 2 +- opac/opac-sendshelf.pl | 2 +- opac/opac-tags.pl | 2 +- serials/routing-preview.pl | 2 +- tags/list.pl | 5 +++-- virtualshelves/sendshelf.pl | 2 +- 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/basket/basket.pl b/basket/basket.pl index 12526138d1..88a5bd5dae 100755 --- a/basket/basket.pl +++ b/basket/basket.pl @@ -89,7 +89,7 @@ foreach my $biblionumber ( @bibs ) { $num++; $dat->{biblionumber} = $biblionumber; - $dat->{ITEM_RESULTS} = $biblio->items; + $dat->{ITEM_RESULTS} = $biblio->items->search_ordered; $dat->{MARCNOTES} = $marcnotesarray; $dat->{MARCSUBJCTS} = $marcsubjctsarray; $dat->{MARCAUTHORS} = $marcauthorsarray; diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl index cbd64b3fc8..ec9e1a2463 100755 --- a/basket/sendbasket.pl +++ b/basket/sendbasket.pl @@ -85,7 +85,7 @@ if ( $email_add ) { $dat->{MARCAUTHORS} = $marcauthorsarray; $dat->{HASAUTHORS} = $hasauthors; $dat->{'biblionumber'} = $biblionumber; - $dat->{ITEM_RESULTS} = $biblio->items; + $dat->{ITEM_RESULTS} = $biblio->items->search_ordered; $iso2709 .= $record->as_usmarc(); diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index e0ad9e9f6c..4590c1dbdc 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -114,9 +114,9 @@ unless ( $biblio && $record ) { exit; } -my $items = $biblio->items; +my $items = $biblio->items->search_ordered; if ($specific_item) { - $items->search( { itemnumber => scalar $query->param('itemnumber') } ); + $items = $items->search( { itemnumber => scalar $query->param('itemnumber') } ); $template->param( specific_item => 1 ); } @@ -496,9 +496,9 @@ $template->param( my $host_items = $biblio->host_items->filter_by_visible_in_opac({ patron => $patron }); -$items = $biblio->items->search( +$items = $biblio->items->search_ordered( { - itemnumber => { + 'me.itemnumber' => { -in => [ $items->get_column('itemnumber'), $host_items->get_column('itemnumber') diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 9e907d1f5b..6cdbbbd3df 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -155,7 +155,7 @@ foreach my $biblioNumber (@biblionumbers) { $biblio->items->filter_by_visible_in_opac( { patron => $patron } ); my $host_items = $biblio->host_items->filter_by_visible_in_opac( { patron => $patron } ); - $items = $biblio->items->search( + $items = $biblio->items->search_ordered( { itemnumber => { -in => [ @@ -571,7 +571,7 @@ foreach my $biblioNum (@biblionumbers) { if ( $biblioLoopIter{holdable} and C4::Context->preference('AllowHoldItemTypeSelection') ) { # build the allowed item types loop - my $rs = $biblio->items->search( + my $rs = $biblio->items->search_ordered( undef, { select => [ { distinct => 'itype' } ], as => 'item_type' diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl index 7ce5f9fdab..cc33d121db 100755 --- a/opac/opac-sendbasket.pl +++ b/opac/opac-sendbasket.pl @@ -85,7 +85,7 @@ if ( $email_add ) { my $marcauthorsarray = $biblio->get_marc_authors; my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); - my $items = $biblio->items->filter_by_visible_in_opac({ patron => $patron }); + my $items = $biblio->items->search_ordered->filter_by_visible_in_opac({ patron => $patron }); my $hasauthors = 0; if($dat->{'author'} || @$marcauthorsarray) { diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index 768e372b4f..17afa1a82e 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -94,7 +94,7 @@ if ( $shelf and $shelf->can_be_viewed( $borrowernumber ) ) { my $marcauthorsarray = $biblio->get_marc_authors; my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); - my $items = $biblio->items->filter_by_visible_in_opac({ patron => $patron }); + my $items = $biblio->items->search_ordered->filter_by_visible_in_opac({ patron => $patron }); $dat->{ISBN} = GetMarcISBN($record, $marcflavour); $dat->{MARCSUBJCTS} = $marcsubjctsarray; diff --git a/opac/opac-tags.pl b/opac/opac-tags.pl index 17cacc7307..4aec61ee73 100755 --- a/opac/opac-tags.pl +++ b/opac/opac-tags.pl @@ -260,7 +260,7 @@ if ($loggedinuser) { next unless $record; my @hidden_items; if ($should_hide) { - my $items = $biblio->items; + my $items = $biblio->items->search_ordered; my @all_itemnumbers = $items->get_column('itemnumber'); my @items_to_show = $items->filter_by_visible_in_opac({ opac => 1, patron => $patron })->as_list; @hidden_items = array_minus( @all_itemnumbers, @items_to_show ); diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl index d6cadaabf9..0e62a68c81 100755 --- a/serials/routing-preview.pl +++ b/serials/routing-preview.pl @@ -65,7 +65,7 @@ if($ok){ # get existing reserves ..... my $biblio = Koha::Biblios->find( $biblionumber ); - my $items = $biblio->items; + my $items = $biblio->items->search_ordered; my $branch = $items->count ? $items->next->holding_branch->branchcode diff --git a/tags/list.pl b/tags/list.pl index 95531f2a75..b9aec1aa19 100755 --- a/tags/list.pl +++ b/tags/list.pl @@ -26,7 +26,7 @@ use C4::Context; use C4::Tags qw( get_tag_rows get_tags remove_tag ); use C4::Output qw( output_html_with_http_headers ); -use Koha::Items; +use Koha::Biblios; my $needed_flags = { tools => 'moderate_tags' }; # FIXME: replace when more specific permission is created. @@ -60,7 +60,8 @@ else { for ( @{$taglist} ) { # FIXME We should use Koha::Biblio here my $dat = &GetBiblioData( $_->{biblionumber} ); - my $items = Koha::Items->search({ biblionumber => $dat->{biblionumber} }); + my $biblio = Koha::Biblios->find($dat->{biblionumber}); + my $items = $biblio->items->search_ordered; $dat->{biblionumber} = $_->{biblionumber}; $dat->{tag_id} = $_->{tag_id}; $dat->{items} = $items; diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index 4000192b3b..7e9111173f 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -82,7 +82,7 @@ if ($to_address) { my $marcauthorsarray = $biblio->get_marc_authors; my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); - my $items = $biblio->items; + my $items = $biblio->items->search_ordered; $dat->{ISBN} = GetMarcISBN($record, $marcflavour); $dat->{MARCSUBJCTS} = $marcsubjctsarray; -- 2.37.1