BUGFIX DB::connect() should not rely on $_SESSION existing, so we check isset() to supress any warnings of undefined indexes

MINOR Code formatting tidy of DB::connect() function


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@111772 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2010-10-07 01:25:36 +00:00 committed by Sam Minnee
parent a9d752b344
commit 10f8318e32

View File

@ -83,12 +83,14 @@ class DB {
*/
static function connect($databaseConfig) {
// This is used by TestRunner::startsession() to test up a test session using an alt
if(isset($_SESSION["alternativeDatabaseName"]) && $dbname = $_SESSION["alternativeDatabaseName"]) $databaseConfig['database'] = $dbname;
if(isset($_SESSION) && !empty($_SESSION['alternativeDatabaseName'])) {
$databaseConfig['database'] = $_SESSION['alternativeDatabaseName'];
}
if(!isset($databaseConfig['type']) || empty($databaseConfig['type'])) {
user_error("DB::connect: Not passed a valid database config", E_USER_ERROR);
}
self::$connection_attempted = true;
$dbClass = $databaseConfig['type'];
@ -332,5 +334,4 @@ class DB {
return self::getConn()->alterationMessage($message, $type);
}
}
?>
}