From ea9614d6ea06bccd97fa886c6721227788b77d7c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 17 Nov 2014 09:39:24 -0500 Subject: [PATCH] Bug 13265 - Still too many search cursor cookies We have multiple sites that are still exhibiting bug 11369. For whatever reason, the cookies on these sites are larger and thus the maximum of 10 is still too large. This setting should be controlled by a system preference to the number can be tailored on a per-site basis. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Set the new system preference MaxSearchCookies to a high number ( e.g. 20 ). 4) Perform searches until you get the error described in bug 11369 5) Delete your cookies so you can use the staff intranet again 5) Set the system preference to a much lower number ( e.g. 5 ) 6) Repeat setp 4, you should no longer get the error. --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 10 ++++++++++ koha-tmpl/intranet-tmpl/js/browser.js | 6 ++++-- .../en/modules/admin/preferences/cataloguing.pref | 5 +++++ .../prog/en/modules/catalogue/ISBDdetail.tt | 3 ++- .../prog/en/modules/catalogue/MARCdetail.tt | 3 ++- .../prog/en/modules/catalogue/detail.tt | 2 +- .../prog/en/modules/catalogue/labeledMARCdetail.tt | 3 ++- .../prog/en/modules/catalogue/moredetail.tt | 3 ++- .../prog/en/modules/catalogue/results.tt | 2 +- .../prog/en/modules/cataloguing/addbiblio.tt | 2 +- .../prog/en/modules/cataloguing/additem.tt | 3 ++- 12 files changed, 33 insertions(+), 10 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 097f609..7134d83 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -197,6 +197,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('MaxFine',NULL,'','Maximum fine a patron can have for all late returns at one moment. Single item caps are specified in the circulation rules matrix.','Integer'), ('MaxItemsForBatch','1000',NULL,'Max number of items record to process in a batch (modification or deletion)','Integer'), ('maxItemsInSearchResults','20',NULL,'Specify the maximum number of items to display for each result on a page of results','free'), +('MaxSearchCookies','10',NULL,'Defines the maximum number of search cookies to store in the browser.','Integer') ('maxoutstanding','5','','maximum amount withstanding to be able make holds','Integer'), ('maxRecordsForFacets','20',NULL,NULL,'Integer'), ('maxreserves','50','','Define maximum number of holds a patron can place','Integer'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 3542685..d3c4e49 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -9505,6 +9505,16 @@ CREATE TABLE borrower_sync ( SetVersion($DBversion); } +$DBversion = "3.17.00.XXX"; +if (CheckVersion($DBversion)) { + $dbh->do(q{ + INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES + ('MaxSearchCookies','10',NULL,'Defines the maximum number of search cookies to store in the browser.','Integer') + }); + print "Upgrade to $DBversion done (Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/js/browser.js b/koha-tmpl/intranet-tmpl/js/browser.js index b0676a5..2a4eb4c 100644 --- a/koha-tmpl/intranet-tmpl/js/browser.js +++ b/koha-tmpl/intranet-tmpl/js/browser.js @@ -1,6 +1,8 @@ if ( KOHA === undefined ) var KOHA = {}; -KOHA.browser = function (searchid, biblionumber) { +KOHA.browser = function (searchid, biblionumber, max_search_cookies) { + if (!max_search_cookies) max_search_cookies = 10; + var me = this; if (!searchid) { @@ -52,7 +54,7 @@ KOHA.browser = function (searchid, biblionumber) { return ( elementOfArray.search(/^scs_\d/) != -1 ); //We are looking for specifically staff client searchCookies. } ); - if (scsCookieKeys.length >= 10) { + if (scsCookieKeys.length >= max_search_cookies) { scsCookieKeys.sort(); //Make sure they are in order, oldest first! $.removeCookie( scsCookieKeys[0], { path: '/' } ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 157bfc8..1910a1a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -207,6 +207,11 @@ Cataloging: yes: Display no: "Don't display" - acquisition details on the biblio detail page. + - + - Allow a maximum of + - pref: MaxSearchCookies + class: Integer + - search history cookies to be stored. Importing: - - When matching on ISBN with the record import tool, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt index 1c61305..7a2d8f2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] Koha › Catalog › [% IF ( unknownbiblionumber ) %] @@ -14,7 +15,7 @@ <script type="text/javascript" src="[% interface %]/js/browser.js"></script> <script type="text/javascript"> //<![CDATA[ - var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10)); + var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10), '[% Koha.Preference("MaxSearchCookies") %]' ); browser.show(); //]]> </script> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt index 698c960..7c2e778 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Catalog › [% IF ( unknownbiblionumber ) %] @@ -14,7 +15,7 @@ <script type="text/javascript" src="[% interface %]/js/browser.js"></script> <script type="text/javascript"> //<![CDATA[ - var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10)); + var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10), '[% Koha.Preference("MaxSearchCookies") %]' ); browser.show(); $(document).ready(function() { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index efd1dc4..32a225f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -192,7 +192,7 @@ function verify_images() { <script type="text/javascript" src="[% interface %]/js/browser.js"></script> <script type="text/javascript"> //<![CDATA[ - var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10)); + var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10), '[% Koha.Preference("MaxSearchCookies") %]' ); browser.show(); function activate_filters(id) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt index 957f6ce..c9edc94 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Catalog › @@ -17,7 +18,7 @@ <script type="text/javascript" src="[% interface %]/js/browser.js"></script> <script type="text/javascript"> //<![CDATA[ - var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10)); + var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10), '[% Koha.Preference("MaxSearchCookies") %]' ); browser.show(); function Changefwk(FwkList) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt index 1ddc952..e507c03 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Catalog › Item details for [% title %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield %][% END %] [% INCLUDE 'doc-head-close.inc' %] @@ -9,7 +10,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 9462fa1..d6bf5d9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -139,7 +139,7 @@ $('#sort_by').change(function() { [%- result.biblionumber %], [%- END -%] ]; - var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10)); + var browser = KOHA.browser('[% searchid %]', parseInt('[% biblionumber %]', 10), '[% Koha.Preference("MaxSearchCookies") %]' ); browser.create([% SEARCH_RESULTS.first.result_number %], '[% query_cgi | uri %]', '[% limit_cgi | uri %]','[% sort_cgi | uri %]', newresults, '[% total %]'); [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 26e3b62..6475527 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -11,7 +11,7 @@