mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +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;
|
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.
|
* Holds key/value pairs of $type => file path.
|
||||||
*
|
*
|
||||||
|
@ -836,7 +828,7 @@ class App extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cache === true) {
|
if ($cache === true) {
|
||||||
$_this->__cache = true;
|
$_this->__resetCache(true);
|
||||||
}
|
}
|
||||||
$_this->__objects[$name] = $objects;
|
$_this->__objects[$name] = $objects;
|
||||||
}
|
}
|
||||||
|
@ -932,7 +924,7 @@ class App extends Object {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$_this->__remove($name . $ext['class'], $type, $plugin);
|
$_this->__remove($name . $ext['class'], $type, $plugin);
|
||||||
$_this->__cache = true;
|
$_this->__resetCache(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($search)) {
|
if (!empty($search)) {
|
||||||
|
@ -963,7 +955,7 @@ class App extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($directory !== null) {
|
if ($directory !== null) {
|
||||||
$_this->__cache = true;
|
$_this->__resetCache(true);
|
||||||
$_this->__map($directory . $file, $name . $ext['class'], $type, $plugin);
|
$_this->__map($directory . $file, $name . $ext['class'], $type, $plugin);
|
||||||
$_this->__overload($type, $name . $ext['class'], $parent);
|
$_this->__overload($type, $name . $ext['class'], $parent);
|
||||||
|
|
||||||
|
@ -1292,6 +1284,21 @@ class App extends Object {
|
||||||
}
|
}
|
||||||
return $items;
|
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.
|
* Object destructor.
|
||||||
|
@ -1302,7 +1309,7 @@ class App extends Object {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
if ($this->__cache) {
|
if ($this->__resetCache() === true) {
|
||||||
$core = App::core('cake');
|
$core = App::core('cake');
|
||||||
unset($this->__paths[rtrim($core[0], DS)]);
|
unset($this->__paths[rtrim($core[0], DS)]);
|
||||||
Cache::write('dir_map', array_filter($this->__paths), '_cake_core_');
|
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_');
|
Cache::write('object_map', $this->__objects, '_cake_core_');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue