From d397da65c02ee40243aacdc3382e68b84e040921 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 1 Apr 2024 14:32:08 +0000 Subject: [PATCH] Bug 36473: Handle Invalid Metadata Exceptions in totalissues.pl This patch wraps the call for record in an eval, and catches any invalid metadata exceptions, letting the warning show, but allowing the script to continue To test: 1 - In default KTD record 369 has problems, otherwise you need to break a record 2 - Run : misc/cronjobs/update_totalissues.pl --use-stats --commit=1000 -v 3 - It dies at record 369 (or the one you broke) 4 - Apply patch 5 - Run again 6 - It succeeds, but skips the bad record Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer (cherry picked from commit f3d2f34d7a6aeead30b40a30b239f15c6c94a7f2) Signed-off-by: Fridolin Somers --- C4/Biblio.pm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 300cfa281b..b57eb7b85a 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -3033,9 +3033,12 @@ sub UpdateTotalIssues { return; } - my $record = $biblio->metadata->record; - unless ($record) { - carp "UpdateTotalIssues could not get biblio record"; + my $record; + eval { $record = $biblio->metadata->record }; + if ($@) { + my $exception = $@; + $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') ); + warn "UpdateTotalIssues could not get bibliographic record"; return; } my $biblioitem = $biblio->biblioitem;