Skip to content

Commit 9105c26

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 0d45c79 commit 9105c26

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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
@@ -410,7 +410,7 @@ public function setOptions(array $options)
410410
$normalized[$normKey] = $value;
411411
}
412412

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

0 commit comments

Comments
 (0)