[Koha-bugs] [Bug 31383] Additional contents: We need a parent and child table

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Jun 22 11:01:10 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31383

--- Comment #34 from Marcel de Rooy <m.de.rooy at rijksmuseum.nl> ---
Will add a follow-up for this bug. We need to check $lang before searching
translated content. And which was very bad, we do not need to search for
additional_content_id in the wrong column.

diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm
index 0555ddc6d1..7d5e877d0f 100644
--- a/Koha/AdditionalContents.pm
+++ b/Koha/AdditionalContents.pm
@@ -85,9 +85,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},
@@ -105,7 +105,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') ]
         },
     );

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list