[Koha-bugs] [Bug 32332] bulkmarcimport.pl -insert fails to add MARC field 999

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Nov 23 15:46:19 CET 2022


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

--- Comment #2 from Magnus Enger <magnus at libriotech.no> ---
Done some more digging, and I think I found the problem. The POD for
bulkmarcimport.pl reads:

    -insert
        if set, only insert when possible

    -update
        if set, only updates (any biblio should have a matching record)

    -all
        if set, do whatever is required

The way I interpret this, if -insert is provided, records that are not present
in the database (based on the matching provided by -match) should be inserted,
and records that are already present should be skipped and not updated. 

If the script is run with -match and -insert, it will look for an existing
record. If one is found, then the following logic happens: 

            if ($biblionumber) {
                eval{
                    $biblioitemnumber = Koha::Biblios->find( $biblionumber
)->biblioitem->biblioitemnumber;
                };
                if ($update) {
                    # If run with -update, but this is not what we are looking
for
                } else {
                    # If run with -insert, nothing happens, except some logging
                    printlog( { id => $id || $originalid || $biblionumber, op
=> "insert", status => "warning : already in database" } ) if ($logfile);
                }
            } else {
                # An existing record was not found
            }

This looks OK, nothing happens if there is a match and -insert is provided. But
then, further down in the script, ModBiblioMarc gets run for all records:

            ModBiblioMarc( $clone_record, $biblionumber );

This updates biblio_metadata.metadata, even if we did not want to update
records that have a match! To check this behviour, run the "bulkmarcimport.pl
-import" command I gave in the first comment, then log into the database and
run this: 

MariaDB [koha_kohadev]> select timestamp from biblio_metadata where
biblionumber = 439;

(Replace 439 with the biblionumber you got, if you got another biblionumber.)

Then run "bulkmarcimport.pl -import" again and check the timestamp again. It
will be different from the first timestamp. 

This could have worked (sort of), if the 999 field was added in ModBiblioMarc,
but since bug 29486 that has not been the case. 

I think the solution here is to not run ModBiblioMarc for records that have a
match, when run with -insert?

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


More information about the Koha-bugs mailing list