From 5b98acfa0f374d63fde4ceb3b6e7a288d3745fe4 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Mon, 30 Aug 2010 14:22:56 +0200 Subject: [PATCH] Add a debug flag (DEBUG_NOCACHE = 256) to disable caching of DirEnums and other data in session. Signed-off-by: Florent Bruneau --- classes/direnum.php | 5 +++-- classes/platalglobals.php.in | 8 +++++++- core | 2 +- include/common.inc.php | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/classes/direnum.php b/classes/direnum.php index 1382019..567f4de 100644 --- a/classes/direnum.php +++ b/classes/direnum.php @@ -61,13 +61,14 @@ class DirEnum static private function init($type) { - if (S::has('__DE_' . $type)) { + if (Platal::globals()->cacheEnabled() && S::has('__DE_' . $type)) { self::$enumerations[$type] = S::v('__DE_' . $type); } else { $cls = "DE_" . ucfirst($type); $obj = new $cls(); self::$enumerations[$type] = $obj; - if ($obj->capabilities & DirEnumeration::SAVE_IN_SESSION) { + if (Platal::globals()->cacheEnabled() + && $obj->capabilities & DirEnumeration::SAVE_IN_SESSION) { S::set('__DE_' . $type, $obj); } } diff --git a/classes/platalglobals.php.in b/classes/platalglobals.php.in index 774a809..3f0085d 100644 --- a/classes/platalglobals.php.in +++ b/classes/platalglobals.php.in @@ -21,6 +21,8 @@ class PlatalGlobals extends PlGlobals { + const DEBUG_NOCACHE = DEBUG_USERBASE; + /** The x.org version */ public $version = '@VERSION@'; @@ -88,8 +90,12 @@ class PlatalGlobals extends PlGlobals FROM requests"); $this->changeDynamicConfig(array('NbValid' => $res->fetchOneCell())); } -} + public function cacheEnabled() + { + return ($this->debug & self::DEBUG_NOCACHE) == 0; + } +} /****************************************************************************** * Dynamic configuration update/edition stuff diff --git a/core b/core index 85bb0c6..70ee734 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 85bb0c6fe8cca537d48c297476971cdac5a7065f +Subproject commit 70ee734edd5ebc194feb24c32acb4ed23d055632 diff --git a/include/common.inc.php b/include/common.inc.php index 1634dc7..f93541d 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -46,5 +46,6 @@ function __autoload($cls) } } + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?> -- 2.1.4