From a8fda3ee047958c2c51f927b7cec9ef3edea54a4 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. Signed-off-by: Owen Leonard Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall (cherry picked from commit 18183bdf34d67e0a97b993ee06c996343c83cb84) Signed-off-by: Fridolin Somers --- .../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 44ea73af8d..fde64ce68b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -481,7 +481,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() { @@ -507,16 +506,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 f8dec66b04..cd0e0ae12a 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -325,50 +325,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.39.5