Permalink
Browse files

Avoid unnecessary calls to ConnectionManager::enumConnectionObjects()…

… in ClassRegistry::init().

Closes #3724
  • Loading branch information...
ADmad committed Mar 27, 2013
1 parent 342bf65 commit 733116d15d22602aecc129b4e170978971dd14ff
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/Cake/Utility/ClassRegistry.php
@@ -109,7 +109,7 @@ public static function init($class, $strict = false) {
$defaults = $_this->_config['Model']; $defaults = $_this->_config['Model'];
} }
$count = count($objects); $count = count($objects);
$availableDs = array_keys(ConnectionManager::enumConnectionObjects()); $availableDs = null;
foreach ($objects as $settings) { foreach ($objects as $settings) {
if (is_numeric($settings)) { if (is_numeric($settings)) {
@@ -153,6 +153,9 @@ public static function init($class, $strict = false) {
$defaultProperties = $reflection->getDefaultProperties(); $defaultProperties = $reflection->getDefaultProperties();
if (isset($defaultProperties['useDbConfig'])) { if (isset($defaultProperties['useDbConfig'])) {
$useDbConfig = $defaultProperties['useDbConfig']; $useDbConfig = $defaultProperties['useDbConfig'];
if ($availableDs === null) {
$availableDs = array_keys(ConnectionManager::enumConnectionObjects());
}
if (in_array('test_' . $useDbConfig, $availableDs)) { if (in_array('test_' . $useDbConfig, $availableDs)) {
$useDbConfig = 'test_' . $useDbConfig; $useDbConfig = 'test_' . $useDbConfig;
} }

0 comments on commit 733116d

Please sign in to comment.