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
# $update=1;
# }#for each tag
# }#foreach tagfield
-# my $authoritynumber = TransformMarcToKoha($dbh,$marcrecord,"") ;
+# my $authoritynumber = TransformMarcToKoha($marcrecord,"") ;
# if ($update==1){
# &ModAuthority($marcrecord,$authoritynumber,GetAuthTypeCode($authoritynumber)) ;
# }
# 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 );
_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 );
=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.
=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) {
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'} );
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'});
}
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);
}
$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;
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}
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} };
}
sub FindDuplicate {
my ($record) = @_;
my $dbh = C4::Context->dbh;
- my $result = TransformMarcToKoha( $dbh, $record, '' );
+ my $result = TransformMarcToKoha( $record, '' );
my $sth;
my $query;
my $search;
$possible_duplicate_record
);
- my $result = TransformMarcToKoha( $dbh, $marcrecord, '' );
+ my $result = TransformMarcToKoha( $marcrecord, '' );
# FIXME :: why 2 $biblionumber ?
if ($result) {
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, {
: 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;
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;
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.
$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 ) {
# 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";
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 ) {
{
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() );
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} ) {
#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'};
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;
#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;
#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 );
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);
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";