From 550191f6ba1bce375099c76f8a8c3b0d01b48022 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 2 Feb 2022 12:51:21 +0000 Subject: [PATCH] Bug 29970: eval processing of MARC record to avoid crash detail.pl displays a warning at the top of the page when a record contains parsing errors Bug 28734 and bug 11175 added additional parsing of the MARC record, but they did not catch the thrown errors. The existing pattern in the script is to eval responses to avoid crashing This patch wraps the new calls in eval{} To test: 1 - Find a record in the staff catalog 2 - Edit the record 3 - In the 520 notes field, add an ASCII escape character (27 decimal, 1b hex) On ubuntu Ctrl+Shift+u, then 1b, enter 4 - Save the record 5 - 500 Error 6 - Apply patch 7 - Reload 8 - The record displays with a warning at the top --- catalogue/detail.pl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/catalogue/detail.pl b/catalogue/detail.pl index bc28f29cc1..3dc73f84d6 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -137,7 +137,6 @@ my $upc = GetNormalizedUPC($record,$marcflavour); my $ean = GetNormalizedEAN($record,$marcflavour); my $oclc = GetNormalizedOCLCNumber($record,$marcflavour); my $isbn = GetNormalizedISBN(undef,$record,$marcflavour); - $template->param( normalized_upc => $upc, normalized_ean => $ean, @@ -145,12 +144,10 @@ $template->param( normalized_isbn => $isbn, ); -my $marcnotesarray = $biblio->get_marc_notes({ marcflavour => $marcflavour }); - +my $marcnotesarray = eval { $biblio->get_marc_notes({ marcflavour => $marcflavour }) }; my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; my $dbh = C4::Context->dbh; - my @all_items = GetItemsInfo( $biblionumber ); my @items; my $patron = Koha::Patrons->find( $borrowernumber ); @@ -167,6 +164,7 @@ if (@hostitems){ push (@items,@hostitems); } + my $dat = &GetBiblioData($biblionumber); #coping with subscriptions @@ -199,7 +197,7 @@ foreach my $subscription (@subscriptions) { my $showcomp = C4::Context->preference('ShowComponentRecords'); my $show_analytics; if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { - if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) { + if ( my $components = eval {$biblio->get_marc_components(C4::Context->preference('MaxComponentRecords'))} ) { $show_analytics = 1 if @{$components}; # just show link when having results $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->messages}; my $parts; @@ -221,7 +219,7 @@ if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { $template->param( ComponentPartsQuery => $biblio->get_components_query ); } } else { # check if we should show analytics anyway - $show_analytics = 1 if @{$biblio->get_marc_components(1)}; # count matters here, results does not + $show_analytics = 1 if eval{ @{$biblio->get_marc_components(1)} }; # count matters here, results does not $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->messages}; } -- 2.30.2