From daaeb89bd8b22f4f003116ef21779e4cbaaf88e0 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Mon, 23 Jul 2018 12:25:58 +0200 Subject: [PATCH] Bug 21101: Allow to disable XSLT cache Koha::XSLT_Handler has a cache. When Plack is used, the XSLT display have a cache that can last several minutes. This is good for performance but bad for XSLT files edition. I propose a syspref to enable/disable this cache, enabled by default. Test plan : 1) Enable Plack 2) Check syspref XSLTCache is enabled 3) Define an XSLT file path in some XSLT display, ie OPACXSLTResultsDisplay 4) Perform a search and look at results 5) Edit XSLT file to add some text, for example next to title 6) Perform a search and look at results => The change is not there, you can try several refresh 7) Undo action 5) 2) Set syspref XSLTCache disabled 8) Perform a search and look at results => you see original display 9) Repeat action 5) 10) Perform a search and look at results => you see the change, you can try several refreshs --- C4/XSLT.pm | 5 +++++ .../atomicupdate/bug_2xxxx_add_XSLTCache_preference.perl | 9 +++++++++ .../prog/en/modules/admin/preferences/admin.pref | 7 +++++++ 3 files changed, 21 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_2xxxx_add_XSLTCache_preference.perl diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 6689aba469..e66298058c 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -350,6 +350,11 @@ Returns reference to XSLT handler object. =cut sub engine { + my $xsltcache = C4::Context->preference('XSLTCache') // 1; + unless ($xsltcache) { + # Do not use cache + $xslth->refresh(); + } return $xslth; } diff --git a/installer/data/mysql/atomicupdate/bug_2xxxx_add_XSLTCache_preference.perl b/installer/data/mysql/atomicupdate/bug_2xxxx_add_XSLTCache_preference.perl new file mode 100644 index 0000000000..b570059085 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_2xxxx_add_XSLTCache_preference.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) + VALUES ('XSLTCache','1',NULL,'Enable/disable XSLT cache','YesNo') + }); + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 2xxxx - Add XSLTCache system preference)\n"; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref index 2e8dce78da..c0114a8a0f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref @@ -65,6 +65,13 @@ Administration: choices: yes: "The logged-in library" no: "All libraries" + - + - "XSLT cache: " + - pref: XSLTCache + choices: + yes: "Enabled" + no: "Disabled" + - Disable for XSLT files edition and enable for better performance. Login options: - - "Inactivity timeout in seconds to automatically log out users: " -- 2.17.1