From e6f86e47bf4d37d67d2e6f9025f8d56f804385ed Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 24 Jan 2025 12:25:46 +0100 Subject: [PATCH] Bug 37425: Check for existence of biblio object before fetching cover images at OPAC 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 OPACLocalCoverImages 2 - Perform a search in OPAC 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 ... 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 --- opac/opac-search.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 54eabd8949..d52f96d01a 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -699,7 +699,7 @@ for (my $i=0;$i<@servers;$i++) { $res->{artreqpossible} = ( $art_req_itypes->{ $res->{itemtype} // q{} } || $art_req_itypes->{ '*' } ) ? 1 : q{}; if ( C4::Context->preference('OPACLocalCoverImages') ) { - $res->{has_local_cover_image} = $res->{biblio_object}->cover_images->count; + $res->{has_local_cover_image} = $res->{biblio_object} ? $res->{biblio_object}->cover_images->count : 0; } } -- 2.47.2