Permalink
Browse files

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
  • Loading branch information...
1 parent d1d3bcf commit 819029e1f3235c075e688af53845021f742007ab @markstory markstory committed Mar 21, 2013
Showing with 4 additions and 6 deletions.
  1. +4 −6 lib/Cake/Core/App.php
View
@@ -425,6 +425,10 @@ public static function core($type) {
* @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 @@ public static function objects($type, $path = null, $cache = true) {
$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 @@ protected static function _loadVendor($name, $plugin, $file, $ext) {
*/
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 @@ public static function shutdown() {
if (self::$_objectCacheChange) {
Cache::write('object_map', self::$_objects, '_cake_core_');
}
-
self::_checkFatalError();
}

0 comments on commit 819029e

Please sign in to comment.