[php-src] master: session: add create_sid and validateId methods to some tests

From: Date: Sun, 16 Aug 2026 21:16:21 +0000
Subject: [php-src] master: session: add create_sid and validateId methods to some tests
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140768@lists.php.net to get a copy of this message
Author: Gina Peter Banyard (Girgias) Date: 2026-08-16T22:16:17+01:00 Commit: https://github.com/php/php-src/commit/00f90287a1c06e6254375dae03a94f8d8a87ed9a Raw diff: https://github.com/php/php-src/commit/00f90287a1c06e6254375dae03a94f8d8a87ed9a.diff session: add create_sid and validateId methods to some tests Changed paths: M ext/session/tests/gh12504.phpt M ext/session/tests/session_module_name_variation2.phpt M ext/session/tests/session_module_name_variation3.phpt M ext/session/tests/user_session_module/basic_set_save_handler_test.phpt M ext/session/tests/user_session_module/basic_set_save_handler_test02.phpt M ext/session/tests/user_session_module/bug32330.phpt M ext/session/tests/user_session_module/bug60634.phpt M ext/session/tests/user_session_module/bug60634_error_1.phpt M ext/session/tests/user_session_module/bug60634_error_2.phpt M ext/session/tests/user_session_module/bug60634_error_5.phpt M ext/session/tests/user_session_module/bug61728.phpt M ext/session/tests/user_session_module/bug78624.phpt M ext/session/tests/user_session_module/bug80889.phpt M ext/session/tests/user_session_module/session_regenerate_id_destroy_fails.phpt M ext/session/tests/user_session_module/session_regenerate_id_write_fails.phpt M ext/session/tests/user_session_module/session_set_save_handler_class_002.phpt M ext/session/tests/user_session_module/session_set_save_handler_class_018.phpt M ext/session/tests/user_session_module/session_set_save_handler_sid_002.phpt Diff: diff --git a/ext/session/tests/gh12504.phpt b/ext/session/tests/gh12504.phpt index eb19424eb500..8b1b3ad94639 100644 --- a/ext/session/tests/gh12504.phpt +++ b/ext/session/tests/gh12504.phpt @@ -34,6 +34,15 @@ class TestSessionHandler implements SessionHandlerInterface echo $data . PHP_EOL; return true; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } register_shutdown_function(function() { diff --git a/ext/session/tests/session_module_name_variation2.phpt b/ext/session/tests/session_module_name_variation2.phpt index 0e78ab86621b..feb9484f2818 100644 --- a/ext/session/tests/session_module_name_variation2.phpt +++ b/ext/session/tests/session_module_name_variation2.phpt @@ -18,6 +18,14 @@ class MySessionHandler implements SessionHandlerInterface { public function write($id, $session_data): bool { return false; } public function destroy($id): bool { return false; } public function gc($maxlifetime): int { return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } var_dump(session_module_name("files")); diff --git a/ext/session/tests/session_module_name_variation3.phpt b/ext/session/tests/session_module_name_variation3.phpt index 2a055e8c04b8..0b621c3a16c5 100644 --- a/ext/session/tests/session_module_name_variation3.phpt +++ b/ext/session/tests/session_module_name_variation3.phpt @@ -24,6 +24,14 @@ class MySessionHandler implements SessionHandlerInterface { public function write($id, $session_data): bool { return true; } public function destroy($id): bool { return true; } public function gc($maxlifetime): int { return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } var_dump(session_module_name("files")); diff --git a/ext/session/tests/user_session_module/basic_set_save_handler_test.phpt b/ext/session/tests/user_session_module/basic_set_save_handler_test.phpt index d1b41dc4c509..63b6e8a1c442 100644 --- a/ext/session/tests/user_session_module/basic_set_save_handler_test.phpt +++ b/ext/session/tests/user_session_module/basic_set_save_handler_test.phpt @@ -44,6 +44,14 @@ class handler implements SessionHandlerInterface { } function gc($max_lifetime): int { return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } $hnd = new handler; diff --git a/ext/session/tests/user_session_module/basic_set_save_handler_test02.phpt b/ext/session/tests/user_session_module/basic_set_save_handler_test02.phpt index ec2858fe2d8c..61f7e5405745 100644 --- a/ext/session/tests/user_session_module/basic_set_save_handler_test02.phpt +++ b/ext/session/tests/user_session_module/basic_set_save_handler_test02.phpt @@ -45,6 +45,14 @@ class handler implements SessionHandlerInterface { } function gc($max_lifetime): int { return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } $hnd = new handler; diff --git a/ext/session/tests/user_session_module/bug32330.phpt b/ext/session/tests/user_session_module/bug32330.phpt index e14161c1e7b4..712f2a4f972d 100644 --- a/ext/session/tests/user_session_module/bug32330.phpt +++ b/ext/session/tests/user_session_module/bug32330.phpt @@ -49,6 +49,14 @@ class MySessionHandler implements SessionHandlerInterface { echo "gc: maxlifetime = {$maxlifetime}\n"; return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } session_set_save_handler(new MySessionHandler()); diff --git a/ext/session/tests/user_session_module/bug60634.phpt b/ext/session/tests/user_session_module/bug60634.phpt index 786c3358e785..4035263fac70 100644 --- a/ext/session/tests/user_session_module/bug60634.phpt +++ b/ext/session/tests/user_session_module/bug60634.phpt @@ -35,6 +35,14 @@ class MySessionHandler implements SessionHandlerInterface { function gc($maxlifetime): int { return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } session_set_save_handler(new MySessionHandler()); diff --git a/ext/session/tests/user_session_module/bug60634_error_1.phpt b/ext/session/tests/user_session_module/bug60634_error_1.phpt index 98e4d371dd8c..8c141804df35 100644 --- a/ext/session/tests/user_session_module/bug60634_error_1.phpt +++ b/ext/session/tests/user_session_module/bug60634_error_1.phpt @@ -37,6 +37,14 @@ class MySessionHandler implements SessionHandlerInterface { function gc($maxlifetime): int { return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } session_set_save_handler(new MySessionHandler()); session_start(); diff --git a/ext/session/tests/user_session_module/bug60634_error_2.phpt b/ext/session/tests/user_session_module/bug60634_error_2.phpt index 0de1f0b70b67..7aea0f6a35b1 100644 --- a/ext/session/tests/user_session_module/bug60634_error_2.phpt +++ b/ext/session/tests/user_session_module/bug60634_error_2.phpt @@ -37,6 +37,14 @@ class MySessionHandler implements SessionHandlerInterface { function gc($maxlifetime): int { return true; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } session_set_save_handler(new MySessionHandler()); diff --git a/ext/session/tests/user_session_module/bug60634_error_5.phpt b/ext/session/tests/user_session_module/bug60634_error_5.phpt index 4103b43b9821..0e2be520209d 100644 --- a/ext/session/tests/user_session_module/bug60634_error_5.phpt +++ b/ext/session/tests/user_session_module/bug60634_error_5.phpt @@ -36,6 +36,14 @@ class MySessionHandler implements SessionHandlerInterface { function gc($maxlifetime): int { return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } session_set_save_handler(new MySessionHandler()); diff --git a/ext/session/tests/user_session_module/bug61728.phpt b/ext/session/tests/user_session_module/bug61728.phpt index 152cf9f42bee..647502712e27 100644 --- a/ext/session/tests/user_session_module/bug61728.phpt +++ b/ext/session/tests/user_session_module/bug61728.phpt @@ -35,6 +35,14 @@ class MySessionHandler implements SessionHandlerInterface { function gc ($maxlifetime): int { return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } session_set_save_handler(new MySessionHandler()); diff --git a/ext/session/tests/user_session_module/bug78624.phpt b/ext/session/tests/user_session_module/bug78624.phpt index 103fc97a6fe2..75a6650d94d9 100644 --- a/ext/session/tests/user_session_module/bug78624.phpt +++ b/ext/session/tests/user_session_module/bug78624.phpt @@ -38,6 +38,14 @@ class MySession implements SessionHandlerInterface { echo 'Garbage collect', "\n"; return 1; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } $handler = new MySession; diff --git a/ext/session/tests/user_session_module/bug80889.phpt b/ext/session/tests/user_session_module/bug80889.phpt index c388a67a932e..c8da6d33fe17 100644 --- a/ext/session/tests/user_session_module/bug80889.phpt +++ b/ext/session/tests/user_session_module/bug80889.phpt @@ -25,6 +25,14 @@ class DummyHandler implements SessionHandlerInterface { public function gc($maxlifetime): int|false { return true; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } $initHandler = ini_get('session.save_handler'); diff --git a/ext/session/tests/user_session_module/session_regenerate_id_destroy_fails.phpt b/ext/session/tests/user_session_module/session_regenerate_id_destroy_fails.phpt index 5ad41aeeacf7..e2e346aa15ec 100644 --- a/ext/session/tests/user_session_module/session_regenerate_id_destroy_fails.phpt +++ b/ext/session/tests/user_session_module/session_regenerate_id_destroy_fails.phpt @@ -31,6 +31,14 @@ class FailingDestroyHandler implements SessionHandlerInterface { function gc($maxlifetime): int|false { return 0; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } session_set_save_handler(new FailingDestroyHandler()); diff --git a/ext/session/tests/user_session_module/session_regenerate_id_write_fails.phpt b/ext/session/tests/user_session_module/session_regenerate_id_write_fails.phpt index 1f5c3f84099b..083ec92f3853 100644 --- a/ext/session/tests/user_session_module/session_regenerate_id_write_fails.phpt +++ b/ext/session/tests/user_session_module/session_regenerate_id_write_fails.phpt @@ -31,6 +31,14 @@ class FailingWriteHandler implements SessionHandlerInterface { function gc($maxlifetime): int|false { return 0; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } session_set_save_handler(new FailingWriteHandler()); diff --git a/ext/session/tests/user_session_module/session_set_save_handler_class_002.phpt b/ext/session/tests/user_session_module/session_set_save_handler_class_002.phpt index bad19815d085..92d176ddcf3f 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_class_002.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_class_002.phpt @@ -48,6 +48,14 @@ class MySession2 extends SessionHandler { } return true; } + + private int $id = 0; + public function create_sid(): string { + return ++$this->id; + } + public function validateId(string $id): bool { + return $id > 0 && $id <= $this->id; + } } $handler = new MySession2; diff --git a/ext/session/tests/user_session_module/session_set_save_handler_class_018.phpt b/ext/session/tests/user_session_module/session_set_save_handler_class_018.phpt index 49aa0cf8fd79..c1d15a2a4609 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_class_018.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_class_018.phpt @@ -52,7 +52,7 @@ class MySession2 extends SessionHandler { return pathinfo(__FILE__)['filename']; } - public function validate_sid($id): bool { + public function validateId($id): bool { return pathinfo(__FILE__)['filename']===$id; } } diff --git a/ext/session/tests/user_session_module/session_set_save_handler_sid_002.phpt b/ext/session/tests/user_session_module/session_set_save_handler_sid_002.phpt index c9a10de4e442..4a940fe87681 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_sid_002.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_sid_002.phpt @@ -48,6 +48,10 @@ class MySession2 implements SessionHandlerInterface, SessionIdInterface { public function create_sid() { return false; } + + public function validateId(string $id): bool { + return true; + } } session_set_save_handler(new MySession2());

« previous php.cvs (#140768) next »