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) {
|
if ($session instanceof Session) {
|
||||||
// Note: If passing $session as object, ensure that changes are written back
|
// 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
|
// 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) {
|
$finally[] = function () use ($session, $sessionArray) {
|
||||||
if (isset($_SESSION)) {
|
if (isset($_SESSION)) {
|
||||||
// Set new / updated keys
|
// Set new / updated keys
|
||||||
|
@ -330,9 +330,9 @@ class Session
|
|||||||
$this->recursivelyApply((array)$this->data, $data);
|
$this->recursivelyApply((array)$this->data, $data);
|
||||||
} else {
|
} else {
|
||||||
// Use in-memory data if the session is lazy started
|
// 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 {
|
} else {
|
||||||
$this->data = [];
|
$this->data = [];
|
||||||
}
|
}
|
||||||
@ -615,6 +615,7 @@ class Session
|
|||||||
*/
|
*/
|
||||||
protected function recursivelyApplyChanges($changes, $source, &$destination)
|
protected function recursivelyApplyChanges($changes, $source, &$destination)
|
||||||
{
|
{
|
||||||
|
$source = $source ?: [];
|
||||||
foreach ($changes as $key => $changed) {
|
foreach ($changes as $key => $changed) {
|
||||||
if ($changed === true) {
|
if ($changed === true) {
|
||||||
// Determine if replacement or removal
|
// Determine if replacement or removal
|
||||||
|
Loading…
Reference in New Issue
Block a user