Skip to content

Commit f096ac1

Browse files
mabardg
authored andcommitted
SessionExtension: don't set readAndClose if null (#213)
Session class throws exception if session is started and option read_and_close is set. SessionExtension breaks compatibility with other session implementations (in case they already started the session) by always setting that option (to default value).
1 parent d6ef402 commit f096ac1

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/Bridges/HttpDI/SessionExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ public function loadConfiguration()
9191
$options['autoStart'] = false;
9292
}
9393

94+
if ($config->readAndClose === null) {
95+
unset($options['readAndClose']);
96+
}
97+
9498
if (!empty($options)) {
9599
$session->addSetup('setOptions', [$options]);
96100
}

src/Http/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ public function setOptions(array $options)
405405
$normalized[$normKey] = $value;
406406
}
407407

408-
if (array_key_exists('read_and_close', $normalized)) {
408+
if (isset($normalized['read_and_close'])) {
409409
if (session_status() === PHP_SESSION_ACTIVE) {
410410
throw new Nette\InvalidStateException('Cannot configure "read_and_close" for already started session.');
411411
}

0 commit comments

Comments
 (0)