Bug 32251 - opac-page.pl: Add a fallback for when language cookie was removed
Summary: opac-page.pl: Add a fallback for when language cookie was removed
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Marcel de Rooy
QA Contact: Kyle M Hall
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-17 15:26 UTC by Marcel de Rooy
Modified: 2023-06-08 22:32 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.03


Attachments
Bug 32251: Add a fallback for when language cookie was removed (2.30 KB, patch)
2022-11-18 07:42 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 32251: Add a fallback for when language cookie was removed (2.31 KB, patch)
2022-12-02 16:44 UTC, PTFS Europe Sandboxes
Details | Diff | Splinter Review
Bug 32251: Add a fallback for when language cookie was removed (2.37 KB, patch)
2023-01-20 14:03 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2022-11-17 15:26:29 UTC
Simply put:
Replace
-    my $lang = $query->param('language') || $query->cookie('KohaOpacLanguage');
+    my $lang = $query->param('language') || $query->cookie('KohaOpacLanguage') || $template->lang;
Comment 1 Marcel de Rooy 2022-11-18 07:42:33 UTC
Created attachment 144045 [details] [review]
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 <m.de.rooy@rijksmuseum.nl>
Comment 2 PTFS Europe Sandboxes 2022-12-02 16:44:20 UTC
Created attachment 144405 [details] [review]
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 <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Pascal <pascal.uphaus@gwdg.de>
Comment 3 Kyle M Hall 2023-01-20 14:03:34 UTC
Created attachment 145512 [details] [review]
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 <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Pascal <pascal.uphaus@gwdg.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Tomás Cohen Arazi 2023-01-27 19:22:52 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 5 Matt Blenkinsop 2023-01-31 14:28:43 UTC
Nice work everyone!

Pushed to stable for 22.11.x