From a96c73eb769a4796623740ee11e6c9656e5bd430 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 28 Apr 2020 18:36:49 +0000 Subject: [PATCH] Bug 25306: Remove framework paramter from ModBiblioMarc Tested with : For a framework (not the default) : Creation of a biblio record Edition of this biblio record Creation of an item of this record Creation of an item of this record ./misc/batchRepairMissingBiblionumbers.pl OK prove t/db_dependent/Biblio/ModBiblioMarc.t OK Signed-off-by: Fridolin Somers Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- C4/Biblio.pm | 14 ++++---------- C4/Items.pm | 3 --- misc/batchRepairMissingBiblionumbers.pl | 2 +- misc/migration_tools/22_to_30/missing090field.pl | 2 +- misc/migration_tools/22_to_30/rebuild_leader.pl | 2 +- .../22_to_30/rebuild_unimarc_100.pl | 2 +- misc/migration_tools/bulkmarcimport.pl | 6 +++--- misc/migration_tools/switch_marc21_series_info.pl | 2 +- t/db_dependent/Biblio/ModBiblioMarc.t | 2 +- 9 files changed, 13 insertions(+), 22 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 6e53842ee1..7a6283b5ac 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -285,7 +285,7 @@ sub AddBiblio { _koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode ); # now add the record - ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $defer_marc_save; + ModBiblioMarc( $record, $biblionumber ) unless $defer_marc_save; # update OAI-PMH sets if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) { @@ -378,7 +378,7 @@ sub ModBiblio { _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode ); # update the MARC record (that now contains biblio and items) with the new record data - &ModBiblioMarc( $record, $biblionumber, $frameworkcode ); + &ModBiblioMarc( $record, $biblionumber ); # modify the other koha tables _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode ); @@ -2982,7 +2982,7 @@ sub _koha_delete_biblio_metadata { =head2 ModBiblioMarc - &ModBiblioMarc($newrec,$biblionumber,$frameworkcode); + &ModBiblioMarc($newrec,$biblionumber); Add MARC XML data for a biblio to koha @@ -2993,7 +2993,7 @@ Function exported, but should NOT be used, unless you really know what you're do sub ModBiblioMarc { # pass the MARC::Record to this function, and it will create the records in # the marcxml field - my ( $record, $biblionumber, $frameworkcode ) = @_; + my ( $record, $biblionumber ) = @_; if ( !$record ) { carp 'ModBiblioMarc passed an undefined record'; return; @@ -3003,12 +3003,6 @@ sub ModBiblioMarc { $record = $record->clone(); my $dbh = C4::Context->dbh; my @fields = $record->fields(); - if ( !$frameworkcode ) { - $frameworkcode = ""; - } - my $sth = $dbh->prepare("UPDATE biblio SET frameworkcode=? WHERE biblionumber=?"); - $sth->execute( $frameworkcode, $biblionumber ); - $sth->finish; my $encoding = C4::Context->preference("marcflavour"); # deal with UNIMARC field 100 (encoding) : create it if needed & set encoding to unicode diff --git a/C4/Items.pm b/C4/Items.pm index fa5e8f2ba6..430ca8e477 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -276,9 +276,6 @@ sub AddItemBatchFromMarc { $record->delete_field($item_field); } - # update the MARC biblio - # $biblionumber = ModBiblioMarc( $record, $biblionumber, $frameworkcode ); - return (\@itemnumbers, \@errors); } diff --git a/misc/batchRepairMissingBiblionumbers.pl b/misc/batchRepairMissingBiblionumbers.pl index 3a7dbe5d69..69e15a6c15 100755 --- a/misc/batchRepairMissingBiblionumbers.pl +++ b/misc/batchRepairMissingBiblionumbers.pl @@ -25,7 +25,7 @@ $sth->execute(); while (my ($biblionumber,$biblioitemnumber,$frameworkcode)=$sth->fetchrow ){ my $record = GetMarcBiblio({ biblionumber => $biblionumber }); C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber); - my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber, $frameworkcode )}; + my $biblionumber = eval {ModBiblioMarc( $record, $biblionumber )}; if($@){ print "Problem with biblionumber : $biblionumber\n"; exit -1; diff --git a/misc/migration_tools/22_to_30/missing090field.pl b/misc/migration_tools/22_to_30/missing090field.pl index dd28111c69..b54bf9285d 100755 --- a/misc/migration_tools/22_to_30/missing090field.pl +++ b/misc/migration_tools/22_to_30/missing090field.pl @@ -73,7 +73,7 @@ sub MARCmodbiblionumber{ if ($update){ - &ModBiblioMarc($record,$biblionumber,''); + &ModBiblioMarc($record,$biblionumber); print "\n modified : $biblionumber \n"; } diff --git a/misc/migration_tools/22_to_30/rebuild_leader.pl b/misc/migration_tools/22_to_30/rebuild_leader.pl index ded81b3730..2d402c5bb5 100755 --- a/misc/migration_tools/22_to_30/rebuild_leader.pl +++ b/misc/migration_tools/22_to_30/rebuild_leader.pl @@ -49,7 +49,7 @@ foreach ($record->field('995')) { $record->delete_field($_); } if ($update){ - &ModBiblioMarc($record,'',$biblionumber); + &ModBiblioMarc($record,$biblionumber); print "$biblionumber \n"; } diff --git a/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl b/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl index 3b3e3cdd91..0988e5631d 100755 --- a/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl +++ b/misc/migration_tools/22_to_30/rebuild_unimarc_100.pl @@ -56,7 +56,7 @@ sub MARCmodrecord { $record->insert_fields_ordered(MARC::Field->new(100,"","","a"=>"$string")); } if ($update){ - &ModBiblioMarc($record,$biblionumber,''); + &ModBiblioMarc($record,$biblionumber); print "\r$biblionumber" unless ( $biblionumber % 100 ); } diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index 0ae54ee9c1..918d485dac 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -445,7 +445,7 @@ RECORD: while ( ) { $biblioitemnumber = Koha::Biblios->find( $biblionumber )->biblioitem->biblioitemnumber; }; if ($update) { - eval { ModBiblio( $record, $biblionumber, GetFrameworkCode($biblionumber) ) }; + eval { ModBiblio( $record, $biblionumber, $framework ) }; if ($@) { warn "ERROR: Edit biblio $biblionumber failed: $@\n"; printlog( { id => $id || $originalid || $biblionumber, op => "update", status => "ERROR" } ) if ($logfile); @@ -458,7 +458,7 @@ RECORD: while ( ) { } } else { if ($insert) { - eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '', { defer_marc_save => 1 } ) }; + eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, $framework, { defer_marc_save => 1 } ) }; if ($@) { warn "ERROR: Adding biblio $biblionumber failed: $@\n"; printlog( { id => $id || $originalid || $biblionumber, op => "insert", status => "ERROR" } ) if ($logfile); @@ -480,7 +480,7 @@ RECORD: while ( ) { C4::Biblio::_strip_item_fields($clone_record, ''); # This sets the marc fields if there was an error, and also calls # defer_marc_save. - ModBiblioMarc( $clone_record, $biblionumber, $framework ); + ModBiblioMarc( $clone_record, $biblionumber ); if ( $error_adding ) { warn "ERROR: Adding items to bib $biblionumber failed: $error_adding"; printlog({id=>$id||$originalid||$biblionumber, op=>"insertitem",status=>"ERROR"}) if ($logfile); diff --git a/misc/migration_tools/switch_marc21_series_info.pl b/misc/migration_tools/switch_marc21_series_info.pl index 925be0c8b3..9d43d47cbd 100755 --- a/misc/migration_tools/switch_marc21_series_info.pl +++ b/misc/migration_tools/switch_marc21_series_info.pl @@ -222,7 +222,7 @@ while ( my ( $biblionumber ) = $bibs_sth->fetchrow ) { else { print "."; } - ModBiblioMarc( $biblio, $biblionumber, $framework ); + ModBiblioMarc( $biblio, $biblionumber ); } print "\n"; diff --git a/t/db_dependent/Biblio/ModBiblioMarc.t b/t/db_dependent/Biblio/ModBiblioMarc.t index 94cf62d6f0..e710ffee3c 100755 --- a/t/db_dependent/Biblio/ModBiblioMarc.t +++ b/t/db_dependent/Biblio/ModBiblioMarc.t @@ -40,7 +40,7 @@ subtest "Check MARC field length calculation" => sub { ); is( $record->leader, ' 'x24, 'No leader lengths' ); - C4::Biblio::ModBiblioMarc( $record, $biblio->biblionumber, '' ); + C4::Biblio::ModBiblioMarc( $record, $biblio->biblionumber ); my $savedrec = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber }); like( substr($savedrec->leader,0,5), qr/^\d{5}$/, 'Record length found' ); like( substr($savedrec->leader,12,5), qr/^\d{5}$/, 'Base address found' ); -- 2.39.5