Skip to content

Commit b9eca9a

Browse files
minor #32215 [HttpFoundation] Throw exception when the "session" extension is not loaded (vudaltsov)
This PR was squashed before being merged into the 3.4 branch (closes #32215). Discussion ---------- [HttpFoundation] Throw exception when the "session" extension is not loaded | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31305 | License | MIT Should I target `3.4` or `master` instead? This change does not alter behavior, but makes the failure more clear. Commits ------- b0c663071b [HttpFoundation] Throw exception when the \"session\" extension is not loaded
2 parents 8cfbf75 + 6005107 commit b9eca9a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Session/Storage/NativeSessionStorage.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ class NativeSessionStorage implements SessionStorageInterface
100100
*/
101101
public function __construct(array $options = [], $handler = null, MetadataBag $metaBag = null)
102102
{
103+
if (!\extension_loaded('session')) {
104+
throw new \LogicException('PHP extension "session" is required.');
105+
}
106+
103107
$options += [
104108
'cache_limiter' => '',
105109
'cache_expire' => 0,

Session/Storage/PhpBridgeSessionStorage.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class PhpBridgeSessionStorage extends NativeSessionStorage
2424
*/
2525
public function __construct($handler = null, MetadataBag $metaBag = null)
2626
{
27+
if (!\extension_loaded('session')) {
28+
throw new \LogicException('PHP extension "session" is required.');
29+
}
30+
2731
$this->setMetadataBag($metaBag);
2832
$this->setSaveHandler($handler);
2933
}

0 commit comments

Comments
 (0)