Bugzilla – Attachment 29631 Details for
Bug 5304
Too many post find queries for items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Bug 5304: GetItemsInfo should return arrayref instead of array
Bug-5304-GetItemsInfo-should-return-arrayref-inste.patch (text/plain), 14.93 KB, created by
Kyle M Hall
on 2014-07-11 12:34:33 UTC
(
hide
)
Description:
Bug 5304: GetItemsInfo should return arrayref instead of array
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2014-07-11 12:34:33 UTC
Size:
14.93 KB
patch
obsolete
>From c50352816027e4ebb9cd7755f72edef2caeaac44 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 11 Jul 2014 08:33:50 -0400 >Subject: [PATCH] Bug 5304: GetItemsInfo should return arrayref instead of array > >--- > C4/Items.pm | 12 +++++++----- > C4/XSLT.pm | 2 +- > basket/basket.pl | 2 +- > basket/sendbasket.pl | 2 +- > catalogue/detail.pl | 2 +- > catalogue/imageviewer.pl | 2 +- > catalogue/moredetail.pl | 2 +- > labels/label-item-search.pl | 2 +- > misc/migration_tools/rebuild_zebra.pl | 2 +- > opac/opac-ISBDdetail.pl | 2 +- > opac/opac-MARCdetail.pl | 2 +- > opac/opac-basket.pl | 2 +- > opac/opac-detail.pl | 4 ++-- > opac/opac-reserve.pl | 2 +- > opac/opac-sendbasket.pl | 2 +- > opac/opac-sendshelf.pl | 2 +- > reports/reservereport.pl | 2 +- > serials/routing-preview.pl | 2 +- > t/db_dependent/Items.t | 2 +- > tags/list.pl | 2 +- > tools/batchMod.pl | 2 +- > virtualshelves/sendshelf.pl | 2 +- > 22 files changed, 29 insertions(+), 27 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index c323308..948757e 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -1207,11 +1207,11 @@ sub GetItemsByBiblioitemnumber { > > =head2 GetItemsInfo > >- @results = GetItemsInfo($biblionumber); >+ $results = GetItemsInfo($biblionumber); > > Returns information about items with the given biblionumber. > >-C<GetItemsInfo> returns a list of references-to-hash. Each element >+C<GetItemsInfo> returns an arrayref of references-to-hash. Each element > contains a number of keys. Most of them are attributes from the > C<biblio>, C<biblioitems>, C<items>, and C<itemtypes> tables in the > Koha database. Other keys include: >@@ -1343,9 +1343,11 @@ sub GetItemsInfo { > $i++; > } > >- return $serial >+ @results = $serial > ? sort { ($b->{'publisheddate'} || $b->{'enumchron'}) cmp ($a->{'publisheddate'} || $a->{'enumchron'}) } @results > : @results; >+ >+ return \@results; > } > > =head2 GetItemsLocationInfo >@@ -1429,7 +1431,7 @@ sub GetHostItemsInfo { > foreach my $hostfield ( $record->field('773') ) { > my $hostbiblionumber = $hostfield->subfield("0"); > my $linkeditemnumber = $hostfield->subfield("9"); >- my @hostitemInfos = GetItemsInfo($hostbiblionumber); >+ my @hostitemInfos = @{GetItemsInfo($hostbiblionumber)}; > foreach my $hostitemInfo (@hostitemInfos){ > if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ > push (@returnitemsInfo,$hostitemInfo); >@@ -1441,7 +1443,7 @@ sub GetHostItemsInfo { > foreach my $hostfield ( $record->field('461') ) { > my $hostbiblionumber = $hostfield->subfield("0"); > my $linkeditemnumber = $hostfield->subfield("9"); >- my @hostitemInfos = GetItemsInfo($hostbiblionumber); >+ my @hostitemInfos = @{GetItemsInfo($hostbiblionumber)}; > foreach my $hostitemInfo (@hostitemInfos){ > if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ > push (@returnitemsInfo,$hostitemInfo); >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index bfacc65..71a5c2e 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -238,7 +238,7 @@ Is only used in this module currently. > sub buildKohaItemsNamespace { > my ($biblionumber, $hidden_items) = @_; > >- my @items = C4::Items::GetItemsInfo($biblionumber); >+ my @items = @{C4::Items::GetItemsInfo($biblionumber)}; > if ($hidden_items && @$hidden_items) { > my %hi = map {$_ => 1} @$hidden_items; > @items = grep { !$hi{$_->{itemnumber}} } @items; >diff --git a/basket/basket.pl b/basket/basket.pl >index 04f28de..ff89b58 100755 >--- a/basket/basket.pl >+++ b/basket/basket.pl >@@ -67,7 +67,7 @@ foreach my $biblionumber ( @bibs ) { > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $marcseriesarray = GetMarcSeries ($record,$marcflavour); > my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >- my @items = GetItemsInfo( $biblionumber ); >+ my @items = @{GetItemsInfo( $biblionumber )}; > > my $hasauthors = 0; > if($dat->{'author'} || @$marcauthorsarray) { >diff --git a/basket/sendbasket.pl b/basket/sendbasket.pl >index 40547f0..5825735 100755 >--- a/basket/sendbasket.pl >+++ b/basket/sendbasket.pl >@@ -80,7 +80,7 @@ if ( $email_add ) { > my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > >- my @items = GetItemsInfo( $biblionumber ); >+ my @items = @{GetItemsInfo( $biblionumber )}; > > my $hasauthors = 0; > if($dat->{'author'} || @$marcauthorsarray) { >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 3f71a87..8bd8765 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -122,7 +122,7 @@ my $branches = GetBranches(); > my $itemtypes = GetItemTypes(); > my $dbh = C4::Context->dbh; > >-my @all_items = GetItemsInfo( $biblionumber ); >+my @all_items = @{GetItemsInfo( $biblionumber )}; > my @items; > for my $itm (@all_items) { > push @items, $itm unless ( $itm->{itemlost} && GetHideLostItemsPreference($borrowernumber) && !$showallitems); >diff --git a/catalogue/imageviewer.pl b/catalogue/imageviewer.pl >index 6ecbc8d..2d66042 100755 >--- a/catalogue/imageviewer.pl >+++ b/catalogue/imageviewer.pl >@@ -45,7 +45,7 @@ my $imagenumber = $query->param('imagenumber'); > my $biblio = GetBiblio($biblionumber); > my $itemcount = GetItemsCount($biblionumber); > >-my @items = GetItemsInfo($biblionumber); >+my @items = @{GetItemsInfo($biblionumber)}; > > my $norequests = 1; > foreach my $item (@items) { >diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl >index 86adb72..b60f5dd 100755 >--- a/catalogue/moredetail.pl >+++ b/catalogue/moredetail.pl >@@ -91,7 +91,7 @@ my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); > # $data->{'dewey'}=$dewey; > > my $fw = GetFrameworkCode($biblionumber); >-my @all_items= GetItemsInfo($biblionumber); >+my @all_items = @{ GetItemsInfo($biblionumber) }; > my @items; > for my $itm (@all_items) { > push @items, $itm unless ( $itm->{itemlost} && >diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl >index 6d7db6f..4822bac 100755 >--- a/labels/label-item-search.pl >+++ b/labels/label-item-search.pl >@@ -120,7 +120,7 @@ if ($show_results) { > my @results_set = (); > my @items =(); > # This code needs to be refactored using these subs... >- #my @items = &GetItemsInfo( $biblio->{biblionumber}, 'intra' ); >+ #my @items = @{ GetItemsInfo( $biblio->{biblionumber}, 'intra' ) }; > #my $dat = &GetBiblioData( $biblio->{biblionumber} ); > for ( my $i = 0 ; $i < $hits ; $i++ ) { > my @row_data= (); >diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl >index 682e4be..5c6d748 100755 >--- a/misc/migration_tools/rebuild_zebra.pl >+++ b/misc/migration_tools/rebuild_zebra.pl >@@ -481,7 +481,7 @@ sub export_marc_records_from_sth { > ? GetXmlBiblio( $record_number ) > : GetAuthorityXML( $record_number ); > if ($record_type eq 'biblio'){ >- my @items = GetItemsInfo($record_number); >+ my @items = @{ GetItemsInfo($record_number) }; > if (@items){ > my $record = MARC::Record->new; > $record->encoding('UTF-8'); >diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl >index 2579a8b..0ca51d9 100755 >--- a/opac/opac-ISBDdetail.pl >+++ b/opac/opac-ISBDdetail.pl >@@ -85,7 +85,7 @@ $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); > > my $marcflavour = C4::Context->preference("marcflavour"); > >-my @items = GetItemsInfo($biblionumber); >+my @items = @{ GetItemsInfo($biblionumber) }; > if (scalar @items >= 1) { > my @hiddenitems = GetHiddenItemnumbers(@items); > >diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl >index aaa565d..3e957b8 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -66,7 +66,7 @@ if ( ! $biblionumber ) { > exit; > } > >-my @all_items = GetItemsInfo($biblionumber); >+my @all_items = @{ GetItemsInfo($biblionumber) }; > my @items2hide; > if (scalar @all_items >= 1) { > push @items2hide, GetHiddenItemnumbers(@all_items); >diff --git a/opac/opac-basket.pl b/opac/opac-basket.pl >index 7b3a90a..06d0e07 100755 >--- a/opac/opac-basket.pl >+++ b/opac/opac-basket.pl >@@ -70,7 +70,7 @@ foreach my $biblionumber ( @bibs ) { > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $marcseriesarray = GetMarcSeries ($record,$marcflavour); > my $marcurlsarray = GetMarcUrls ($record,$marcflavour); >- my @items = &GetItemsInfo( $biblionumber ); >+ my @items = @{ GetItemsInfo( $biblionumber ) }; > my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber)); > > my $hasauthors = 0; >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 224bf82..87e3391 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -74,7 +74,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > my $biblionumber = $query->param('biblionumber') || $query->param('bib') || 0; > $biblionumber = int($biblionumber); > >-my @all_items = GetItemsInfo($biblionumber); >+my @all_items = @{ GetItemsInfo($biblionumber) }; > my @hiddenitems; > if (scalar @all_items >= 1) { > push @hiddenitems, GetHiddenItemnumbers(@all_items); >@@ -455,7 +455,7 @@ if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){ > foreach my $hostfield ( $record->field($analyticfield)) { > my $hostbiblionumber = $hostfield->subfield("0"); > my $linkeditemnumber = $hostfield->subfield("9"); >- my @hostitemInfos = GetItemsInfo($hostbiblionumber); >+ my @hostitemInfos = @{ GetItemsInfo($hostbiblionumber) }; > foreach my $hostitemInfo (@hostitemInfos){ > if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ > push(@all_items, $hostitemInfo); >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index a842869..6a8298f 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -140,7 +140,7 @@ foreach my $biblioNumber (@biblionumbers) { > my $biblioData = GetBiblioData($biblioNumber); > $biblioDataHash{$biblioNumber} = $biblioData; > >- my @itemInfos = GetItemsInfo($biblioNumber); >+ my @itemInfos = @{ GetItemsInfo($biblioNumber) }; > > my $marcrecord= GetMarcBiblio($biblioNumber); > >diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl >index 5821bea..aab1576 100755 >--- a/opac/opac-sendbasket.pl >+++ b/opac/opac-sendbasket.pl >@@ -92,7 +92,7 @@ if ( $email_add ) { > my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > >- my @items = GetItemsInfo( $biblionumber ); >+ my @items = @{ GetItemsInfo( $biblionumber ) }; > > my $hasauthors = 0; > if($dat->{'author'} || @$marcauthorsarray) { >diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl >index 852ef8d..3fd2538 100755 >--- a/opac/opac-sendshelf.pl >+++ b/opac/opac-sendshelf.pl >@@ -89,7 +89,7 @@ if ( $email ) { > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $subtitle = GetRecordValue('subtitle', $record, $fw); > >- my @items = GetItemsInfo( $biblionumber ); >+ my @items = @{ GetItemsInfo( $biblionumber ) }; > > $dat->{ISBN} = GetMarcISBN($record, $marcflavour); > $dat->{MARCNOTES} = $marcnotesarray; >diff --git a/reports/reservereport.pl b/reports/reservereport.pl >index 42a1d20..82a2229 100755 >--- a/reports/reservereport.pl >+++ b/reports/reservereport.pl >@@ -96,7 +96,7 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { > # FIXME still need to shift the text to the template so its translateable > if ( $data->[$i]) { > # find if its on issue >- my @items = GetItemsInfo( $line{biblionumber} ); >+ my @items = @{ GetItemsInfo( $line{biblionumber} ) }; > my $onissue = 0; > foreach my $item (@items) { > if ( $item->{'datedue'} eq 'Reserved' ) { >diff --git a/serials/routing-preview.pl b/serials/routing-preview.pl >index 1e0bd09..995992c 100755 >--- a/serials/routing-preview.pl >+++ b/serials/routing-preview.pl >@@ -65,7 +65,7 @@ if($ok){ > # get biblio information.... > my $biblio = $subs->{'biblionumber'}; > my ($count2,@bibitems) = GetBiblioItemByBiblioNumber($biblio); >- my @itemresults = GetItemsInfo( $subs->{biblionumber} ); >+ my @itemresults = @{ GetItemsInfo( $subs->{biblionumber} ) }; > my $branch = $itemresults[0]->{'holdingbranch'}; > my $branchname = GetBranchName($branch); > >diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t >index ad52278..e41bd1b 100755 >--- a/t/db_dependent/Items.t >+++ b/t/db_dependent/Items.t >@@ -171,7 +171,7 @@ subtest 'GetItemsInfo tests' => sub { > $branch->{ opac_info } = "holdingbranch OPAC info"; > ModBranch($branch); > >- my @results = GetItemsInfo( $biblionumber ); >+ my @results = @{ GetItemsInfo($biblionumber) }; > ok( @results, 'GetItemsInfo returns results'); > is( $results[0]->{ home_branch_opac_info }, "homebranch OPAC info", > 'GetItemsInfo returns the correct home branch OPAC info notice' ); >diff --git a/tags/list.pl b/tags/list.pl >index 91914b3..c94f990 100755 >--- a/tags/list.pl >+++ b/tags/list.pl >@@ -67,7 +67,7 @@ else { > $dat->{'subtitle'} = > GetRecordValue( 'subtitle', $record, > GetFrameworkCode( $_->{biblionumber} ) ); >- my @items = GetItemsInfo( $_->{biblionumber} ); >+ my @items = @{ GetItemsInfo( $_->{biblionumber} ) }; > $dat->{biblionumber} = $_->{biblionumber}; > $dat->{tag_id} = $_->{tag_id}; > $dat->{items} = \@items; >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index bda2eff..50ff645 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -243,7 +243,7 @@ if ($op eq "show"){ > } > } else { > if (defined $biblionumber){ >- my @all_items = GetItemsInfo( $biblionumber ); >+ my @all_items = @{ GetItemsInfo( $biblionumber ) }; > foreach my $itm (@all_items) { > push @itemnumbers, $itm->{itemnumber}; > } >diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl >index 9866671..a3b1d93 100755 >--- a/virtualshelves/sendshelf.pl >+++ b/virtualshelves/sendshelf.pl >@@ -86,7 +86,7 @@ if ( $email ) { > my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); > my $subtitle = GetRecordValue('subtitle', $record, $fw); > >- my @items = GetItemsInfo( $biblionumber ); >+ my @items = @{ GetItemsInfo( $biblionumber ) }; > > $dat->{MARCNOTES} = $marcnotesarray; > $dat->{MARCSUBJCTS} = $marcsubjctsarray; >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 5304
:
2692
|
29596
|
29597
|
29606
|
29607
|
29629
|
29630
|
29631
|
32722
|
32723