mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02: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()) {
|
if (Director::is_cli()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Skip if there's no request object yet
|
||||||
if (!Injector::inst()->has(HTTPRequest::class)) {
|
if (!Injector::inst()->has(HTTPRequest::class)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/** @var HTTPRequest $request */
|
/** @var HTTPRequest $request */
|
||||||
$request = Injector::inst()->get(HTTPRequest::class);
|
$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);
|
$name = $request->getSession()->get(self::ALT_DB_KEY);
|
||||||
if (self::valid_alternative_database_name($name)) {
|
if (self::valid_alternative_database_name($name)) {
|
||||||
return $name;
|
return $name;
|
||||||
|
Loading…
Reference in New Issue
Block a user