From 0c71b08363b5533de4fa0da2bb0ddc3c7d5f3dbe Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Tue, 19 May 2020 11:59:59 +0200 Subject: [PATCH] Bug 25539: Remove AddBiblio option "defer_marc_save" Items are no longer embedded in the MARCXML and because of this the MARC data does not need to be saved once more after changing record items data. The "defer_marc_save" is no longer needed since bulkmarcimport.pl was the only place this option was utilized in order to resave MARC data after possibly changing items data. --- C4/Biblio.pm | 20 ++++---------------- C4/Items.pm | 3 --- misc/migration_tools/bulkmarcimport.pl | 20 +++++--------------- 3 files changed, 9 insertions(+), 34 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 9eb3696a54..b16b71bf10 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -181,15 +181,7 @@ bib to add, while the second argument is the desired MARC framework code. This function also accepts a third, optional argument: a hashref -to additional options. The only defined option is C, -which if present and mapped to a true value, causes C -to omit the call to save the MARC in C -This option is provided B -for the use of scripts such as C that may need -to do some manipulation of the MARC record for item parsing before -saving it and which cannot afford the performance hit of saving -the MARC record twice. Consequently, do not use that option -unless you can guarantee that C will be called. +to additional options. =cut @@ -197,14 +189,10 @@ sub AddBiblio { my $record = shift; my $frameworkcode = shift; my $options = @_ ? shift : undef; - my $defer_marc_save = 0; if (!$record) { carp('AddBiblio called with undefined record'); return; } - if ( defined $options and exists $options->{'defer_marc_save'} and $options->{'defer_marc_save'} ) { - $defer_marc_save = 1; - } if (C4::Context->preference('BiblioAddsAuthorities')) { BiblioAutoLink( $record, $frameworkcode ); @@ -226,7 +214,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, $frameworkcode ); # update OAI-PMH sets if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) { @@ -273,8 +261,8 @@ sub ModBiblio { } if ( C4::Context->preference("CataloguingLog") ) { - my $newrecord = GetMarcBiblio({ biblionumber => $biblionumber }); - logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $newrecord->as_formatted ); + my $oldrecord = GetMarcBiblio({ biblionumber => $biblionumber }); + logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $oldrecord->as_formatted ); } if ( !$disable_autolink && C4::Context->preference('BiblioAddsAuthorities') ) { diff --git a/C4/Items.pm b/C4/Items.pm index a162ac5dec..aefacc6a31 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/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index 6ab4b3fcf4..15a6e89e35 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -286,7 +286,7 @@ RECORD: while ( ) { ($record, $guessed_charset, $charset_errors) = MarcToUTF8Record($record, $marcFlavour.(($authorities and $marcFlavour ne "MARC21")?'AUTH':'')); if ($guessed_charset eq 'failed') { warn "ERROR: failed to perform character conversion for record $i\n"; - next RECORD; + next RECORD; } } SetUTF8Flag($record); @@ -395,7 +395,7 @@ RECORD: while ( ) { else{ printlog({id=>$originalid||$id||$authid, op=>"edit",status=>"ok"}) if ($logfile); } - } + } elsif (defined $authid) { ## An authid is defined but no authority in database : add eval { ( $authid ) = AddAuthority($record,$authid, $authtypecode) }; @@ -467,7 +467,7 @@ RECORD: while ( ) { } } else { if ($insert) { - eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '', { defer_marc_save => 1 } ) }; + eval { ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '') }; if ($@) { warn "ERROR: Adding biblio $biblionumber failed: $@\n"; printlog( { id => $id || $originalid || $biblionumber, op => "insert", status => "ERROR" } ) if ($logfile); @@ -483,17 +483,10 @@ RECORD: while ( ) { } eval { ( $itemnumbers_ref, $errors_ref ) = AddItemBatchFromMarc( $record, $biblionumber, $biblioitemnumber, '' ); }; my $error_adding = $@; - # Work on a clone so that if there are real errors, we can maybe - # fix them up later. - my $clone_record = $record->clone(); - 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 ); if ( $error_adding ) { warn "ERROR: Adding items to bib $biblionumber failed: $error_adding"; printlog({id=>$id||$originalid||$biblionumber, op=>"insertitem",status=>"ERROR"}) if ($logfile); - # if we failed because of an exception, assume that + # if we failed because of an exception, assume that # the MARC columns in biblioitems were not set. next RECORD; } @@ -533,9 +526,6 @@ RECORD: while ( ) { if ( $@ ) { warn "ERROR: Adding items to bib $biblionumber failed: $@\n"; printlog({id=>$id||$originalid||$biblionumber, op=>"insertitem",status=>"ERROR"}) if ($logfile); - # if we failed because of an exception, assume that - # the MARC columns in biblioitems were not set. - ModBiblioMarc( $record, $biblionumber, $framework ); next RECORD; } else { printlog({id=>$id||$originalid||$biblionumber, op=>"insertitem",status=>"ok"}) if ($logfile); @@ -584,7 +574,7 @@ sub GetRecordId{ my $id; if ($tag lt "010"){ return $marcrecord->field($tag)->data() if $marcrecord->field($tag); - } + } elsif ($subfield){ if ($marcrecord->field($tag)){ return $marcrecord->subfield($tag,$subfield); -- 2.20.1