From d13373daa65dccf0cc147c5e0da76f5a82ff6e6e Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 16 May 2024 09:25:34 +0000 Subject: [PATCH] Bug 36875: (follow-up) Modify query in translated_content This removes the MySQLism for FIELD(..). In this case we just want to get the non-default records in the front. So we can just test lang=default. And prevent inserting $lang in the expression. And so prevent execution in ORDER BY. No longer needing the ->quote call too. Test plan: Run Koha/AdditionalContents.t again. Signed-off-by: Marcel de Rooy Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Martin Renvoize --- Koha/AdditionalContent.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/AdditionalContent.pm b/Koha/AdditionalContent.pm index 3aca46ad875..3b2807a8496 100644 --- a/Koha/AdditionalContent.pm +++ b/Koha/AdditionalContent.pm @@ -134,9 +134,10 @@ Return the translated content for a given language. The default is returned if n sub translated_content { my ( $self, $lang ) = @_; + $lang ||= 'default'; my $content = $self->translated_contents->search( - { lang => [ 'default', ( $lang ? $lang : () ) ] }, - { ( $lang ? ( order_by => \[ "field(lang, '" . $lang . "', 'default')" ] ) : () ) } + { lang => [ 'default', $lang ] }, + { order_by => { -asc => [ \'lang="default"', 'id' ] } } )->next; return $content; } -- 2.45.1