[Koha-bugs] [Bug 25539] Remove AddBiblio "defer_marc_save" option

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Sep 16 14:12:57 CEST 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=25539

--- Comment #10 from David Gustafsson <glasklas at gmail.com> ---
I had a look at this, and I think this is a bit of a mess to sort out. You are
calling bulkmarcimport.pl without -update or -insert set, which seems to
default to -insert ($insert = 1, $update = undef), and without -match with a
matchpoint.

bulkmarcimport will correctly get original id through:

$originalid = GetRecordId( $record, $tagid, $subfieldid );

But will not use $originalid as a match ($biblionumber will have no value on
line 453 where record is either inserted or updated). Because of this and
$update = undef the block inside of if ($insert) {... on line 470 will run
inserting a new record with defer_marc_save => 1. After this block:

eval { ( $itemnumbers_ref, $errors_ref ) = AddItemBatchFromMarc( $record,
$biblionumber, $biblioitemnumber, '' ); };

Will be run with a $biblionumber set to a biblio without any marc data yet
saved.

Inside of AddItemBatchFromMarc

my $item_object = Koha::Item->new($item)->store;

will be run.

Inside Koha/Item.pm Koha::Item::store this will get executed:

C4::Biblio::ModZebra( $self->biblionumber, "specialUpdate", "biblioserver" )
            unless $params->{skip_modzebra_update}

ModZebra will attempt to load the Biblio Marc data:

$record = GetMarcBiblio({
    biblionumber => $biblionumber,
    embed_items  => 1 });

But this will return an undefined record since the marc-data has not yet been
saved.

This will cause the import in later processing of this undefined $record to
crash which will not propagate to bulkmarcimport.pl since run within an eval.

I get this when running bulkmarcimport without the patch. The new record marc
data is later saved in the following block which comes shortly after:

   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 );

which I removed in the patch (was not aware that the marc data was loaded as a
side effect of AddItemBarchFromMarc).

This code needs to be removed somehow though since it will bypass the marc
merge rules in bug 14957.

I think by removing this block a new bug is exposed which is that AddBiblio
will not strip items before saving. Perhaps this could be addressed by
stripping items before calling AddBiblio in bulkmarcimport.pl. I will look
further into this.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list