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)
Created attachment 139676 [details] [review] 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`
Created attachment 140877 [details] [review] 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>
Testing notes using a MARC21 instance (using koha-testing-docker): 1. I edited an existing subfield 995$z for the BKS framework, and made visible in the OPAC, staff interface, and editor 2. I also created a new subfield 995$Z for the BKS framework, and made visible in the OPAC, staff interface, and editor 3. Initially, everything worked as expected as per the test plan: not displayed in OPAC before the patch was applied. Only tested for OPAC ISBD display. 4. Then I retested again after I signed off just to check the staff interface, and it was displayed correctly without applying the patch on master (flush_memcached, restart_all, cleared browser cache - I also shut down KTD and restarted again, still the same behaviour). 5. I also added the display of the field to the staff interface (ISBD system preference). Has this been fixed some other way, or have I totally screwed up caching/my git clone/testing? Or is it UNIMARC specific?
Created attachment 141111 [details] [review] 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>
(In reply to David Nind from comment #3) > Has this been fixed some other way, or have I totally screwed up caching/my > git clone/testing? Or is it UNIMARC specific? Koha/Filter/MARC/EmbedItems.pm: push @item_fields, $item->as_marc_field( { mss => $mss } ); opac/opac-ISBDdetail.pl: { filters => [ 'EmbedItems', 'ViewPolicy' ], Use of as_marc_field is not very widespread. catalogue/ISBDdetail.pl does not use it.
Pushed to master for 22.11. Nice work everyone, thanks!
Backported to 22.05.x for upcomiong 22.05.08 release
applied to 21.11 for 21.11.15
Not backported to 21.05.x