From c564f30155cac18cf6b7b26a549303f65e9e33a3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 30 Mar 2016 11:58:31 +0100 Subject: [PATCH] Bug 16169: Change prototype for C4::Biblio::TransformMarcToKoha 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 Signed-off-by: Katrin Fischer Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com --- C4/AuthoritiesMarc.pm | 2 +- C4/Biblio.pm | 9 ++++----- C4/ImportBatch.pm | 4 ++-- C4/Items.pm | 6 +++--- C4/Matcher.pm | 2 +- C4/Search.pm | 8 ++++---- acqui/neworderbiblio.pl | 2 +- cataloguing/additem.pl | 6 +++--- cataloguing/value_builder/marc21_linking_section.pl | 2 +- cataloguing/value_builder/unimarc_field_4XX.pl | 2 +- circ/circulation.pl | 3 +-- labels/label-item-search.pl | 2 +- misc/batchRebuildBiblioTables.pl | 2 +- opac/opac-ISBDdetail.pl | 2 +- opac/opac-MARCdetail.pl | 2 +- serials/subscription-bib-search.pl | 2 +- t/Biblio.t | 2 +- 17 files changed, 28 insertions(+), 30 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 43e6a531ca..82c53b478a 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -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)) ; # } diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 75afaa1d34..3e88d6d4d3 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -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) { diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 77ba9f3c08..1d387e138b 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -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'}); } diff --git a/C4/Items.pm b/C4/Items.pm index a0dfb299e2..7f9a3da35c 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -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} diff --git a/C4/Matcher.pm b/C4/Matcher.pm index 9e04758bf7..7d91cf29ea 100644 --- a/C4/Matcher.pm +++ b/C4/Matcher.pm @@ -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} }; } diff --git a/C4/Search.pm b/C4/Search.pm index 9b7bde3b5f..2139c5a826 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -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; diff --git a/acqui/neworderbiblio.pl b/acqui/neworderbiblio.pl index 4269fe6d91..4bd0827ba0 100755 --- a/acqui/neworderbiblio.pl +++ b/acqui/neworderbiblio.pl @@ -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; diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index b9672c2391..eb52415ee9 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -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"; diff --git a/cataloguing/value_builder/marc21_linking_section.pl b/cataloguing/value_builder/marc21_linking_section.pl index b32474c0e6..61e21c7cc9 100755 --- a/cataloguing/value_builder/marc21_linking_section.pl +++ b/cataloguing/value_builder/marc21_linking_section.pl @@ -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 ) { diff --git a/cataloguing/value_builder/unimarc_field_4XX.pl b/cataloguing/value_builder/unimarc_field_4XX.pl index 092b0f1d90..f14a616a85 100755 --- a/cataloguing/value_builder/unimarc_field_4XX.pl +++ b/cataloguing/value_builder/unimarc_field_4XX.pl @@ -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() ); diff --git a/circ/circulation.pl b/circ/circulation.pl index 2bda49b16b..3a57685e93 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -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} ) { diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl index d1500a4ac1..c2d218a262 100755 --- a/labels/label-item-search.pl +++ b/labels/label-item-search.pl @@ -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'}; diff --git a/misc/batchRebuildBiblioTables.pl b/misc/batchRebuildBiblioTables.pl index 59185fd926..dc4175c61f 100755 --- a/misc/batchRebuildBiblioTables.pl +++ b/misc/batchRebuildBiblioTables.pl @@ -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; diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl index 7fb1073abe..49d7ce7657 100755 --- a/opac/opac-ISBDdetail.pl +++ b/opac/opac-ISBDdetail.pl @@ -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; diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index 79b92a8eb0..83e97b8ab2 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -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 ); diff --git a/serials/subscription-bib-search.pl b/serials/subscription-bib-search.pl index a74afb0891..09530ca414 100755 --- a/serials/subscription-bib-search.pl +++ b/serials/subscription-bib-search.pl @@ -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); diff --git a/t/Biblio.t b/t/Biblio.t index 0e709af234..1cec33be51 100755 --- a/t/Biblio.t +++ b/t/Biblio.t @@ -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"; -- 2.39.5