From 5ea5c72edb6cbce81053ba310646ba22c178ef32 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 16 Jun 2022 12:29:14 +0200 Subject: [PATCH] Bug 30972: Don't replace biblio's local cover images when uploading an image's image When attaching a new cover image to an item we should not replace cover images attached to the bibliographic record if "Replace existing covers" is ticked. Test plan: Attach 1+ image to a bibliographic record Attach 1 image to an item of this biblio Attach another image to the item and seect "replace existing covers" => Without this patch the images attached to the biblio are removed => With this patch applied only the images attached to the image are removed Same if you tick the checkbox when attaching an image to the biblio Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit e32e7a6c9019ac93217f1b4322076e779d35dec4) Signed-off-by: Lucas Gass --- tools/upload-cover-image.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/upload-cover-image.pl b/tools/upload-cover-image.pl index e533b8362d..4bd2e57e8f 100755 --- a/tools/upload-cover-image.pl +++ b/tools/upload-cover-image.pl @@ -107,10 +107,10 @@ if ($fileID) { if ( defined $srcimage ) { eval { if ( $replace ) { - if ( $biblionumber ) { - Koha::Biblios->find($biblionumber)->cover_images->delete; - } elsif ( $itemnumber ) { + if ( $itemnumber ) { Koha::Items->find($itemnumber)->cover_images->delete; + } elsif ( $biblionumber ) { + Koha::Biblios->find($biblionumber)->cover_images->search({ itemnumber => undef })->delete; } } -- 2.39.5