From 85ea56a170cc1f91dafbc37f6a9b9c97143ad208 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 6 Mar 2026 12:04:32 +0100 Subject: [PATCH] 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 Signed-off-by: Laura Escamilla (cherry picked from commit da64305067e26d31e909a7a6ec040cd50bc27164) Signed-off-by: Baptiste Wojtkowski --- cataloguing/addbooks.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl index 2206c5e143..400b02f7d9 100755 --- a/cataloguing/addbooks.pl +++ b/cataloguing/addbooks.pl @@ -46,7 +46,6 @@ my $query = $input->param('q'); my @value = $input->multi_param('value'); my $page = $input->param('page') || 1; my $results_per_page = 20; -my $lang = C4::Languages::getlanguage($input); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -57,6 +56,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( flagsrequired => { editcatalogue => '*' }, } ); +my $lang = C4::Languages::getlanguage($input); # Searching the catalog. if ($query) {