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:
mark_story 2013-03-20 21:26:42 -04:00
parent d1d3bcff04
commit 819029e1f3

View file

@ -425,6 +425,10 @@ class App {
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::objects * @link http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::objects
*/ */
public static function objects($type, $path = null, $cache = true) { 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$/'; $extension = '/\.php$/';
$includeDirectories = false; $includeDirectories = false;
$name = $type; $name = $type;
@ -451,10 +455,6 @@ class App {
$name = $type . str_replace(DS, '', $path); $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; $cacheLocation = empty($plugin) ? 'app' : $plugin;
if ($cache !== true || !isset(self::$_objects[$cacheLocation][$name])) { if ($cache !== true || !isset(self::$_objects[$cacheLocation][$name])) {
@ -768,7 +768,6 @@ class App {
*/ */
public static function init() { public static function init() {
self::$_map += (array)Cache::read('file_map', '_cake_core_'); self::$_map += (array)Cache::read('file_map', '_cake_core_');
self::$_objects += (array)Cache::read('object_map', '_cake_core_');
register_shutdown_function(array('App', 'shutdown')); register_shutdown_function(array('App', 'shutdown'));
} }
@ -896,7 +895,6 @@ class App {
if (self::$_objectCacheChange) { if (self::$_objectCacheChange) {
Cache::write('object_map', self::$_objects, '_cake_core_'); Cache::write('object_map', self::$_objects, '_cake_core_');
} }
self::_checkFatalError(); self::_checkFatalError();
} }