From af2d6eed4ac8392bf119ca6bfb739b475679f940 Mon Sep 17 00:00:00 2001 From: Jacek Ablewicz Date: Tue, 14 Jun 2016 16:31:57 +0200 Subject: [PATCH] Bug 16734: getLanguages() in opac-search.pl should be called only if needed There is no need to always call getLanguages() in opac/opac-search.pl (especially not if it's an actual search), it's output is used only in opac-advsearch.tt template. This patch moves it into 'if ( ... $template_type eq 'advsearch' )' block. Speed gain is rather moderate (40 - 80 msec, if the mysql server is no too busy, and the results are already in query cache), but it eliminates a lot of small DBI calls, making a further profiling of OPAC searches a bit easier. Test plan: just ensure that language selection is still available on OPAC advanced search page, and that it still works like intended. --- opac/opac-search.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 64b8800..d947b06 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -217,10 +217,6 @@ my $branches = GetBranches(); # used later in *getRecords, probably should be my $library_categories = Koha::LibraryCategories->search( { categorytype => 'searchdomain' }, { order_by => [ 'categorytype', 'categorycode' ] } ); $template->param( searchdomainloop => $library_categories ); -# 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; # add translated_description to itemtypes @@ -303,6 +299,10 @@ $template->param(advancedsearchesloop => \@advancedsearchesloop); # The following should only be loaded if we're bringing up the advanced search template 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 servers (used for searching -- to do federated searching, etc.) my $primary_servers_loop;# = displayPrimaryServers(); $template->param(outer_servers_loop => $primary_servers_loop,); -- 1.7.10.4