Bug 37947

Summary: Import from Z39.50 doesn't open the record in editor
Product: Koha Reporter: Caroline Cyr La Rose <caroline.cyr-la-rose>
Component: CatalogingAssignee: Jonathan Druart <jonathan.druart>
Status: Pushed to oldstable --- QA Contact: Marcel de Rooy <m.de.rooy>
Severity: major    
Priority: P5 - low CC: david, ddaghita, ephetteplace, isabel.pineda, jonathan.druart, lucas, m.de.rooy, mnero, phil, quersumme
Version: MainKeywords: regression
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.05
Circulation function:
Bug Depends on: 37429    
Bug Blocks: 38076, 38211, 37946    
Attachments: Bug 37947: (bug 37429 follow-up) Fix addbiblio and frameworkcode="Default"
Bug 37947: (bug 37429 follow-up) Fix addbiblio and frameworkcode="Default"
Bug 37947: (bug 37429 follow-up) Fix addbiblio and frameworkcode="Default"

Description Caroline Cyr La Rose 2024-09-17 16:50:52 UTC
When importing a record from Z39.50, normally choosing "Import" opens the record in the basic editor. However, the record is not opening.

To recreate:
1. Go to Cataloging
2. Click on New from Z39.50/SRU
3. Make a search in the library of congress server for anything (I searched for author: shakespeare)
4. Click on one of the results and choose Import
   --> The basic editor appears, but not the record

I tried this in KTD as well as a sandbox with the same result. I tried different records (all from LOC and all with author: shakespeare) but they all do the same thing.
Comment 1 David Nind 2024-09-17 19:41:55 UTC
I can confirm that this is happening. KTD with main.
Comment 2 Phil Ringnalda 2024-09-17 19:52:01 UTC
Workaround (assuming you aren't currently trying to document New from Z39.50/SRU ;)): Cataloging - New record - Z39.50/SRU search

Workaround #2: when you are faced with the empty page with no editor, delete the word Default from the URL in &frameworkcode=Default since the code for the default framework is "", not "Default".

We were passing "Default" to z3950_search.pl and getting "" in the addbiblio.pl URL back when New from Z39.50/SRU used to work, so apparently someone got rid of something that did s/Default// somewhere along the line.
Comment 4 Phil Ringnalda 2024-09-19 02:11:24 UTC
bisect says 8aced236e9 from bug 37429 (which I wanted to blame, but couldn't see any reason why it would break this).
Comment 5 Jonathan Druart 2024-09-19 07:17:36 UTC
Created attachment 171709 [details] [review]
Bug 37947: (bug 37429 follow-up) Fix addbiblio and frameworkcode="Default"

On bug 37429 we reordered the global var to assign them before anything
else. The logic is correct except for $frameworkcode, we want to do some
processings (like defaulting to "" if eq "Default") BEFORE we retrieve
the MARC structure ($tagslib, $usedTagsLib).

This patch also moved this code after get_template_and_user (and so
authentication), like it should be everywhere.

Test plan:
1. Go to Cataloging
2. Click on New from Z39.50/SRU
3. Make a search in the library of congress server for anything (Caroline searched for author: shakespeare)
4. Click on one of the results and choose Import
Without this patch the basic editor appears, but not the record
With this patch applied the bug is fixed and you can edit the record
Comment 6 David Nind 2024-09-19 08:39:21 UTC
Created attachment 171711 [details] [review]
Bug 37947: (bug 37429 follow-up) Fix addbiblio and frameworkcode="Default"

On bug 37429 we reordered the global var to assign them before anything
else. The logic is correct except for $frameworkcode, we want to do some
processings (like defaulting to "" if eq "Default") BEFORE we retrieve
the MARC structure ($tagslib, $usedTagsLib).

This patch also moved this code after get_template_and_user (and so
authentication), like it should be everywhere.

Test plan:
1. Go to Cataloging
2. Click on New from Z39.50/SRU
3. Make a search in the library of congress server for anything (Caroline searched for author: shakespeare)
4. Click on one of the results and choose Import
Without this patch the basic editor appears, but not the record
With this patch applied the bug is fixed and you can edit the record

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Marcel de Rooy 2024-09-20 07:39:14 UTC
Created attachment 171822 [details] [review]
Bug 37947: (bug 37429 follow-up) Fix addbiblio and frameworkcode="Default"

On bug 37429 we reordered the global var to assign them before anything
else. The logic is correct except for $frameworkcode, we want to do some
processings (like defaulting to "" if eq "Default") BEFORE we retrieve
the MARC structure ($tagslib, $usedTagsLib).

This patch also moved this code after get_template_and_user (and so
authentication), like it should be everywhere.

Test plan:
1. Go to Cataloging
2. Click on New from Z39.50/SRU
3. Make a search in the library of congress server for anything (Caroline searched for author: shakespeare)
4. Click on one of the results and choose Import
Without this patch the basic editor appears, but not the record
With this patch applied the bug is fixed and you can edit the record

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 8 Katrin Fischer 2024-09-27 17:41:31 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 9 Lucas Gass (lukeg) 2024-10-09 19:54:30 UTC
Backported to 24.05.x for upcoming 24.05.05
Comment 10 Phil Ringnalda 2024-10-18 19:51:47 UTC
*** Bug 38168 has been marked as a duplicate of this bug. ***
Comment 11 Manfred R. 2024-10-30 09:52:57 UTC
The following is regarding my standard KOHA installation (according to http://wiki.koha-community.org/wiki/Debian) under Ubuntu Server 24.x with Apache 2.

My successfully tested workaround makes use of the apache "substitute" module:

- Edit /etc/apache2/sites-available/<koha-instance name>.conf
- In the "intranet" virtualhost section, add the following two lines:
     SetOutputFilter SUBSTITUTE
     Substitute 's|frameworkcode=Default|frameworkcode=|nq'
- sudo a2enmod substitute
- sudo systemctl restart apache2