From 82dc7b55a8b5a7642a906dcd8963952b7464adb1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 24 Jul 2012 15:39:15 +0200 Subject: [PATCH] Bug 4321: clean C4::Biblio::GetBiblio and uses Signed-off-by: Kyle M Hall Signed-off-by: Jared Camins-Esakov Signed-off-by: Paul Poulain --- C4/Biblio.pm | 12 +++++------- C4/ILSDI/Services.pm | 6 +++--- C4/ImportBatch.pm | 4 ++-- C4/Serials.pm | 2 +- catalogue/imageviewer.pl | 2 +- catalogue/issuehistory.pl | 4 ++-- opac/opac-imageviewer.pl | 2 +- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 5500b305c9..533fcb67d4 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -999,7 +999,7 @@ sub GetISBDView { =head2 GetBiblio - ( $count, @results ) = &GetBiblio($biblionumber); + my $biblio = &GetBiblio($biblionumber); =cut @@ -1010,12 +1010,10 @@ sub GetBiblio { my $count = 0; my @results; $sth->execute($biblionumber); - while ( my $data = $sth->fetchrow_hashref ) { - $results[$count] = $data; - $count++; - } # while - $sth->finish; - return ( $count, @results ); + if ( my $data = $sth->fetchrow_hashref ) { + return $data; + } + return; } # sub GetBiblio =head2 GetBiblioItemInfosOf diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 12f869fcd7..d685e6c210 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -411,7 +411,7 @@ sub GetPatronInfo { # Add additional fields $reserve->{'item'} = $item; $reserve->{'branchname'} = $branchname; - $reserve->{'title'} = ( GetBiblio( $reserve->{'biblionumber'} ) )[1]->{'title'}; + $reserve->{'title'} = GetBiblio( $reserve->{'biblionumber'} )->{'title'}; } $borrower->{'holds'}->{'hold'} = \@reserves; } @@ -601,7 +601,7 @@ sub HoldTitle { # Get the biblio record, or return an error code my $biblionumber = $cgi->param('bib_id'); - my ( $count, $biblio ) = GetBiblio( $biblionumber ); + my $biblio = GetBiblio( $biblionumber ); return { code => 'RecordNotFound' } unless $$biblio{biblionumber}; my $title = $$biblio{title}; @@ -666,7 +666,7 @@ sub HoldItem { # Get the biblio or return an error code my $biblionumber = $cgi->param('bib_id'); - my ( $count, $biblio ) = GetBiblio($biblionumber); + my $biblio = GetBiblio($biblionumber); return { code => 'RecordNotFound' } unless $$biblio{biblionumber}; my $title = $$biblio{title}; diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index a64a0d2781..8cfb3e6b58 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -539,7 +539,7 @@ sub BatchCommitBibRecords { } elsif ($bib_result eq 'replace') { $num_updated++; my $biblionumber = $bib_match; - my ($count, $oldbiblio) = GetBiblio($biblionumber); + my $oldbiblio = GetBiblio($biblionumber); my $oldxml = GetXmlBiblio($biblionumber); # remove item fields so that they don't get @@ -679,7 +679,7 @@ sub BatchRevertBibRecords { $num_reverted++; my $old_record = MARC::Record->new_from_xml(StripNonXmlChars($rowref->{'marcxml_old'}), 'UTF-8', $rowref->{'encoding'}); my $biblionumber = $rowref->{'matched_biblionumber'}; - my ($count, $oldbiblio) = GetBiblio($biblionumber); + my $oldbiblio = GetBiblio($biblionumber); $num_items_deleted += BatchRevertItems($rowref->{'import_record_id'}, $rowref->{'matched_biblionumber'}); ModBiblio($old_record, $biblionumber, $oldbiblio->{'frameworkcode'}); SetImportRecordStatus($rowref->{'import_record_id'}, 'reverted'); diff --git a/C4/Serials.pm b/C4/Serials.pm index 98660e9e87..e31d5dfb82 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -1303,7 +1303,7 @@ sub NewSubscription { logaction( "SERIAL", "ADD", $subscriptionid, "" ) if C4::Context->preference("SubscriptionLog"); #set serial flag on biblio if not already set. - my ( $null, ($bib) ) = GetBiblio($biblionumber); + my $bib = GetBiblio($biblionumber); if ( !$bib->{'serial'} ) { my $record = GetMarcBiblio($biblionumber); my ( $tag, $subf ) = GetMarcFromKohaField( 'biblio.serial', $bib->{'frameworkcode'} ); diff --git a/catalogue/imageviewer.pl b/catalogue/imageviewer.pl index 011dfabbb6..a5f86a5563 100755 --- a/catalogue/imageviewer.pl +++ b/catalogue/imageviewer.pl @@ -41,7 +41,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $biblionumber = $query->param('biblionumber') || $query->param('bib'); my $imagenumber = $query->param('imagenumber'); -my ( $count, $biblio ) = GetBiblio($biblionumber); +my $biblio = GetBiblio($biblionumber); my $itemcount = GetItemsCount($biblionumber); my @items = GetItemsInfo($biblionumber); diff --git a/catalogue/issuehistory.pl b/catalogue/issuehistory.pl index 288182ccd8..a5c4d0dc2f 100755 --- a/catalogue/issuehistory.pl +++ b/catalogue/issuehistory.pl @@ -61,10 +61,10 @@ if ($itemnumber){ ); } else { $issues = GetBiblioIssues($biblionumber); - my (undef,@biblio)=GetBiblio($biblionumber); + my $biblio = GetBiblio($biblionumber); my $total = scalar @$issues; $template->param( - %{$biblio[0]}, + %{$biblio}, ); } foreach (@{$issues}){ diff --git a/opac/opac-imageviewer.pl b/opac/opac-imageviewer.pl index 300e90f0e4..1870321a6e 100755 --- a/opac/opac-imageviewer.pl +++ b/opac/opac-imageviewer.pl @@ -39,7 +39,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $biblionumber = $query->param('biblionumber') || $query->param('bib'); my $imagenumber = $query->param('imagenumber'); -my ( $count, $biblio ) = GetBiblio($biblionumber); +my $biblio = GetBiblio($biblionumber); if ( C4::Context->preference("OPACLocalCoverImages") ) { my @images = ListImagesForBiblio($biblionumber); -- 2.20.1