[php-src] master: Merge branch 'PHP-8.6'
| From: | Ilia Alshanetsky | Date: | Wed, 23 Sep 2026 01:22:32 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141455@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-22T20:52:00-04:00
Commit: https://github.com/php/php-src/commit/1816f331f75c4d6d678263e6660be5127272337f
Raw diff: https://github.com/php/php-src/commit/1816f331f75c4d6d678263e6660be5127272337f.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
ext/session: Abort strict-mode re-creation when create_sid() fails
Changed paths:
A ext/session/tests/user_session_module/session_start_strict_recreate_create_sid_fails.phpt
M ext/session/session.c
Diff:
diff --git a/ext/session/session.c b/ext/session/session.c
index 21545ecc01ba..ef97f856499f 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -463,7 +463,11 @@ static zend_result php_session_initialize(void)
PS(id) = NULL;
PS(id) = PS(mod)->s_create_sid(&PS(mod_data));
if (!PS(id)) {
- PS(id) = php_session_create_id(NULL);
+ php_session_abort();
+ if (!EG(exception)) {
+ zend_throw_error(NULL, "Failed to create session ID: %s (path: %s)",
PS(mod)->s_name, ZSTR_VAL(PS(save_path)));
+ }
+ return FAILURE;
}
if (PS(use_cookies)) {
PS(send_cookie) = true;
diff --git
a/ext/session/tests/user_session_module/session_start_strict_recreate_create_sid_fails.phpt
b/ext/session/tests/user_session_module/session_start_strict_recreate_create_sid_fails.phpt
new file mode 100644
index 000000000000..3e32c79641e3
--- /dev/null
+++ b/ext/session/tests/user_session_module/session_start_strict_recreate_create_sid_fails.phpt
@@ -0,0 +1,49 @@
+--TEST--
+session_start() strict mode re-creation must abort when create_sid fails
+--INI--
+session.use_trans_sid=1
+session.use_only_cookies=0
+error_reporting=E_ALL & ~E_DEPRECATED
+--EXTENSIONS--
+session
+--FILE--
+<?php
+
+class FailingHandler implements SessionHandlerInterface, SessionIdInterface,
SessionUpdateTimestampHandlerInterface
+{
+ public function open($path, $name): bool { return true; }
+ public function close(): bool { return true; }
+ public function read($id): string|false { return ''; }
+ public function write($id, $data): bool { return true; }
+ public function destroy($id): bool { return true; }
+ public function gc($max_lifetime): int|false { return 0; }
+ public function updateTimestamp($id, $data): bool { return true; }
+
+ public function create_sid(): string
+ {
+ throw new RuntimeException('create_sid failed');
+ }
+
+ public function validateId($id): bool
+ {
+ return false;
+ }
+}
+
+session_set_save_handler(new FailingHandler(), true);
+session_id(str_repeat('a', 32));
+
+try {
+ var_dump(session_start(['use_strict_mode' => true]));
+} catch (Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+var_dump(session_status() === PHP_SESSION_ACTIVE);
+var_dump(defined('SID'));
+
+?>
+--EXPECT--
+TypeError: Session id must be of type string, null given
+bool(false)
+bool(false)