Permalink
Browse files

Removing __cache property that can be altered outside of the class de…

…finition.

Adding __resetCache() as a replacement for checking if cache should be reset and written.
  • Loading branch information...
1 parent 5349257 commit bed7767258969698b04dcd31ad98f0f70b9938fb @phpnut phpnut committed Nov 17, 2010
Showing with 20 additions and 13 deletions.
  1. +20 −13 cake/libs/configure.php
View
@@ -579,14 +579,6 @@ class App extends Object {
*/
var $return = false;
-/**
- * Determines if $__maps and $__paths cache should be written.
- *
- * @var boolean
- * @access private
- */
- var $__cache = false;
-
/**
* Holds key/value pairs of $type => file path.
*
@@ -836,7 +828,7 @@ function objects($type, $path = null, $cache = true) {
}
if ($cache === true) {
- $_this->__cache = true;
+ $_this->__resetCache(true);
}
$_this->__objects[$name] = $objects;
}
@@ -932,7 +924,7 @@ function import($type = null, $name = null, $parent = true, $search = array(), $
return true;
} else {
$_this->__remove($name . $ext['class'], $type, $plugin);
- $_this->__cache = true;
+ $_this->__resetCache(true);
}
}
if (!empty($search)) {
@@ -963,7 +955,7 @@ function import($type = null, $name = null, $parent = true, $search = array(), $
}
if ($directory !== null) {
- $_this->__cache = true;
+ $_this->__resetCache(true);
$_this->__map($directory . $file, $name . $ext['class'], $type, $plugin);
$_this->__overload($type, $name . $ext['class'], $parent);
@@ -1292,6 +1284,21 @@ function __list($path, $suffix = false, $extension = false) {
}
return $items;
}
+
+/**
+ * Determines if $__maps and $__paths cache should be reset.
+ *
+ * @param boolean $reset
+ * @return boolean
+ * @access private
+ */
+ function __resetCache($reset = null) {
+ static $cache = array();
+ if (!$cache && $reset === true) {
+ $cache = true;
+ }
+ return $cache;
+ }
/**
* Object destructor.
@@ -1302,12 +1309,12 @@ function __list($path, $suffix = false, $extension = false) {
* @access private
*/
function __destruct() {
- if ($this->__cache) {
+ if ($this->__resetCache() === true) {
$core = App::core('cake');
unset($this->__paths[rtrim($core[0], DS)]);
Cache::write('dir_map', array_filter($this->__paths), '_cake_core_');
Cache::write('file_map', array_filter($this->__map), '_cake_core_');
Cache::write('object_map', $this->__objects, '_cake_core_');
}
}
-}
+}

0 comments on commit bed7767

Please sign in to comment.