From 1b95828e79aa3936ec74c3df8563733db6a82499 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 Signed-off-by: Nick Clemens Signed-off-by: Aleisha Amohia Signed-off-by: Martin Renvoize (cherry picked from commit 6c9482f213ba7f65de490f49b1ddf3425a4ab478) Signed-off-by: Lucas Gass (cherry picked from commit 6dfb1dd9317ff916b8e7aa13aeb1601252118dea) Signed-off-by: Fridolin Somers --- C4/AuthoritiesMarc.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 70c5903dc4..933d944abe 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -1122,9 +1122,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.39.5