Bug 41989: Call getlanguage after get_template_and_user

This patch prevents the UI to randomly change the language when reaching
addbooks

The problem is that getlanguage is called BEFORE get_template_and_user,
without, and "interface" (C4::Context->interface) is not set yet.

Open C4/Languages.pm, search "sub getlanguage"
We first read the cache, then if there is no interface we reach
GetTranslatedLanguages that does return languages in a random order,
then we pick the first one
765         @languages = map { $_->{rfc4646_subtag} } @{ getTranslatedLanguages( $interface, $theme ) };
783     $language = shift @languages unless $language;

We must call getlanguage AFTER that the cache is populated.

Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-03-06 12:04:32 +01:00 committed by Martin Renvoize
parent 1984f205ed
commit 5059a0b360
No known key found for this signature in database
GPG Key ID: 2D86E0EAEC83711B
1 changed files with 1 additions and 1 deletions

View File

@ -43,7 +43,6 @@ my $query = $input->param('q');
my @value = $input->multi_param('value'); my @value = $input->multi_param('value');
my $page = $input->param('page') || 1; my $page = $input->param('page') || 1;
my $results_per_page = 20; my $results_per_page = 20;
my $lang = C4::Languages::getlanguage($input);
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{ {
@ -53,6 +52,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
flagsrequired => { editcatalogue => '*' }, flagsrequired => { editcatalogue => '*' },
} }
); );
my $lang = C4::Languages::getlanguage($input);
# Searching the catalog. # Searching the catalog.
if ($query) { if ($query) {