From a786f4b1c605751c9c6a95528b66f159db83b25b Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sun, 17 Jul 2011 22:26:21 -0430 Subject: [PATCH] Making DboSource::$methodCache a static variable to be able to share the cache between multiple instances of the same class --- lib/Cake/Model/Datasource/DboSource.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 17080bc7916..94ae7141275 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -62,7 +62,7 @@ class DboSource extends DataSource { * @var array * @access public */ - public $methodCache = array(); + public static $methodCache = array(); /** * Whether or not to cache the results of DboSource::name() and DboSource::conditions() @@ -753,7 +753,8 @@ public function field($name, $sql) { * @return void */ public function flushMethodCache() { - $this->methodCache = array(); + $this->_methodCacheChange = true; + self::$methodCache = array(); } /** @@ -772,14 +773,14 @@ public function cacheMethod($method, $key, $value = null) { if ($this->cacheMethods === false) { return $value; } - if (empty($this->methodCache)) { - $this->methodCache = Cache::read('method_cache', '_cake_core_'); + if (empty(self::$methodCache)) { + self::$methodCache = Cache::read('method_cache', '_cake_core_'); } if ($value === null) { - return (isset($this->methodCache[$method][$key])) ? $this->methodCache[$method][$key] : null; + return (isset(self::$methodCache[$method][$key])) ? self::$methodCache[$method][$key] : null; } $this->_methodCacheChange = true; - return $this->methodCache[$method][$key] = $value; + return self::$methodCache[$method][$key] = $value; } /**