Skip to content
Permalink
Browse files

FIX Do not try and access sessions when they are not ready

  • Loading branch information
robbieaverill committed Aug 24, 2017
1 parent deec9b4 commit 5a9131a1165ce59b99b62a67fedceca28d381df9
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/ORM/DB.php
@@ -233,11 +233,17 @@ public static function get_alternative_database_name()
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;

0 comments on commit 5a9131a

Please sign in to comment.
You can’t perform that action at this time.