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 <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit e32e7a6c90)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2022-06-16 12:29:14 +02:00 committed by Lucas Gass
parent eae8863fcb
commit 5ea5c72edb
1 changed files with 3 additions and 3 deletions

View File

@ -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;
}
}