Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG Using Session::set() for DB::set_alternative_database_name()

Setting session directly through $_SESSION relies on
session_autostart which might not be set on every environment,
and isn't consistent with other framework use.
  • Loading branch information...
commit 35da873ad9f79d7893a6894a66afa84ce39b21c5 1 parent 574c53d
@chillu chillu authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 model/DB.php
View
8 model/DB.php
@@ -65,14 +65,14 @@ public static function getConn($name = 'default') {
* Set it to null to revert to the main database.
*/
public static function set_alternative_database_name($dbname) {
- $_SESSION["alternativeDatabaseName"] = $dbname;
+ Session::set("alternativeDatabaseName", $dbname);
}
/**
* Get the name of the database in use
*/
public static function get_alternative_database_name() {
- return $_SESSION["alternativeDatabaseName"];
+ return Session::get("alternativeDatabaseName");
}
/**
@@ -84,8 +84,8 @@ public static function get_alternative_database_name() {
*/
public static function connect($databaseConfig) {
// This is used by TestRunner::startsession() to test up a test session using an alt
- if(isset($_SESSION) && !empty($_SESSION['alternativeDatabaseName'])) {
- $databaseConfig['database'] = $_SESSION['alternativeDatabaseName'];
+ if($name = Session::get('alternativeDatabaseName')) {
+ $databaseConfig['database'] = $name;
}
if(!isset($databaseConfig['type']) || empty($databaseConfig['type'])) {
Please sign in to comment.
Something went wrong with that request. Please try again.