From bed0a26cd85aff32ca0a0c92d31f39f9907b28a3 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 16 May 2024 09:33:34 +0000 Subject: [PATCH] Bug 35989: Stop geographic authority searches crashing Currently when searching for a geographic authority record the search will fail if the record has a heading in a 78X field. The system tries to do a regex match against an undefined variable causing an error. This patch makes that regex match conditional on the variable being defined to allow the search to succeed. Test plan: 1) Navigate to Authorities 2) In the search bar at the top of the page, click on the dropdown options and in the 'Authority type' field, select 'Geographic Name' 3) Click search 4) You should have a list of authorities 5) Click on any authority record and then click edit and select to edit the record 6) Click on the "7" button 7) Click on the green text next to the '781' field to get the list of fields 8) In field 'v' enter any string you like 9) Click save 10) Repeat steps 1-3, this time it should display an error message for an Unmatched [ in regex 11) Apply patch 12) restart_all 13) Refresh the page, the results should show and the string you entered in the 'v' field should display on the record you edited --- C4/AuthoritiesMarc.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index b595230c5d..d7fd7371ff 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -1138,9 +1138,11 @@ sub BuildSummary { my $heading = $field->as_string($subfields_to_report); - my $subheading = $field->as_string( $subfields_to_subdivision, $delimiter ); - if ( length $subheading > 0 ) { - $heading .= $delimiter . $subheading; + if($subfields_to_subdivision) { + my $subheading = $field->as_string( $subfields_to_subdivision, $delimiter ); + if ( length $subheading > 0 ) { + $heading .= $delimiter . $subheading; + } } if ($subfields_to_report) { -- 2.37.1 (Apple Git-137.1)