From 205a4736e3126ea075923eed0079744d1e35a885 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 19 Dec 2019 03:20:36 +0000 Subject: [PATCH] Bug 24272: add check_sysprefs_cache.pl This script ensure that no sysprefs have been changed directly in the database and/or that the cache has not become corrupted. We have occasionally seen this happen on production sites To test: 1 - In the staff interface go to Administration 2 - Search for system preference 'IntranetUserJS' 3 - Add content to the syspref: console.log('Hi!'); 4 - On the command line launch mysql sudo koha-mysql kohadev 5 - Alter the syspref directly UPDATE systempreferences SET value = "console.log('Bye!');" WHERE variable = 'IntranetUserJS'; 6 - run the script perl misc/maintenance/check_syspref_cache.pl 7 - You are warned about the altered system preference Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- misc/maintenance/check_syspref_cache.pl | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 misc/maintenance/check_syspref_cache.pl diff --git a/misc/maintenance/check_syspref_cache.pl b/misc/maintenance/check_syspref_cache.pl new file mode 100755 index 0000000000..809ecaae05 --- /dev/null +++ b/misc/maintenance/check_syspref_cache.pl @@ -0,0 +1,48 @@ +#! /usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Koha::Script; +use Koha::Caches; +use Koha::Config::SysPrefs; +use C4::Context; + +=head1 NAME + +check_syspref_cache.pl + +=head1 SYNOPSIS + + perl check_syspref_cache.pl + +=head1 DESCRIPTION + +Catch data inconsistencies in cached sysprefs vs those in the database + +=cut + + +my $syspref_cache = Koha::Caches->get_instance('syspref'); +my $prefs = Koha::Config::SysPrefs->search(); + +while (my $pref = $prefs->next) { + my $var = lc $pref->variable; + my $cached_var = $syspref_cache->get_from_cache("syspref_$var"); + next unless $cached_var; + print "$var: value in cache is $cached_var and value in db is ".$pref->value,"\n" unless $cached_var eq $pref->value; +} -- 2.20.1