Bug 40883 - Authorities display fails on unknown 7XX
Summary: Authorities display fails on unknown 7XX
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: MARC Authority data support (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Fridolin Somers
QA Contact: Testopia
URL:
Keywords:
Depends on: 27943
Blocks: 34482
  Show dependency treegraph
 
Reported: 2025-09-26 07:40 UTC by Fridolin Somers
Modified: 2025-09-26 09:02 UTC (History)
0 users

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40883: Add unit test (1.66 KB, patch)
2025-09-26 08:52 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 40883: Fix authorities display fails on unknown 7XX (2.04 KB, patch)
2025-09-26 08:52 UTC, Fridolin Somers
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2025-09-26 07:40:11 UTC
Bug 27943 added MARC21 authorities 7XX on display.
It calls $field->as_string($subfields_to_report).
This fails when field is not in known ones.
Comment 1 Fridolin Somers 2025-09-26 08:47:10 UTC
This creates an ugly warning in logs :

Unmatched [ in regex; marked by <-- HERE in m/^[ <-- HERE ]$/ at /usr/share/perl5/MARC/Field.pm line 643.

Because of a call field->as_string with an empty string.
Looks like MARC::Field only checks var is undef before using in regexp.
Comment 2 Fridolin Somers 2025-09-26 08:52:35 UTC
Created attachment 186964 [details] [review]
Bug 40883: Add unit test
Comment 3 Fridolin Somers 2025-09-26 08:52:47 UTC
Created attachment 186965 [details] [review]
Bug 40883: Fix authorities display fails on unknown 7XX

Bug 27943 added MARC21 authorities 7XX on display.
It calls $field->as_string($subfields_to_report).
This fails when authority type is custom (not in C4/Heading/MARC21.pm $auth_heading_fields)
and so field is not in known ones.

We see in other parts that $subfields_to_report may be emty.
This patch simply creates 7xx heading with $field->as_string() in this case.

Test plan:
1) Run test : prove t/db_dependent/AuthoritiesMarc.t
2) Create a new autority type with main heading in 199 and field 799
3) Create a new authority of this type
4) Perform a search to find it
=> Without patch the page retruns the error
Unmatched [ in regex; marked by <-- HERE in m/^[ <-- HERE ]$/ at /usr/share/perl5/MARC/Field.pm line 643.
Comment 4 Fridolin Somers 2025-09-26 09:02:14 UTC
NB :

We see in C4/AuthoritiesMarc.pm BuildSummary() that var $subfields_to_report can be set by part building 7xx and then is reused in part building 880.
This looks very strange.