Bug 32160

Summary: Batch record modification - show MARC preview no longer works
Product: Koha Reporter: David Nind <david>
Component: CatalogingAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: m.de.rooy, mvsreedharan, phil
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description David Nind 2022-11-10 01:44:10 UTC
When clicking on the 'Show MARC' action from the list of records to be modified using Cataloguing > Batch record modification, it shows as 'Loading' and does not complete the display of the modified MARC record.

In the web developer tools an error is displayed:

14:24:26.131 XHR GET http://127.0.0.1:8081/cgi-bin/koha/svc/records/preview?record_type=biblio&record_id=262&mmtid=3&overlay_context=batchmod
[HTTP/1.1 500 Internal Server Error 87ms]

To replicate using koha-testing-docker (KTD):
1. Add a MARC modification template (Cataloguing > MARC modification templates > New template > give it a name and click submit > add a 'New action" (for example: Add new 500$a with value 'OK')).
2. Modify a batch of records (Cataloguing > Batch record modification):
   - For 'Enter a list of record numbers' enter 17 and 262 (sample data for KTD)
   - Choose the template you created in step 1
   - Press Continue
3. Enable the web developer tools console.
3. From the results list, click on 'Show MARC'.
4. On the modal window, note that the spinner says 'Loading', and doesn't complete the display of the MARC.
5. Note that in the web developer tools console there is an error:
   14:24:26.131 XHR GET http://127.0.0.1:8081/cgi-bin/koha/svc/records/preview?record_type=biblio&record_id=262&mmtid=3&overlay_context=batchmod
[HTTP/1.1 500 Internal Server Error 87ms]
Comment 1 Katrin Fischer 2022-11-17 09:13:24 UTC
It looks to me like the problem might be that we are trying to use the templates on the record we view there (preview of changes) and that this failes.

My action was a simple "delete field xxx"

Can't call method "field" on an undefined value at /kohadevbox/koha/Koha/SimpleMARC.pm line 534
	Koha::SimpleMARC::_delete_field('HASH(0x560470731670)') called at /kohadevbox/koha/Koha/SimpleMARC.pm line 522
	Koha::SimpleMARC::delete_field('HASH(0x56046fff90a8)') called at /kohadevbox/koha/C4/MarcModificationTemplates.pm line 630
	C4::MarcModificationTemplates::ModifyRecordWithTemplate(1, undef) called at /kohadevbox/koha/svc/records/preview line 53
	eval {...} at /kohadevbox/koha/svc/records/preview line 2
Comment 2 Sreedharan M V 2023-03-30 07:46:47 UTC
Batch record modification is not working in koha 22.05.07
Comment 3 Phil Ringnalda 2024-04-05 19:13:20 UTC
Broken by bug 29697, fixed by bug 32631

*** This bug has been marked as a duplicate of bug 32631 ***