From f4219ec3b0a452fbe517e3f231b9cc0e86cff211 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@biblibre.com>
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 <kyle@bywatersolutions.com>
---
 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 c479502..4c5da0e 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 4eed936..6893e70 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;
     }
@@ -597,7 +597,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};
@@ -662,7 +662,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 a64a0d2..8cfb3e6 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 98660e9..e31d5df 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 011dfab..a5f86a5 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 288182c..7a376d9 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 300e90f..1870321 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);
-- 
1.7.2.5