From da21a6f627cb5ec657aeb0087bd8f0ff35bfb70d 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. Signed-off-by: Martin Renvoize --- 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 97fa95aeb1..051589d41f 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -180,15 +180,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 @@ -196,14 +188,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 ); @@ -225,7 +213,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")) { @@ -272,8 +260,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 22ac2de12c..37b72251be 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -275,9 +275,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 6e9ea0b3ad..2aaa8f98c0 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -287,7 +287,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); @@ -396,7 +396,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) }; @@ -468,7 +468,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); @@ -484,17 +484,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; } @@ -534,9 +527,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); @@ -585,7 +575,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