Bug 31441: Fix Koha::Item::as_marc_field when kohafield = ''
authorJulian Maurice <julian.maurice@biblibre.com>
Tue, 23 Aug 2022 11:47:56 +0000 (13:47 +0200)
committerLucas Gass <lucas@bywatersolutions.com>
Mon, 5 Dec 2022 15:37:34 +0000 (15:37 +0000)
commit272510faf747a0d7da49b3c5ae3b491fc83ba36d
tree6437cba6ce673c50cbf7becca290b2ef28bb1f8a
parent6e3ff69730ec269973cc5225a99e5ce7123f05f7
Bug 31441: Fix Koha::Item::as_marc_field when kohafield = ''

marc_subfield_structure.kohafield can be NULL, but it can also be an
empty string. But in that case, Koha::Item::as_marc_field ignores them,
which means the resulting MARC::Field object has missing data.
This can produce a bug in OPAC ISBD view (and probably other places
where this method is used)

Test plan:
1. Edit the default biblio MARC framework for the item field: find or
   create a subfield that is not linked to a DB column.
   Save even if you made no changes to make sure that
   marc_subfield_structure.kohafield is set to an empty string.
   I'll use 995$Z as an example for the following steps.
2. Add the following to syspref OPACISBD:
    #995|<br>Item:|{995Z}|
3. Create a biblio with an item and put a value into 995$Z
4. Go to the ISBD detail page for this record at OPAC. Confirm that the
   value you entered in 995$Z is not visible
5. Apply patch and restart koha
6. Refresh the ISBD detail page. Confirm that the 995$Z is now visible.
7. Run `prove t/db_dependent/Koha/Item.t`

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 389b9dfaf43e889612990401ab83cc1f75972333)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Koha/Item.pm
t/db_dependent/Koha/Item.t