mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing __cache property that can be altered outside of the class definition.
Adding __resetCache() as a replacement for checking if cache should be reset and written.
This commit is contained in:
parent
5349257bbd
commit
bed7767258
1 changed files with 20 additions and 13 deletions
|
@ -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 @@ class App extends Object {
|
|||
}
|
||||
|
||||
if ($cache === true) {
|
||||
$_this->__cache = true;
|
||||
$_this->__resetCache(true);
|
||||
}
|
||||
$_this->__objects[$name] = $objects;
|
||||
}
|
||||
|
@ -932,7 +924,7 @@ class App extends Object {
|
|||
return true;
|
||||
} else {
|
||||
$_this->__remove($name . $ext['class'], $type, $plugin);
|
||||
$_this->__cache = true;
|
||||
$_this->__resetCache(true);
|
||||
}
|
||||
}
|
||||
if (!empty($search)) {
|
||||
|
@ -963,7 +955,7 @@ class App extends Object {
|
|||
}
|
||||
|
||||
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 @@ class App extends Object {
|
|||
}
|
||||
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,7 +1309,7 @@ class App extends Object {
|
|||
* @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_');
|
||||
|
@ -1310,4 +1317,4 @@ class App extends Object {
|
|||
Cache::write('object_map', $this->__objects, '_cake_core_');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue