From 246ee74c54e9cf3ead959253480b795f62e88a12 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 --- 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.30.2