From ff36d256b70cd1a9fbc38816313964f3187621d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 24 Aug 2010 14:48:46 +0200 Subject: [PATCH] (bug #4363) Fix subscription search error when no results There was a template param assignment before template is loaded. Signed-off-by: Colin Campbell --- serials/subscription-bib-search.pl | 33 +++++++++++++----------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/serials/subscription-bib-search.pl b/serials/subscription-bib-search.pl index d1b0f634d8..ab7ab80c4f 100755 --- a/serials/subscription-bib-search.pl +++ b/serials/subscription-bib-search.pl @@ -76,6 +76,16 @@ my $query = $input->param('q'); # don't run the search if no search term ! if ($op eq "do_search" && $query) { + ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "serials/result.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1, serials => '*'}, + debug => 1, + } + ); + # add the itemtype limit if applicable my $itemtypelimit = $input->param('itemtypelimit'); if ( $itemtypelimit ) { @@ -90,7 +100,10 @@ if ($op eq "do_search" && $query) { $resultsperpage = 20 if(!defined $resultsperpage); my ($error, $marcrecords, $total_hits) = SimpleSearch($query, $startfrom*$resultsperpage, $resultsperpage); - my $total = scalar @$marcrecords; + my $total = 0; + if (defined $marcrecords ) { + $total = scalar @{$marcrecords}; + } if (defined $error) { $template->param(query_error => $error); @@ -117,15 +130,6 @@ if ($op eq "do_search" && $query) { push @results, \%resultsloop; } - ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "serials/result.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {catalogue => 1, serials => '*'}, - debug => 1, - }); - # multi page display gestion my $displaynext=0; my $displayprev=$startfrom; @@ -223,15 +227,6 @@ else { } } - ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "serials/subscription-bib-search.tmpl", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {catalogue => 1, serials => '*'}, - debug => 1, - }); - if ($op eq "do_search") { $template->param("no_query" => 1); -- 2.39.5