Skip to content

Commit

Permalink
Lazy loading objects and file map once it should not be used anymore …
Browse files Browse the repository at this point in the history
…in most of the requests
  • Loading branch information
jrbasso committed Jun 24, 2012
1 parent e99dbee commit beb66e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
20 changes: 5 additions & 15 deletions lib/Cake/Core/App.php
Expand Up @@ -157,14 +157,6 @@ class App {
*/
protected static $_objectCacheChange = false;

/**
* Indicates the the Application is in the bootstrapping process. Used to better cache
* loaded classes while the cache libraries have not been yet initialized
*
* @var boolean
*/

This comment has been minimized.

Copy link
@lorenzo

lorenzo Jul 2, 2012

Member

What's the actual reason for removing this feature?

This comment has been minimized.

Copy link
@jrbasso

jrbasso via email Jul 2, 2012

Author Member
public static $bootstrapping = false;

/**
* Return the classname namespaced. This method check if the class is defined on the
* application/plugin, otherwise try to load from the CakePHP core
Expand Down Expand Up @@ -430,7 +422,7 @@ public static function objects($type, $path = null, $cache = true) {
}

if (empty(static::$_objects) && $cache === true) {
static::$_objects = Cache::read('object_map', '_cake_core_');
static::$_objects = (array)Cache::read('object_map', '_cake_core_');
}

$cacheLocation = empty($plugin) ? 'app' : $plugin;
Expand Down Expand Up @@ -492,6 +484,9 @@ public static function load($className) {
if (!isset(static::$_classMap[$className])) {
return false;
}
if (empty(static::$_map)) {
static::$_map = (array)Cache::read('file_map', '_cake_core_');
}

$parts = explode('.', static::$_classMap[$className], 2);
list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts));
Expand Down Expand Up @@ -539,16 +534,14 @@ public static function location($className) {
}

/**
* Initializes the cache for App, registers a shutdown function.
* Initializes the App, registers a shutdown function.
*
* @return void
*/
public static function init() {
$loader = new ClassLoader(Configure::read('App.namespace'), dirname(APP));
$loader->register();

static::$_map += (array)Cache::read('file_map', '_cake_core_');
static::$_objects += (array)Cache::read('object_map', '_cake_core_');
register_shutdown_function(array(__CLASS__, 'shutdown'));
}

Expand All @@ -571,9 +564,6 @@ protected static function _map($file, $name, $plugin = null) {
if (!$plugin && empty(static::$_map['plugin.' . $name])) {
static::$_map[$key] = $file;
}
if (!static::$bootstrapping) {
static::$_cacheChange = true;
}
}

/**
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Core/Configure.php
Expand Up @@ -77,7 +77,6 @@ public static function bootstrap($boot = true) {
if (!include APP . 'Config' . DS . 'core.php') {
trigger_error(__d('cake_dev', "Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", APP . 'Config' . DS), E_USER_ERROR);
}
App::$bootstrapping = false;
App::init();
App::build();

Expand Down
2 changes: 0 additions & 2 deletions lib/Cake/bootstrap.php
Expand Up @@ -127,10 +127,8 @@
use Cake\Core\App;
use Cake\Core\Configure;

App::$bootstrapping = true;
Configure::bootstrap(isset($boot) ? $boot : true);


/**
* Full url prefix
*/
Expand Down

0 comments on commit beb66e4

Please sign in to comment.