Bug 38846: Only call getLanguages for advanced search pages

This change makes it so that C4::Languages::getLanguages is only
called for the advanced search pages and not the search result pages
where the output is not used.

Test plan:
0. Apply the patch and koha-plack --restart kohadev
1. Go to http://localhost:8081/cgi-bin/koha/catalogue/search.pl?expanded_options=1
2. Note that the "Language" and "Language of original" dropdowns appear with language
options
3. Go to the following
http://localhost:8081/cgi-bin/koha/catalogue/search.pl?advsearch=1
&idx=kw&q=test&sort_by=relevance
4. Note that the page loads normally

5. Go to http://localhost:8080/cgi-bin/koha/opac-search.pl?expanded_options=1
6. Note that the "Language" dropdown appears with language options
7. Go to http://localhost:8080/cgi-bin/koha/opac-search.pl?idx=&q=test&weight_search=1
8. Note that the page loads normally

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
David Cook 2025-01-08 00:14:46 +00:00 committed by Katrin Fischer
parent 9e894ee790
commit 996ec95274
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 12 additions and 6 deletions

View File

@ -329,9 +329,12 @@ if ( $template_type eq 'advsearch' ) {
$template->param(uc(C4::Context->preference("marcflavour")) =>1 );
# load the language limits (for search)
my $languages_limit_loop = getLanguages($lang, 1);
$template->param(search_languages_loop => $languages_limit_loop,);
if ( $template_type && $template_type eq 'advsearch' ) {
# load the language limits (for search)
my $languages_limit_loop = getLanguages( $lang, 1 );
$template->param( search_languages_loop => $languages_limit_loop, );
}
# Expanded search options in advanced search:
# use the global setting by default, but let the user override it

View File

@ -220,9 +220,12 @@ if ($cgi->cookie("search_path_code")) {
my @search_groups = Koha::Library::Groups->get_search_groups( { interface => 'opac' } )->as_list;
$template->param( search_groups => \@search_groups );
# load the language limits (for search)
my $languages_limit_loop = getLanguages($lang, 1);
$template->param(search_languages_loop => $languages_limit_loop,);
if ( $template_type && $template_type eq 'advsearch' ) {
# load the language limits (for search)
my $languages_limit_loop = getLanguages( $lang, 1 );
$template->param( search_languages_loop => $languages_limit_loop, );
}
# load the Type stuff
my $itemtypes = GetItemTypesCategorized;