From af888cd3b84d0b784667dca4d16a00a3c19c3516 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 10 Feb 2021 07:26:15 +0100 Subject: [PATCH] Bug 27650: Fix variable passed to the template in opac-main $template->param( + koha_news => @all_koha_news, We must not pass an array, the number of elements of the hash passed to the template may be inconsistent. It's working because of an error earlier in the script: + @all_koha_news = &GetNewsToDisplay($news_lang,$homebranch); GetNewsToDisplay returns an arrayref Test plan: Define at least 2 news to display on the OPAC main page Hit opac-main.pl => All news are displayed Click one => You see the single news you selected Signed-off-by: Fridolin Somers Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit ca4ef19a2bb400d4348ee84eaddf6af0c429d1c7) Signed-off-by: Fridolin Somers --- opac/opac-main.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/opac/opac-main.pl b/opac/opac-main.pl index c572866284..27e1b24cfc 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -60,17 +60,17 @@ elsif (C4::Context->userenv and defined $input->param('branch') and length $inpu } my $news_id = $input->param('news_id'); -my @all_koha_news; +my $all_koha_news; if (defined $news_id){ - @all_koha_news = Koha::News->search({ idnew => $news_id, lang => { '!=', 'koha' } }); # get news that is not staff-only news - if( @all_koha_news ) { # we only expect one btw - $template->param( news_item => $all_koha_news[0] ); + $all_koha_news = Koha::News->search({ idnew => $news_id, lang => { '!=', 'koha' } }); # get news that is not staff-only news + if( $all_koha_news->count ) { # we only expect one btw + $template->param( news_item => $all_koha_news->next ); } else { $template->param( single_news_error => 1 ); } } else { - @all_koha_news = &GetNewsToDisplay( $template->lang, $homebranch); + $all_koha_news = &GetNewsToDisplay( $template->lang, $homebranch); } # For dashboard @@ -97,7 +97,7 @@ if ( $patron ) { } $template->param( - koha_news => @all_koha_news, + koha_news => $all_koha_news, branchcode => $homebranch, daily_quote => Koha::Quotes->get_daily_quote(), ); -- 2.39.5