[Koha-patches] [PATCH 1/1] Bug 2775: adding method to clean syspref cache in C4::Context
Andrew Moore
andrew.moore at liblime.com
Tue Nov 11 21:34:13 CET 2008
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.
---
C4/Context.pm | 14 ++++++++++++++
C4/Installer.pm | 1 +
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/C4/Context.pm b/C4/Context.pm
index e3be714..4873ed7 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 1dc13aa..caeb2ff 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
--
1.5.6
More information about the Koha-patches
mailing list