Bug 16169: Change prototype for C4::Biblio::TransformMarcToKoha
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 30 Mar 2016 10:58:31 +0000 (11:58 +0100)
committerBrendan Gallagher <brendan@bywatersolutions.com>
Thu, 7 Apr 2016 00:04:21 +0000 (00:04 +0000)
subroutines should not take $dbh in parameter.
C4::Biblio::TransformMarcToKoha has it and does not use it.

Test plan:
Look at the patch and confirm that all occurrences of
TransformMarcToKoha have been modified.

Signed-off-by: Jacek Ablewicz <abl@biblos.pk.edu.pl>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com

17 files changed:
C4/AuthoritiesMarc.pm
C4/Biblio.pm
C4/ImportBatch.pm
C4/Items.pm
C4/Matcher.pm
C4/Search.pm
acqui/neworderbiblio.pl
cataloguing/additem.pl
cataloguing/value_builder/marc21_linking_section.pl
cataloguing/value_builder/unimarc_field_4XX.pl
circ/circulation.pl
labels/label-item-search.pl
misc/batchRebuildBiblioTables.pl
opac/opac-ISBDdetail.pl
opac/opac-MARCdetail.pl
serials/subscription-bib-search.pl
t/Biblio.t

index 43e6a53..82c53b4 100644 (file)
@@ -1555,7 +1555,7 @@ sub merge {
 #         $update=1;
 #       }#for each tag
 #     }#foreach tagfield
-#     my $authoritynumber = TransformMarcToKoha($dbh,$marcrecord,"") ;
+#     my $authoritynumber = TransformMarcToKoha($marcrecord,"") ;
 #     if ($update==1){
 #       &ModAuthority($marcrecord,$authoritynumber,GetAuthTypeCode($authoritynumber)) ;
 #     }
index 75afaa1..3e88d6d 100644 (file)
@@ -257,7 +257,7 @@ sub AddBiblio {
 
     # transform the data into koha-table style data
     SetUTF8Flag($record);
-    my $olddata = TransformMarcToKoha( $dbh, $record, $frameworkcode );
+    my $olddata = TransformMarcToKoha( $record, $frameworkcode );
     ( $biblionumber, $error ) = _koha_add_biblio( $dbh, $olddata, $frameworkcode );
     $olddata->{'biblionumber'} = $biblionumber;
     ( $biblioitemnumber, $error ) = _koha_add_biblioitem( $dbh, $olddata );
@@ -340,7 +340,7 @@ sub ModBiblio {
     _koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber, $biblioitemnumber );
 
     # load the koha-table data object
-    my $oldbiblio = TransformMarcToKoha( $dbh, $record, $frameworkcode );
+    my $oldbiblio = TransformMarcToKoha( $record, $frameworkcode );
 
     # update MARC subfield that stores biblioitems.cn_sort
     _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
@@ -2606,7 +2606,7 @@ our $inverted_field_map;
 
 =head2 TransformMarcToKoha
 
-  $result = TransformMarcToKoha( $dbh, $record, $frameworkcode )
+  $result = TransformMarcToKoha( $record, $frameworkcode )
 
 Extract data from a MARC bib record into a hashref representing
 Koha biblio, biblioitems, and items fields. 
@@ -2617,8 +2617,7 @@ hash_ref
 =cut
 
 sub TransformMarcToKoha {
-    my ( $dbh, $record, $frameworkcode, $limit_table ) = @_;
-    ## FIXME: $dbh parameter is never used inside this subroutine ???
+    my ( $record, $frameworkcode, $limit_table ) = @_;
 
     my $result = {};
     if (!defined $record) {
index 77ba9f3..1d387e1 100644 (file)
@@ -759,7 +759,7 @@ sub BatchCommitItems {
         my ( $MARCfield, $MARCsubfield ) = GetMarcFromKohaField( 'items.onloan', GetFrameworkCode($biblionumber) );
         $item_marc->field($MARCfield)->delete_subfield( code => $MARCsubfield );
 
-        my $item = TransformMarcToKoha( $dbh, $item_marc );
+        my $item = TransformMarcToKoha( $item_marc );
 
         my $duplicate_barcode = exists( $item->{'barcode'} ) && GetItemnumberFromBarcode( $item->{'barcode'} );
         my $duplicate_itemnumber = exists( $item->{'itemnumber'} );
@@ -1545,7 +1545,7 @@ sub _parse_biblio_fields {
     my ($marc_record) = @_;
 
     my $dbh = C4::Context->dbh;
-    my $bibliofields = TransformMarcToKoha($dbh, $marc_record, '');
+    my $bibliofields = TransformMarcToKoha($marc_record, '');
     return ($bibliofields->{'title'}, $bibliofields->{'author'}, $bibliofields->{'isbn'}, $bibliofields->{'issn'});
 
 }
index a0dfb29..7f9a3da 100644 (file)
@@ -251,7 +251,7 @@ sub AddItemFromMarc {
        
        my $localitemmarc=MARC::Record->new;
        $localitemmarc->append_fields($source_item_marc->field($itemtag));
-    my $item = &TransformMarcToKoha( $dbh, $localitemmarc, $frameworkcode ,'items');
+    my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode ,'items');
     my $unlinked_item_subfields = _get_unlinked_item_subfields($localitemmarc, $frameworkcode);
     return AddItem($item, $biblionumber, $dbh, $frameworkcode, $unlinked_item_subfields);
 }
@@ -383,7 +383,7 @@ sub AddItemBatchFromMarc {
         $temp_item_marc->append_fields($item_field);
     
         # add biblionumber and biblioitemnumber
-        my $item = TransformMarcToKoha( $dbh, $temp_item_marc, $frameworkcode, 'items' );
+        my $item = TransformMarcToKoha( $temp_item_marc, $frameworkcode, 'items' );
         my $unlinked_item_subfields = _get_unlinked_item_subfields($temp_item_marc, $frameworkcode);
         $item->{'more_subfields_xml'} = _get_unlinked_subfields_xml($unlinked_item_subfields);
         $item->{'biblionumber'} = $biblionumber;
@@ -507,7 +507,7 @@ sub ModItemFromMarc {
 
     my $localitemmarc = MARC::Record->new;
     $localitemmarc->append_fields( $item_marc->field($itemtag) );
-    my $item = &TransformMarcToKoha( $dbh, $localitemmarc, $frameworkcode, 'items' );
+    my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
     my $default_values = _build_default_values_for_mod_marc();
     foreach my $item_field ( keys %$default_values ) {
         $item->{$item_field} = $default_values->{$item_field}
index 9e04758..7d91cf2 100644 (file)
@@ -708,7 +708,7 @@ sub get_matches {
         foreach my $marcblob (keys %matches) {
             my $target_record = C4::Search::new_record_from_zebra('biblioserver',$marcblob);
             my $record_number;
-            my $result = C4::Biblio::TransformMarcToKoha(C4::Context->dbh, $target_record, '');
+            my $result = C4::Biblio::TransformMarcToKoha($target_record, '');
             $record_number = $result->{'biblionumber'};
             push @results, { 'record_id' => $record_number, 'score' => $matches{$marcblob} };
         }
index 9b7bde3..2139c5a 100644 (file)
@@ -83,7 +83,7 @@ This function attempts to find duplicate records using a hard-coded, fairly simp
 sub FindDuplicate {
     my ($record) = @_;
     my $dbh = C4::Context->dbh;
-    my $result = TransformMarcToKoha( $dbh, $record, '' );
+    my $result = TransformMarcToKoha( $record, '' );
     my $sth;
     my $query;
     my $search;
@@ -145,7 +145,7 @@ sub FindDuplicate {
                 $possible_duplicate_record
             );
 
-            my $result = TransformMarcToKoha( $dbh, $marcrecord, '' );
+            my $result = TransformMarcToKoha( $marcrecord, '' );
 
             # FIXME :: why 2 $biblionumber ?
             if ($result) {
@@ -201,7 +201,7 @@ my @results;
 
 for my $r ( @{$marcresults} ) {
     my $marcrecord = MARC::File::USMARC::decode($r);
-    my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,q{});
+    my $biblio = TransformMarcToKoha($marcrecord,q{});
 
     #build the iarray of hashs for the template.
     push @results, {
@@ -1889,7 +1889,7 @@ sub searchResults {
                : GetFrameworkCode($marcrecord->subfield($bibliotag,$bibliosubf));
 
         SetUTF8Flag($marcrecord);
-        my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, $fw );
+        my $oldbiblio = TransformMarcToKoha( $marcrecord, $fw );
         $oldbiblio->{subtitle} = GetRecordValue('subtitle', $marcrecord, $fw);
         $oldbiblio->{result_number} = $i + 1;
 
index 4269fe6..4bd0827 100755 (executable)
@@ -122,7 +122,7 @@ my @results;
 
 foreach my $result ( @{$marcresults} ) {
     my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $result );
-    my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
+    my $biblio = TransformMarcToKoha( $marcrecord, '' );
 
     $biblio->{booksellerid} = $booksellerid;
     push @results, $biblio;
index b9672c2..eb52415 100755 (executable)
@@ -404,7 +404,7 @@ $restrictededition = 0 if ($restrictededition != 0 && $frameworkcode eq 'FA' &&
 
 my $tagslib = &GetMarcStructure(1,$frameworkcode);
 my $record = GetMarcBiblio($biblionumber);
-my $oldrecord = TransformMarcToKoha($dbh,$record);
+my $oldrecord = TransformMarcToKoha($record);
 my $itemrecord;
 my $nextop="additem";
 my @errors; # store errors found while checking data BEFORE saving item.
@@ -457,7 +457,7 @@ if ($op eq "additem") {
         $record = _increment_barcode($record, $frameworkcode);
     }
 
-    my $addedolditem = TransformMarcToKoha( $dbh, $record );
+    my $addedolditem = TransformMarcToKoha( $record );
 
     # If we have to add or add & duplicate, we add the item
     if ( $add_submit || $add_duplicate_submit ) {
@@ -683,7 +683,7 @@ if ($op eq "additem") {
     # MARC::Record builded => now, record in DB
     # warn "R: ".$record->as_formatted;
     # check that the barcode don't exist already
-    my $addedolditem = TransformMarcToKoha($dbh,$itemtosave);
+    my $addedolditem = TransformMarcToKoha($itemtosave);
     my $exist_itemnumber = get_item_from_barcode($addedolditem->{'barcode'});
     if ($exist_itemnumber && $exist_itemnumber != $itemnumber) {
         push @errors,"barcode_not_unique";
index b32474c..61e21c7 100755 (executable)
@@ -208,7 +208,7 @@ my $launcher = sub {
         my @field_data = ($search);
         for ( my $i = 0 ; $i < $resultsperpage ; $i++ ) {
             my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] );
-            my $rechash = TransformMarcToKoha( $dbh, $record );
+            my $rechash = TransformMarcToKoha( $record );
             my $pos;
             my $countitems = $rechash->{itembumber} ? 1 : 0;
             while ( index( $rechash->{itemnumber}, '|', $pos ) > 0 ) {
index 092b0f1..f14a616 100755 (executable)
@@ -397,7 +397,7 @@ sub plugin {
          {
             my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] );
             next unless $record;
-            my $rechash = TransformMarcToKoha( $dbh, $record );
+            my $rechash = TransformMarcToKoha( $record );
             if ( my $f = $record->field('200') ) {
                 $rechash->{fulltitle} =
                     join(', ', map { $_->[1] } grep { $_->[0] =~ /[aehi]/ } $f->subfields() );
index 2bda49b..3a57685 100755 (executable)
@@ -361,8 +361,7 @@ if (@$barcodes) {
             my @options = ();
             foreach my $hit ( @{$results} ) {
                 my $chosen =
-                  TransformMarcToKoha( C4::Context->dbh,
-                    C4::Search::new_record_from_zebra('biblioserver',$hit) );
+                  TransformMarcToKoha( C4::Search::new_record_from_zebra('biblioserver',$hit) );
 
                 # offer all barcodes individually
                 if ( $chosen->{barcode} ) {
index d1500a4..c2d218a 100755 (executable)
@@ -132,7 +132,7 @@ if ($show_results) {
         #DEBUG Notes: Decode the MARC record from each resulting MARC record...
         my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $marcresults->[$i] );
         #DEBUG Notes: Transform it to Koha form...
-        my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
+        my $biblio = TransformMarcToKoha( $marcrecord, '' );
         #DEBUG Notes: Stuff the bib into @biblio_data...
         push (@results_set, $biblio);
         my $biblionumber = $biblio->{'biblionumber'};
index 59185fd..dc4175c 100755 (executable)
@@ -96,7 +96,7 @@ if (scalar(@errors) > 0) {
 sub localNEWmodbiblio {
     my ($dbh,$record,$biblionumber,$frameworkcode) =@_;
     $frameworkcode="" unless $frameworkcode;
-    my $oldbiblio = TransformMarcToKoha($dbh,$record,$frameworkcode);
+    my $oldbiblio = TransformMarcToKoha($record,$frameworkcode);
     C4::Biblio::_koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
     C4::Biblio::_koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
     return 1;
index 7fb1073..49d7ce7 100755 (executable)
@@ -119,7 +119,7 @@ $template->param(
 #coping with subscriptions
 my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
 my $dbh = C4::Context->dbh;
-my $dat                 = TransformMarcToKoha( $dbh, $record );
+my $dat                 = TransformMarcToKoha( $record );
 
 my @subscriptions       = SearchSubscriptions({ biblionumber => $biblionumber, orderby => 'title' });
 my @subs;
index 79b92a8..83e97b8 100755 (executable)
@@ -306,7 +306,7 @@ if(C4::Context->preference("ISBD")) {
 
 #Search for title in links
 my $marcflavour  = C4::Context->preference("marcflavour");
-my $dat = TransformMarcToKoha( $dbh, $record );
+my $dat = TransformMarcToKoha( $record );
 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
 my $marccontrolnumber   = GetMarcControlnumber ($record, $marcflavour);
 my $marcissns = GetMarcISSN( $record, $marcflavour );
index a74afb0..09530ca 100755 (executable)
@@ -114,7 +114,7 @@ if ( $op eq "do_search" && $query ) {
     for ( my $i = 0 ; $i < $total ; $i++ ) {
         my %resultsloop;
         my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $marcrecords->[$i] );
-        my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
+        my $biblio = TransformMarcToKoha( $marcrecord, '' );
 
         #build the hash for the template.
         $resultsloop{highlight}       = ( $i % 2 ) ? (1) : (0);
index 0e709af..1cec33b 100755 (executable)
@@ -162,7 +162,7 @@ ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
 
 my $hash_ref;
 
-warning_is { $hash_ref = TransformMarcToKoha(undef, undef) }
+warning_is { $hash_ref = TransformMarcToKoha( undef) }
            { carped => 'TransformMarcToKoha called with undefined record'},
            "TransformMarcToKoha returns carped warning on undef record";