Bugzilla – Attachment 73849 Details for
Bug 20539
Warnings in catalogue/search.pl need to be removed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20539: Remove warnings in catalogue/search.pl
Bug-20539-Remove-warnings-in-cataloguesearchpl.patch (text/plain), 6.28 KB, created by
Julian Maurice
on 2018-04-09 09:49:21 UTC
(
hide
)
Description:
Bug 20539: Remove warnings in catalogue/search.pl
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2018-04-09 09:49:21 UTC
Size:
6.28 KB
patch
obsolete
>From 0025bd2ec6fc6d96547ab05164f938228d95976c Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Mon, 9 Apr 2018 11:38:44 +0200 >Subject: [PATCH] Bug 20539: Remove warnings in catalogue/search.pl > >Test plan: >1. Start a search from intranet >2. See several warnings in logs >3. Apply patch (&& reload starman) >4. Start a new search >5. Confirm that warnings are gone and that the search still works >--- > catalogue/search.pl | 69 +++++++++++++++++++++++++++++------------------------ > 1 file changed, 38 insertions(+), 31 deletions(-) > >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 79ba83fd08..27b36b7802 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -170,6 +170,7 @@ my $template_type; > my @params = $cgi->multi_param("limit"); > if ((@params>=1) || ($cgi->param("q")) || ($cgi->param('multibranchlimit')) || ($cgi->param('limit-yr')) ) { > $template_name = 'catalogue/results.tt'; >+ $template_type = 'results'; > } > else { > $template_name = 'catalogue/advsearch.tt'; >@@ -449,7 +450,6 @@ my $offset = $params->{'offset'} || 0; > $offset = 0 if $offset < 0; > my $page = $cgi->param('page') || 1; > #my $offset = ($page-1)*$results_per_page; >-my $hits; > my $expanded_facet = $params->{'expand'}; > > # Define some global variables >@@ -474,42 +474,47 @@ my @query_inputs; > my $scan_index_to_use; > my $scan_search_term_to_use; > >-for my $this_cgi ( split('&',$query_cgi) ) { >- next unless $this_cgi; >- $this_cgi =~ m/(.*?)=(.*)/; >- my $input_name = $1; >- my $input_value = $2; >- push @query_inputs, { input_name => $input_name, input_value => Encode::decode_utf8( uri_unescape( $input_value ) ) }; >- if ($input_name eq 'idx') { >- $scan_index_to_use = $input_value; # unless $scan_index_to_use; >- } >- if ($input_name eq 'q') { >- $scan_search_term_to_use = Encode::decode_utf8( uri_unescape( $input_value )); >+if ($query_cgi) { >+ for my $this_cgi ( split('&', $query_cgi) ) { >+ next unless $this_cgi; >+ $this_cgi =~ m/(.*?)=(.*)/; >+ my $input_name = $1; >+ my $input_value = $2; >+ push @query_inputs, { input_name => $input_name, input_value => Encode::decode_utf8( uri_unescape( $input_value ) ) }; >+ if ($input_name eq 'idx') { >+ $scan_index_to_use = $input_value; # unless $scan_index_to_use; >+ } >+ if ($input_name eq 'q') { >+ $scan_search_term_to_use = Encode::decode_utf8( uri_unescape( $input_value )); >+ } > } > } >+ > $template->param ( QUERY_INPUTS => \@query_inputs, > scan_index_to_use => $scan_index_to_use, > scan_search_term_to_use => $scan_search_term_to_use ); > > ## parse the limit_cgi string and put it into a form suitable for <input>s > my @limit_inputs; >-for my $this_cgi ( split('&',$limit_cgi) ) { >- next unless $this_cgi; >- # handle special case limit-yr >- if ($this_cgi =~ /yr,st-numeric/) { >- push @limit_inputs, { input_name => 'limit-yr', input_value => $limit_yr_value }; >- next; >+if ($limit_cgi) { >+ for my $this_cgi ( split('&', $limit_cgi) ) { >+ next unless $this_cgi; >+ # handle special case limit-yr >+ if ($this_cgi =~ /yr,st-numeric/) { >+ push @limit_inputs, { input_name => 'limit-yr', input_value => $limit_yr_value }; >+ next; >+ } >+ $this_cgi =~ m/(.*=)(.*)/; >+ my $input_name = $1; >+ my $input_value = $2; >+ $input_name =~ s/=$//; >+ push @limit_inputs, { input_name => $input_name, input_value => Encode::decode_utf8( uri_unescape($input_value) ) }; > } >- $this_cgi =~ m/(.*=)(.*)/; >- my $input_name = $1; >- my $input_value = $2; >- $input_name =~ s/=$//; >- push @limit_inputs, { input_name => $input_name, input_value => Encode::decode_utf8( uri_unescape($input_value) ) }; > } > $template->param ( LIMIT_INPUTS => \@limit_inputs ); > > ## II. DO THE SEARCH AND GET THE RESULTS >-my $total; # the total results for the whole set >+my $total = 0; # the total results for the whole set > my $facets; # this object stores the faceted results that display on the left-hand of the results page > my $results_hashref; > >@@ -534,11 +539,11 @@ my @sup_results_array; > for (my $i=0;$i<@servers;$i++) { > my $server = $servers[$i]; > if ($server =~/biblioserver/) { # this is the local bibliographic server >- $hits = $results_hashref->{$server}->{"hits"}; >+ my $hits = $results_hashref->{$server}->{"hits"} // 0; > my $page = $cgi->param('page') || 0; > my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan, > $results_hashref->{$server}->{"RECORDS"}); >- $total = $total + $results_hashref->{$server}->{"hits"}; >+ $total = $total + $hits; > > # Search history > if (C4::Context->preference('EnableSearchHistory')) { >@@ -586,9 +591,11 @@ for (my $i=0;$i<@servers;$i++) { > > if ($hits) { > $template->param(total => $hits); >- my $limit_cgi_not_availablity = $limit_cgi; >- $limit_cgi_not_availablity =~ s/&limit=available//g; >- $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity); >+ if ($limit_cgi) { >+ my $limit_cgi_not_availablity = $limit_cgi; >+ $limit_cgi_not_availablity =~ s/&limit=available//g; >+ $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity); >+ } > $template->param(limit_cgi => $limit_cgi); > $template->param(query_cgi => $query_cgi); > $template->param(query_desc => $query_desc); >@@ -703,13 +710,13 @@ for (my $i=0;$i<@servers;$i++) { > $template->{'VARS'}->{'searchid'} = $cgi->param('searchid'); > > my $gotonumber = $cgi->param('gotoNumber'); >-if ($gotonumber eq 'last' || $gotonumber eq 'first') { >+if ( $gotonumber && ( $gotonumber eq 'last' || $gotonumber eq 'first' ) ) { > $template->{'VARS'}->{'gotoNumber'} = $gotonumber; > } > $template->{'VARS'}->{'gotoPage'} = 'detail.pl'; > my $gotopage = $cgi->param('gotoPage'); > $template->{'VARS'}->{'gotoPage'} = $gotopage >- if $gotopage =~ m/^(ISBD|labeledMARC|MARC|more)?detail.pl$/; >+ if $gotopage && $gotopage =~ m/^(ISBD|labeledMARC|MARC|more)?detail.pl$/; > > for my $facet ( @$facets ) { > for my $entry ( @{ $facet->{facets} } ) { >-- >2.14.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20539
:
73849
|
74176
|
74181