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)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 3 Oct 2022 11:40:01 +0000 (08:40 -0300)
commit389b9dfaf43e889612990401ab83cc1f75972333
tree1e4506b4294d85e999c39e0e79af4b113a56fc36
parent4c3d18091d821af2d9ac7a6178547cc9c478f9de
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>
Koha/Item.pm
t/db_dependent/Koha/Item.t