From 2e773a33c362247a0b763996226df8ca9acd5858 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 22 Jun 2023 08:41:41 +0000 Subject: [PATCH] Bug 31383: Check lang and use right column in search_for_display We should check if $lang equals default before looking for translated contents. And note that @translated_content_id contains additional_content_id not id, so cannot be used in the last query. Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- Koha/AdditionalContents.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm index a866aa71d0..4b97fc1d83 100644 --- a/Koha/AdditionalContents.pm +++ b/Koha/AdditionalContents.pm @@ -87,9 +87,9 @@ sub search_for_display { my $contents = $self->SUPER::search( $search_params, { order_by => 'number' } ); my @all_content_id = $contents->get_column('id'); - my @translated_content_id; - if ( $params->{lang} ) { - my $translated_contents = Koha::AdditionalContentsLocalizations->search( + my ( $translated_contents, @translated_content_id ); + if ( $params->{lang} && $params->{lang} ne 'default' ) { + $translated_contents = Koha::AdditionalContentsLocalizations->search( { additional_content_id => [$contents->get_column('id')], lang => $params->{lang}, @@ -107,7 +107,7 @@ sub search_for_display { return Koha::AdditionalContentsLocalizations->search( { - id => [@translated_content_id, $default_contents->get_column('id')] + id => [ $translated_contents ? $translated_contents->get_column('id') : (), $default_contents->get_column('id') ] }, ); -- 2.39.5