Fix tests on unset session data

Thanks Robbie!
This commit is contained in:
Ingo Schommer 2018-07-18 21:15:56 +12:00 committed by Daniel Hensby
parent 76ac8465de
commit 74b655d3fc
No known key found for this signature in database
GPG Key ID: D8DEBC4C8E7BC8B9
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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