From dc73ef953b7832a6a784324556c5eefb01cad100 Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Tue, 11 Nov 2008 14:34:13 -0600 Subject: [PATCH] Bug 2775: adding method to clean syspref cache in C4::Context C4::Installer provides a way to update the kohaversion syspref. Now that C4::Context caches syspref values, any updated value through C4::Installer is not being seen. This patch adds a method to C4::Context to allow you to clean that cache. Then, it calls that method when the kohaversion syspref is changed. Signed-off-by: Galen Charlton --- C4/Context.pm | 14 ++++++++++++++ C4/Installer.pm | 1 + 2 files changed, 15 insertions(+) diff --git a/C4/Context.pm b/C4/Context.pm index e3be714d4a..4873ed70b8 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -494,6 +494,20 @@ sub boolean_preference ($) { return defined($it)? C4::Boolean::true_p($it): undef; } +=head3 clear_syspref_cache + + C4::Context->clear_syspref_cache(); + + cleans the internal cache of sysprefs. Please call this method if + you update the systempreferences table. Otherwise, your new changes + will not be seen by this process. + +=cut + +sub clear_syspref_cache { + %sysprefs = (); +} + # AUTOLOAD # This implements C4::Config->foo, and simply returns # C4::Context->config("foo"), as described in the documentation for diff --git a/C4/Installer.pm b/C4/Installer.pm index 1dc13aab54..caeb2ff87b 100644 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -517,6 +517,7 @@ sub set_version_syspref { my $finish=$self->{'dbh'}->prepare("INSERT into systempreferences (variable,value,explanation) values ('Version',?,'The Koha database version. WARNING: Do not change this value manually, it is maintained by the webinstaller')"); $finish->execute($kohaversion); } + C4::Context->clear_syspref_cache(); } =head2 load_sql -- 2.39.5