From 1f679bb7748a5c9e72a5988ca4b4cc90fb2f4d8d Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 18 Nov 2022 07:23:25 +0000 Subject: [PATCH] Bug 32251: Add a fallback for when language cookie was removed Since we remove cookies after logout now, the language cookie might not be there yet. It is friendlier to add the template language fallback here now too before switching to 'default' in the Additional contents (AC)-context. Note: The cookie will not be removed when you added it to the list in koha-conf.xml. Note2: This only pertains to the use of opac-page with code param. Test plan: [1] Create a CMS page with AC. Add two languages (say en, nl-NL). Add different text to default and both languages. [2] Remove the KohaOPACLanguage cookie from your browser (via dev console). [3] Without this patch, copy the Current language URL from the AC overview page. (Note that the Default URL always refers you to 'default'.) [4] Go to that page with the selected (Current..) URL. Observe that you still see the 'default' text. [5] Remove the cookie again if it might be there already. [6] With this patch, observe that you get the language of the interface now on the CMS page using the same URL. Signed-off-by: Marcel de Rooy Signed-off-by: Pascal Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi (cherry picked from commit a99d188e78d42b7c2b9f2091a64142ba45909c70) Signed-off-by: Matt Blenkinsop --- opac/opac-page.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opac/opac-page.pl b/opac/opac-page.pl index d5e83f7d4d..cba09dddfd 100755 --- a/opac/opac-page.pl +++ b/opac/opac-page.pl @@ -45,7 +45,7 @@ if (C4::Context->userenv) { if( $page_id ) { $page = Koha::AdditionalContents->search({ idnew => $page_id, location => ['opac_only', 'staff_and_opac'], branchcode => [ $homebranch, undef ] }); } elsif( $code ) { - my $lang = $query->param('language') || $query->cookie('KohaOpacLanguage'); + my $lang = $query->param('language') || $query->cookie('KohaOpacLanguage') || $template->lang; # In the next query we make sure that the 'default' records come after the regular languages $page = Koha::AdditionalContents->search({ code => $code, lang => ['default', $lang], location => ['opac_only', 'staff_and_opac'], branchcode => [ $homebranch, undef ] }, { order_by => { -desc => \[ 'CASE WHEN lang="default" THEN "" ELSE lang END' ]}} ); } -- 2.39.5