From ca4ee0c56206c57df4156029e0857036b8617de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 9 Jan 2011 00:01:44 -0430 Subject: [PATCH] Caching plugin objects in App::objects() --- lib/Cake/Core/App.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 86f0a55a173..fdccbeef43d 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -411,7 +411,7 @@ public static function core($type = null) { * `App::objects('plugin');` returns `array('DebugKit', 'Blog', 'User');` * * You can also search only within a plugin's objects by using the plugin dot - * syntax (these objects are not cached): + * syntax. * * `App::objects('MyPlugin.model');` returns `array('Post', 'Comment');` * @@ -453,7 +453,9 @@ public static function objects($type, $path = null, $cache = true) { self::$__objects = Cache::read('object_map', '_cake_core_'); } - if (!isset(self::$__objects[$name]) || $cache !== true) { + $cacheLocation = empty($plugin) ? 'app' : $plugin; + + if ($cache !== true || !isset(self::$__objects[$cacheLocation][$name])) { $objects = array(); if (empty($path)) { @@ -484,11 +486,11 @@ public static function objects($type, $path = null, $cache = true) { if ($plugin) { return $objects; } - self::$__objects[$name] = $objects; + self::$__objects[$cacheLocation][$name] = $objects; self::$_objectCacheChange = true; } - return self::$__objects[$name]; + return self::$__objects[$cacheLocation][$name]; } /**