From d065e209aef35dd8028aad4173f9c9b06093f212 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/atomicupdate/bug_13265.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + 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, 24 insertions(+), 10 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_13265.sql diff --git a/installer/data/mysql/atomicupdate/bug_13265.sql b/installer/data/mysql/atomicupdate/bug_13265.sql new file mode 100644 index 0000000..b6bde5a --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_13265.sql @@ -0,0 +1 @@ +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'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 878214f..1fbe295 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -201,6 +201,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/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 bc35aad..778d04b 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 a392e1a..29cbe6f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -207,7 +207,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 785da66..0fb71e4 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 %]', '[% 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 c530ce0..a23407c 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 @@