Bug 12114: (QA Followup) Use JSON instead of JSON::XS
[koha_fer] / opac / opac-search.pl
index 00cd8e3..83f16d8 100755 (executable)
@@ -43,7 +43,7 @@ for ( $searchengine ) {
 
 use C4::Output;
 use C4::Auth qw(:DEFAULT get_session ParseSearchHistorySession SetSearchHistorySession);
-use C4::Languages qw(getAllLanguages);
+use C4::Languages qw(getLanguages);
 use C4::Search;
 use C4::Biblio;  # GetBiblioData
 use C4::Koha;
@@ -198,7 +198,7 @@ $template->param(
 );
 
 # load the language limits (for search)
-my $languages_limit_loop = getAllLanguages($lang);
+my $languages_limit_loop = getLanguages($lang, 1);
 $template->param(search_languages_loop => $languages_limit_loop,);
 
 # load the Type stuff
@@ -556,6 +556,7 @@ for (my $i=0;$i<@servers;$i++) {
             @newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
                                         $results_hashref->{$server}->{"RECORDS"});
         }
+        $hits = 0 unless @newresults;
 
         foreach my $res (@newresults) {
 
@@ -610,11 +611,10 @@ for (my $i=0;$i<@servers;$i++) {
         }
 
         if ($results_hashref->{$server}->{"hits"}){
-            $total = $total + $results_hashref->{$server}->{"hits"};
+            $total = $total + $hits;
         }
 
         # Opac search history
-        my $newsearchcookie;
         if (C4::Context->preference('EnableOpacSearchHistory')) {
             my @recentSearches = ParseSearchHistorySession($cgi);
 
@@ -638,11 +638,10 @@ for (my $i=0;$i<@servers;$i++) {
                 }
 
                 shift @recentSearches if (@recentSearches > 15);
-                # Pushing the cookie back
                 SetSearchHistorySession($cgi, \@recentSearches);
             }
             else {
-                # To the session (the user is logged in)
+                # To the database (the user is logged in)
                 if (!$offset) {
                     AddSearchHistory($borrowernumber, $cgi->cookie("CGISESSID"), $query_desc_history, $query_cgi_history, $total);
                     $template->param(ShowOpacRecentSearchLink => 1);