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

--- Comment #22 from Martin Renvoize (ashimema) 
<[email protected]> ---
Created attachment 201744
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201744&action=edit
Bug 22439: (QA follow-up) Guard linkitem.pl and fix get_marc_host fallback

cataloguing/linkitem.pl was missing the "if $field" guard that was added
to cataloguing/addbiblio.pl in the original patch. generate_marc_host_field
can return undef when marcflavour is neither MARC21 nor UNIMARC, and
MARC::Record::append_fields(undef) dies, so the two callers should behave
consistently.

Separately, generate_marc_host_field can now populate both the standard
773/461 $w control-number subfield (gated by UseControlNumber) and the
Koha-internal $0/$9/$o subfields (gated by EasyAnalyticalRecords) on the
same field. Koha::Biblio::get_marc_host, which resolves a child record's
host from that field, only fell back to $0/$9 when $w was completely
absent. If $w was present but its search-engine based control-number
lookup failed to resolve to exactly one record (for example, the host
hasn't been reindexed yet), resolution would give up entirely even though
$0/$9 were available for a direct, reliable lookup. get_marc_host now also
falls back to $0/$9 when the $w-based search doesn't resolve. The
duplicated $0/$9 resolution logic is extracted into a new private method,
_get_marc_host_bibnumber_from_easy_analytics, used in both fallback sites,
which also fixes a latent bug where it would die if the item referenced by
$9 had since been deleted.

Also adds test coverage for the previous QA follow-up patch to
Koha/REST/V1/Items.pm (add_to_bundle), which had none.

Test plan:
1. prove t/db_dependent/Koha/Biblio.t
2. prove t/db_dependent/Koha/Biblio/host_record.t
3. prove t/db_dependent/api/v1/items/bundled_items.t

Signed-off-by: Martin Renvoize <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to