mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #7308 from creative-commoners/pulls/4.0/fix-alternative-db-name-when-session-not-started
FIX Do not try and access sessions when they are not ready
This commit is contained in:
commit
d52e972453
@ -233,11 +233,17 @@ class DB
|
||||
if (Director::is_cli()) {
|
||||
return false;
|
||||
}
|
||||
// Skip if there's no request object yet
|
||||
if (!Injector::inst()->has(HTTPRequest::class)) {
|
||||
return null;
|
||||
}
|
||||
/** @var HTTPRequest $request */
|
||||
$request = Injector::inst()->get(HTTPRequest::class);
|
||||
// Skip if the session hasn't been started
|
||||
if (!$request->getSession()->isStarted()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$name = $request->getSession()->get(self::ALT_DB_KEY);
|
||||
if (self::valid_alternative_database_name($name)) {
|
||||
return $name;
|
||||
|
Loading…
x
Reference in New Issue
Block a user