[Koha-bugs] [Bug 30996] ModBiblio breaks MARC::File::XML

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Jun 27 04:05:02 CEST 2022


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

David Cook <dcook at prosentient.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dcook at prosentient.com.au

--- Comment #2 from David Cook <dcook at prosentient.com.au> ---
(In reply to Magnus Enger from comment #0)
> Anyone got a hunch what might be causing this, or where to start looking for
> a solution?

I love a good encoding problem...

It looks like MARC::File::XML is rewriting that position 9 to " " from "a"
based on this code in MARC::File::XML::decode():

    if (@leaders) {
        my $leader = $leaders[0]->textContent;

        # this bit is rather questionable
        $transcode_to_marc8 = substr($leader, 9, 1) eq 'a' &&
decideMARC8Binary($format, $enc) ? 1 : 0;
        substr($leader, 9, 1) = ' ' if $transcode_to_marc8;

        $rec->leader($leader);
    }

But since you're setting BinaryEncoding to utf8, it shouldn't be doing that
"questionable" rewrite. 

And like you say... it seems to work fine when you don't use ModBiblio... 

--

MARC::File::XML::decideMARC8Binary() uses a /o regex modifier which is heavily
warned against. But I don't see how that would cause a problem here...

--

It looks like C4::Biblio::GetMarcBiblio (called by ModBiblio) runs the
following:

MARC::File::XML->default_record_format( C4::Context->preference('marcflavour')
);

That does interfere with MARC::File::XML's internal $_load_args data structure,
but... that should be OK since RecordFormat should be MARC21 either way. Plus
what we're really worried about is the "BinaryEncoding" anyway. 

--

MARC::Record::new_from_xml does call MARC::File::XML::decode...

In GetMarcBiblio, we run the following:

1221             MARC::Record::new_from_xml( $marcxml, "UTF-8",
1222                 C4::Context->preference('marcflavour') );
1223         };

But that shouldn't reset anything in MARC::File::XML...

--

I think the only option really is to add debugging code to MARC::File::XML and
C4::Biblio to try to unpick what is happening, unfortunately.

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