Bug 37425: Check for existence of biblio object before fetching cover images

This patch simply adds a conditional to ensure the biblio object has been retrieved and assumes no cover images otherwise

To test:
 1 - Enable system preference LocalCoverImages
 2 - Perform a search in staff interface
 3 - Find the biblionumebr for one of the results and delete it via the SQL backend:
     DELETE FROM biblio WHERE biblionumber=3;
 4 - Search again.
 5 - KO!
     Can't call method "cover_images" on an undefined value at /usr/share/koha/intranet/cgi-bin/catalogue/search.pl line 671.
 6 - Reindex, confirm error is gone
 7 - Apply patch
 8 - Search again
 9 - Delete a record from the results via SQL
10 - Reload and confirm no error
11 - Reindex and repeat search and confirm no error

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 8fdddccffb)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2024-07-22 19:46:33 +00:00 committed by Lucas Gass
parent 864d666424
commit 4d141a6bb7
1 changed files with 2 additions and 1 deletions

View File

@ -668,7 +668,8 @@ for (my $i=0;$i<@servers;$i++) {
}
if ( C4::Context->preference('LocalCoverImages') ) {
$line->{has_local_cover_image} = $line->{biblio_object}->cover_images->count;
$line->{has_local_cover_image} =
$line->{biblio_object} ? $line->{biblio_object}->cover_images->count : 0;
}
}
my( $page_numbers, $hits_to_paginate, $pages, $current_page_number, $previous_page_offset, $next_page_offset, $last_page_offset ) =