diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index de3a4e90cff..208d6ba9d4b 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -69,7 +69,6 @@ private static function init() { include_once CONFIGS . 'database.php'; if (class_exists('DATABASE_CONFIG')) { self::$config = new DATABASE_CONFIG(); - self::_getConnectionObjects(); } register_shutdown_function('ConnectionManager::shutdown'); self::$_init = true; @@ -91,11 +90,16 @@ public static function getDataSource($name) { return $return; } + if (empty(self::$_connectionsEnum[$name])) { + self::_getConnectionObject($name); + } + if (empty(self::$_connectionsEnum[$name])) { trigger_error(__("ConnectionManager::getDataSource - Non-existent data source %s", $name), E_USER_ERROR); $null = null; return $null; } + $conn = self::$_connectionsEnum[$name]; $class = $conn['classname']; @@ -222,13 +226,9 @@ public static function create($name = '', $config = array()) { * * @return void */ - protected static function _getConnectionObjects() { - $connections = get_object_vars(self::$config); - - if ($connections != null) { - foreach ($connections as $name => $config) { - self::$_connectionsEnum[$name] = self::_connectionData($config); - } + protected static function _getConnectionObject($name) { + if (!empty(self::$config->{$name})) { + self::$_connectionsEnum[$name] = self::_connectionData(self::$config->{$name}); } else { throw new MissingConnectionException(array('class' => 'ConnectionManager')); } diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index fd67272ad24..58915338368 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -559,10 +559,7 @@ protected static function _configureSession() { */ protected static function _getHandler($handler) { list($plugin, $class) = pluginSplit($handler, true); - $found = App::import('Lib', $plugin . 'session/' . $class); - if (!$found) { - App::import('Core', 'session/' . $class); - } + App::uses($class, $plugin . 'Model/Datasource/Session'); if (!class_exists($class)) { throw new Exception(__('Could not load %s to handle the session.', $class)); } diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index e4a50b4c2f3..817e00cf1ca 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -18,6 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('DboSource', 'Model/Datasource'); + /** * DBO implementation for the SQLite3 DBMS. * @@ -26,7 +28,7 @@ * @package datasources * @subpackage cake.cake.libs.model.datasources.dbo */ -class DboSqlite extends DboSource { +class Sqlite extends DboSource { /** * Datasource Description diff --git a/lib/Cake/Utility/File.php b/lib/Cake/Utility/File.php index 66300484080..2d9e268d752 100644 --- a/lib/Cake/Utility/File.php +++ b/lib/Cake/Utility/File.php @@ -22,9 +22,7 @@ * Included libraries. * */ -if (!class_exists('Folder')) { - require LIBS . 'folder.php'; -} +App::uses('File', 'Utility'); /** * Convenience class for reading, writing and appending to files. diff --git a/lib/Cake/View/pages/home.ctp b/lib/Cake/View/pages/home.ctp index 95ead2a1848..81a6d58181d 100644 --- a/lib/Cake/View/pages/home.ctp +++ b/lib/Cake/View/pages/home.ctp @@ -72,7 +72,7 @@ endif; ?>

'; __('PCRE has not been compiled with Unicode support.'); @@ -83,15 +83,12 @@ endif; ?> getDataSource('default'); + App::uses('ConnectionManager', 'Model'); + $connected = ConnectionManager::getDataSource('default'); ?>

isConnected()): + if ($connected && $connected->isConnected()): echo ''; echo __('Cake is able to connect to the database.'); echo '';