mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fix tests on unset session data
Thanks Robbie!
This commit is contained in:
parent
76ac8465de
commit
74b655d3fc
@ -206,7 +206,7 @@ class Director implements TemplateGlobalProvider
|
||||
if ($session instanceof Session) {
|
||||
// Note: If passing $session as object, ensure that changes are written back
|
||||
// This is important for classes such as FunctionalTest which emulate cross-request persistence
|
||||
$newVars['_SESSION'] = $sessionArray = $session->getAll();
|
||||
$newVars['_SESSION'] = $sessionArray = $session->getAll() ?: [];
|
||||
$finally[] = function () use ($session, $sessionArray) {
|
||||
if (isset($_SESSION)) {
|
||||
// Set new / updated keys
|
||||
|
@ -262,8 +262,8 @@ class Session
|
||||
public function requestContainsSessionId(HTTPRequest $request)
|
||||
{
|
||||
$secure = Director::is_https($request) && $this->config()->get('cookie_secure');
|
||||
$name = $secure ? $this->config()->get('cookie_name_secure') : session_name();
|
||||
return (bool)Cookie::get($name);
|
||||
$name = $secure ? $this->config()->get('cookie_name_secure') : session_name();
|
||||
return (bool)Cookie::get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,9 +330,9 @@ class Session
|
||||
$this->recursivelyApply((array)$this->data, $data);
|
||||
} else {
|
||||
// Use in-memory data if the session is lazy started
|
||||
$data = isset($this->data) ? $this->data : [];
|
||||
$data = $this->data;
|
||||
}
|
||||
$this->data = $data;
|
||||
$this->data = $data ?: [];
|
||||
} else {
|
||||
$this->data = [];
|
||||
}
|
||||
@ -615,6 +615,7 @@ class Session
|
||||
*/
|
||||
protected function recursivelyApplyChanges($changes, $source, &$destination)
|
||||
{
|
||||
$source = $source ?: [];
|
||||
foreach ($changes as $key => $changed) {
|
||||
if ($changed === true) {
|
||||
// Determine if replacement or removal
|
||||
|
Loading…
Reference in New Issue
Block a user