mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Fix Director::test() not persisting removed session keys on teardown
This commit is contained in:
parent
e7e32d13a3
commit
5bff64b47b
@ -207,12 +207,17 @@ 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'] = $session->getAll();
|
||||
$finally[] = function () use ($session) {
|
||||
$newVars['_SESSION'] = $sessionArray = $session->getAll();
|
||||
$finally[] = function () use ($session, $sessionArray) {
|
||||
if (isset($_SESSION)) {
|
||||
// Set new / updated keys
|
||||
foreach ($_SESSION as $key => $value) {
|
||||
$session->set($key, $value);
|
||||
}
|
||||
// Unset removed keys
|
||||
foreach (array_diff_key($sessionArray, $_SESSION) as $key => $value) {
|
||||
$session->clear($key);
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user