Add a debug flag (DEBUG_NOCACHE = 256) to disable caching of DirEnums and other
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 30 Aug 2010 12:22:56 +0000 (14:22 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 30 Aug 2010 12:35:44 +0000 (14:35 +0200)
data in session.

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/direnum.php
classes/platalglobals.php.in
core
include/common.inc.php

index 1382019..567f4de 100644 (file)
@@ -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);
             }
         }
index 774a809..3f0085d 100644 (file)
@@ -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 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 85bb0c6fe8cca537d48c297476971cdac5a7065f
+Subproject commit 70ee734edd5ebc194feb24c32acb4ed23d055632
index 1634dc7..f93541d 100644 (file)
@@ -46,5 +46,6 @@ function __autoload($cls)
     }
 }
 
+
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
 ?>