From 2c03646735383b724ea2fe724bb002807c5849fd Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 3 Aug 2021 10:58:47 +0200 Subject: [PATCH] Bug 28784: Remove code related to num_paragraph cookie It could lead to server freeze if set to a big value (we are pushing into an array and so RAM is being fulfilled, and CPU is looping). I don't understand the point of this cookie. var numPar = $("#booleansearch fieldset p").size(); if (numPar > [% search_boxes_count | html %]){ jQuery.cookie("num_paragraph", numPar,{ path: '/'}); }else{ jQuery.removeCookie("num_paragraph", { path: '/'}); } But "#booleansearch fieldset p" does not exist, it's not 'p' but 'div' elements. I've removed the code related to num_paragraph and the "Return to the last advanced search" feature still works as before. From this comment: # determine what to display next to the search boxes (ie, boolean option # shouldn't appear on the first one, scan indexes should, adding a new # box should only appear on the last, etc. The only bit that is not working as described is "adding a new box should only appear on the last", but it has been working this way for a long time already I think, and I don't see it as a bug. Test plan: Read the code, check that the above is correct. Search for regression in this "return to last adv search" feature added by bug 13307. --- .../bootstrap/en/modules/opac-advsearch.tt | 8 ---- opac/opac-search.pl | 38 ------------------- 2 files changed, 46 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index 1edd1023406..f5b48f2769d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -482,7 +482,6 @@ $(document).ready(function() { //Clear all form cookies jQuery.removeCookie("form_serialized", { path: '/'}); jQuery.removeCookie("form_serialized_limits", { path: '/'}); - jQuery.removeCookie("num_paragraph", { path: '/'}); jQuery.removeCookie("search_path_code", { path: '/'}); [% END %] $('#advsearch form').submit(function() { @@ -508,16 +507,9 @@ $(document).ready(function() { ]; jQuery.cookie("form_serialized_limits", form_serialized_limits,{ path: '/'}); [% IF ( expanded_options ) %] - var numPar = $("#booleansearch fieldset p").size(); - if (numPar > [% search_boxes_count | html %]){ - jQuery.cookie("num_paragraph", numPar,{ path: '/'}); - }else{ - jQuery.removeCookie("num_paragraph", { path: '/'}); - } jQuery.cookie("search_path_code", 'exs',{ path: '/'}); [% ELSE %] jQuery.cookie("search_path_code", 'ads',{ path: '/'}); - jQuery.removeCookie("num_paragraph", { path: '/'}); [% END %] }); diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 67c11c182f3..e64b54a2367 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -312,50 +312,12 @@ if ( $template_type && $template_type eq 'advsearch' ) { $template->param( sort_by => $default_sort_by ); } - # determine what to display next to the search boxes (ie, boolean option - # shouldn't appear on the first one, scan indexes should, adding a new - # box should only appear on the last, etc. - my @search_boxes_array; - my $search_boxes_count = 3; # begin with 3 boxes - $template->param( search_boxes_count => $search_boxes_count ); - - if ($cgi->cookie("num_paragraph")){ - $search_boxes_count = $cgi->cookie("num_paragraph"); - } - - for (my $i=1;$i<=$search_boxes_count;$i++) { - # if it's the first one, don't display boolean option, but show scan indexes - if ($i==1) { - push @search_boxes_array, - { - scan_index => 1, - }; - - } - # if it's the last one, show the 'add field' box - elsif ($i==$search_boxes_count) { - push @search_boxes_array, - { - boolean => 1, - add_field => 1, - }; - } - else { - push @search_boxes_array, - { - boolean => 1, - }; - } - - } - my @advsearch_limits = split /,/, C4::Context->preference('OpacAdvSearchOptions'); my @advsearch_more_limits = split /,/, C4::Context->preference('OpacAdvSearchMoreOptions'); $template->param( uc( C4::Context->preference("marcflavour") ) => 1, # we already did this for UNIMARC advsearch => 1, - search_boxes_loop => \@search_boxes_array, OpacAdvSearchOptions => \@advsearch_limits, OpacAdvSearchMoreOptions => \@advsearch_more_limits, ); -- 2.20.1