From aa3a34e831c13361afb8264573acae4dc4b6a8fd Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 19 Oct 2023 11:49:26 +0000 Subject: [PATCH] Bug 35099: Prevent crash from invalid marc in the parent record When getting the query for components, we need to parse the MARC::Record. If that fails, we simply should not attempt the component search as the user should see a warning about the degraded MARC To test: prove -v t/db_dependent/selenium/regressions.t It fails apply patch, restart_all prove -v t/db_dependent/selenium/regressions.t It passes Signed-off-by: Martin Renvoize --- Koha/Biblio.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index fc38955718c..0326c1c8147 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -767,7 +767,12 @@ sub get_volumes_query { # MARC21 Only for now return if ( C4::Context->preference('marcflavour') ne 'MARC21' ); - my $marc = $self->metadata->record; + # If the marc cannot be loaded, do not build the query + # the staff interface should already be displaying an error message in this case + # so we don't need to return the error + my $marc; + eval { $marc = $self->metadata->record;}; + return unless $marc; # Only build volumes query if we're in a 'Set' record # or we have a monographic series. -- 2.41.0