mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Only load the object cache when requested.
Instead of loading a cache key that may not exist on every request, it should only be loaded when required. Fixes #3717
This commit is contained in:
parent
d1d3bcff04
commit
819029e1f3
1 changed files with 4 additions and 6 deletions
|
@ -425,6 +425,10 @@ class App {
|
|||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::objects
|
||||
*/
|
||||
public static function objects($type, $path = null, $cache = true) {
|
||||
if (empty(self::$_objects) && $cache === true) {
|
||||
self::$_objects = (array)Cache::read('object_map', '_cake_core_');
|
||||
}
|
||||
|
||||
$extension = '/\.php$/';
|
||||
$includeDirectories = false;
|
||||
$name = $type;
|
||||
|
@ -451,10 +455,6 @@ class App {
|
|||
$name = $type . str_replace(DS, '', $path);
|
||||
}
|
||||
|
||||
if (empty(self::$_objects) && $cache === true) {
|
||||
self::$_objects = Cache::read('object_map', '_cake_core_');
|
||||
}
|
||||
|
||||
$cacheLocation = empty($plugin) ? 'app' : $plugin;
|
||||
|
||||
if ($cache !== true || !isset(self::$_objects[$cacheLocation][$name])) {
|
||||
|
@ -768,7 +768,6 @@ class App {
|
|||
*/
|
||||
public static function init() {
|
||||
self::$_map += (array)Cache::read('file_map', '_cake_core_');
|
||||
self::$_objects += (array)Cache::read('object_map', '_cake_core_');
|
||||
register_shutdown_function(array('App', 'shutdown'));
|
||||
}
|
||||
|
||||
|
@ -896,7 +895,6 @@ class App {
|
|||
if (self::$_objectCacheChange) {
|
||||
Cache::write('object_map', self::$_objects, '_cake_core_');
|
||||
}
|
||||
|
||||
self::_checkFatalError();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue