mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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 (from r111772) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112920 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
dd92459517
commit
d328c7cc53
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user