Bug 11369: fix issue that can cause staff client searches to stop working
This patch fixes an issue where too many search cursor cookies overflow the HTTP-header size after making multiple searches in the staff client. To replicate this issue, make multiple searches in catalogue/search.pl. 50+ Should be enough to cause the HTTP-request header to overgrow. One can verify this issue by observing the searchCookie growth in browser's stored cookies. ------------- - TEST PLAN - ------------- Keep making searches. One should never have more than 10 searchCookies. Browser might display only 9, because for some reason the newest js-generated cookie is not included in Firefox's cookies listing. ------------ - DRAWBACK - ------------ Removing these cookies disables the search cursor for traversing search results (next/previous) for the removed cookie. This maybe be problematic in some cases, (for ex when multiple search tabs need to be open and they need to be traversed) One easy solution is to grow the amount of stored searchCookies from 10 to 20, but 10 is chosen so there will be plenty of room for other cookies as well. Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
35bec75d66
commit
0cada7a323
2 changed files with 22 additions and 2 deletions
|
@ -678,8 +678,15 @@ for (my $i=0;$i<@servers;$i++) {
|
|||
} #/end of the for loop
|
||||
#$template->param(FEDERATED_RESULTS => \@results_array);
|
||||
|
||||
$template->{'VARS'}->{'searchid'} = $cgi->param('searchid')
|
||||
|| String::Random::random_string('ssssssss');
|
||||
if ($cgi->param('searchid')) {
|
||||
$template->{'VARS'}->{'searchid'} = $cgi->param('searchid');
|
||||
}
|
||||
else {
|
||||
my $dt = DateTime->now(time_zone => 'local');
|
||||
#We are generating a clean numeric datetime representation so we can easily compare them using the default javascript lexigraphic sorter.
|
||||
$template->{'VARS'}->{'searchid'} = 'scs_'.$dt->ymd('').$dt->hms(''); #scs == Staff Client
|
||||
}
|
||||
|
||||
my $gotonumber = $cgi->param('gotoNumber');
|
||||
if ($gotonumber eq 'last' || $gotonumber eq 'first') {
|
||||
$template->{'VARS'}->{'gotoNumber'} = $gotonumber;
|
||||
|
|
|
@ -40,6 +40,19 @@ KOHA.browser = function (searchid, biblionumber) {
|
|||
pagelen: newresults.length,
|
||||
results: newresults
|
||||
};
|
||||
|
||||
//Bug_11369 Cleaning up excess searchCookies to prevent cookie overflow in the browser memory.
|
||||
var allVisibleCookieKeys = Object.keys( $.cookie() );
|
||||
var scsCookieKeys = $.grep( allVisibleCookieKeys,
|
||||
function(elementOfArray, indexInArray) {
|
||||
return ( elementOfArray.search(/^scs_\d/) != -1 ); //We are looking for specifically staff client searchCookies.
|
||||
}
|
||||
);
|
||||
if (scsCookieKeys.length >= 10) {
|
||||
scsCookieKeys.sort(); //Make sure they are in order, oldest first!
|
||||
$.removeCookie( scsCookieKeys[0], { path: '/' } );
|
||||
}
|
||||
//EO Bug_11369
|
||||
}
|
||||
$.cookie(me.searchid, JSON.stringify(me.searchCookie), { path: '/' });
|
||||
$(document).ready(function () {
|
||||
|
|
Loading…
Reference in a new issue