Commit 53e12920569 for php.net
commit 53e1292056986d6033cc1bedbc2a10cbe9f8ef94
Author: NickSdot <32384907+NickSdot@users.noreply.github.com>
Date: Thu Aug 6 23:25:21 2026 +0700
ext/session: applied fixers to improve test robustness (#23036)
diff --git a/ext/session/tests/bug73100.phpt b/ext/session/tests/bug73100.phpt
index fc998442872..125849c0655 100644
--- a/ext/session/tests/bug73100.phpt
+++ b/ext/session/tests/bug73100.phpt
@@ -15,7 +15,7 @@
try {
session_module_name("user");
} catch (\ValueError $e) {
- echo $e->getMessage() . \PHP_EOL;
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
===DONE===
@@ -24,5 +24,5 @@
Warning: session_module_name(): Session save handler module cannot be changed when a session is active (started from %s on line %d) in %s on line %d
bool(true)
-session_module_name(): Argument #1 ($module) must not be "user"
+ValueError: session_module_name(): Argument #1 ($module) must not be "user"
===DONE===
diff --git a/ext/session/tests/session_create_id_invalid_prefix.phpt b/ext/session/tests/session_create_id_invalid_prefix.phpt
index 7de7e8061f6..4d84944f5cf 100644
--- a/ext/session/tests/session_create_id_invalid_prefix.phpt
+++ b/ext/session/tests/session_create_id_invalid_prefix.phpt
@@ -16,13 +16,13 @@
try {
var_dump(session_create_id('ABTgdPs68S3M4HMaqKwj33TzqLMv5PHpWQxJbfpeogEhrJRY7o9f33pKLCmhf0tXCtoBkIu0yxXYCSHfJhPd2miPUW4MIpd91dnEiOwWDfaBnfdJZOwgvgmYLSfDGaebqmnCAoyuzlcq2j59nNRhccgJIkr9ytY3RwFTTXszpcjpx6mlJuG9GksKAhPsnnaEwSEb0eFyqvn80gYI2roKSjaFSmJxg0xgXuCF4csMo8DxiSvovho5QTKx5u7h8VyQL'));
} catch (Throwable $e) {
- echo $e::class . ': ' . $e->getMessage() . "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
var_dump(session_create_id("AB\0CD"));
} catch (Throwable $e) {
- echo $e::class . ': ' . $e->getMessage() . "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
diff --git a/ext/session/tests/session_encode_error2.phpt b/ext/session/tests/session_encode_error2.phpt
index 42f5c4dd688..5bdc263f367 100644
--- a/ext/session/tests/session_encode_error2.phpt
+++ b/ext/session/tests/session_encode_error2.phpt
@@ -34,7 +34,7 @@
try {
$_SESSION[$input] = "Hello World!";
} catch (Error $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump(session_encode());
var_dump(session_destroy());
diff --git a/ext/session/tests/session_gc_probability_ini.phpt b/ext/session/tests/session_gc_probability_ini.phpt
index 6d6f7519ba4..5efd2ddc809 100644
--- a/ext/session/tests/session_gc_probability_ini.phpt
+++ b/ext/session/tests/session_gc_probability_ini.phpt
@@ -36,7 +36,7 @@
session_start($gc_setting);
session_write_close();
} catch (Throwable $e) {
- echo $e::class, ': '. $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
}
ob_end_flush();
diff --git a/ext/session/tests/session_name_variation_null_byte.phpt b/ext/session/tests/session_name_variation_null_byte.phpt
index 84b6ccfb1e6..86c67cb035e 100644
--- a/ext/session/tests/session_name_variation_null_byte.phpt
+++ b/ext/session/tests/session_name_variation_null_byte.phpt
@@ -11,11 +11,11 @@
var_dump(session_name("AB\0CD"));
var_dump(session_start());
} catch (ValueError $e) {
- echo $e->getMessage(). "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
echo "Done";
?>
--EXPECT--
-session_name(): Argument #1 ($name) must not contain any null bytes
+ValueError: session_name(): Argument #1 ($name) must not contain any null bytes
Done
diff --git a/ext/session/tests/session_set_cookie_params_variation7.phpt b/ext/session/tests/session_set_cookie_params_variation7.phpt
index 3780fc0222f..4874192ae14 100644
--- a/ext/session/tests/session_set_cookie_params_variation7.phpt
+++ b/ext/session/tests/session_set_cookie_params_variation7.phpt
@@ -22,13 +22,13 @@
try {
session_set_cookie_params([]);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
session_set_cookie_params(["unknown_key" => true, "secure_invalid" => true]);
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
var_dump(ini_get("session.cookie_secure"));
@@ -46,7 +46,7 @@
try {
session_set_cookie_params(["path" => "newpath/"], "arg after options array");
} catch (ValueError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
var_dump(ini_get("session.cookie_path"));
@@ -56,12 +56,12 @@
?>
--EXPECTF--
*** Testing session_set_cookie_params() : array parameter variation ***
-session_set_cookie_params(): Argument #1 ($lifetime_or_options) must contain at least 1 valid key
+ValueError: session_set_cookie_params(): Argument #1 ($lifetime_or_options) must contain at least 1 valid key
Warning: session_set_cookie_params(): Argument #1 ($lifetime_or_options) contains an unrecognized key "unknown_key" in %s on line %d
Warning: session_set_cookie_params(): Argument #1 ($lifetime_or_options) contains an unrecognized key "secure_invalid" in %s on line %d
-session_set_cookie_params(): Argument #1 ($lifetime_or_options) must contain at least 1 valid key
+ValueError: session_set_cookie_params(): Argument #1 ($lifetime_or_options) must contain at least 1 valid key
string(1) "0"
string(0) ""
bool(true)
@@ -71,6 +71,6 @@
bool(true)
string(2) "42"
string(1) "/"
-session_set_cookie_params(): Argument #2 ($path) must be null when argument #1 ($lifetime_or_options) is an array
+ValueError: session_set_cookie_params(): Argument #2 ($path) must be null when argument #1 ($lifetime_or_options) is an array
string(1) "/"
Done
diff --git a/ext/session/tests/session_start_error.phpt b/ext/session/tests/session_start_error.phpt
index f616b8d4e95..05e09a2faf6 100644
--- a/ext/session/tests/session_start_error.phpt
+++ b/ext/session/tests/session_start_error.phpt
@@ -12,7 +12,7 @@
try {
session_start(['option' => new stdClass()]);
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
$read_and_close = "false";
@@ -20,7 +20,7 @@
try {
session_start([$read_and_close]);
} catch (ValueError $exception) {
- echo $exception::class, ': ', $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
var_dump(session_start(['option' => false]));
@@ -29,7 +29,7 @@
?>
--EXPECTF--
-session_start(): Option "option" must be of type string|int|bool, stdClass given
+TypeError: session_start(): Option "option" must be of type string|int|bool, stdClass given
ValueError: session_start(): Argument #1 ($options) must be of type array with keys as string
Warning: session_start(): Setting option "option" failed in %s on line %d
diff --git a/ext/session/tests/user_session_module/bug31454.phpt b/ext/session/tests/user_session_module/bug31454.phpt
index 09858be34bd..2098c1a48fc 100644
--- a/ext/session/tests/user_session_module/bug31454.phpt
+++ b/ext/session/tests/user_session_module/bug31454.phpt
@@ -15,12 +15,12 @@
array(&$arf, 'gc')
);
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
echo "Done\n";
?>
--EXPECTF--
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-session_set_save_handler(): Argument #1 ($open) must be a valid callback, first array member is not a valid class name or object
+TypeError: session_set_save_handler(): Argument #1 ($open) must be a valid callback, first array member is not a valid class name or object
Done
diff --git a/ext/session/tests/user_session_module/bug55688.phpt b/ext/session/tests/user_session_module/bug55688.phpt
index b1fcec38228..55047dc6b9c 100644
--- a/ext/session/tests/user_session_module/bug55688.phpt
+++ b/ext/session/tests/user_session_module/bug55688.phpt
@@ -13,8 +13,8 @@
try {
$x->gc(1);
} catch (Error $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
?>
--EXPECT--
-Session is not active
+Error: Session is not active
diff --git a/ext/session/tests/user_session_module/bug67972.phpt b/ext/session/tests/user_session_module/bug67972.phpt
index a35b3ac08a2..5beea5bf15e 100644
--- a/ext/session/tests/user_session_module/bug67972.phpt
+++ b/ext/session/tests/user_session_module/bug67972.phpt
@@ -8,9 +8,9 @@
try {
(new SessionHandler)->create_sid();
} catch (Error $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
?>
--EXPECT--
-Session is not active
+Error: Session is not active
diff --git a/ext/session/tests/user_session_module/bug69111.phpt b/ext/session/tests/user_session_module/bug69111.phpt
index 395eb33900e..c3d9a325da7 100644
--- a/ext/session/tests/user_session_module/bug69111.phpt
+++ b/ext/session/tests/user_session_module/bug69111.phpt
@@ -12,23 +12,23 @@
try {
$sh->open('path', 'name');
} catch (Error $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
$sh->write("foo", "bar");
} catch (Error $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
$sh->read("");
} catch (Error $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
?>
--EXPECT--
-Session is not active
-Session is not active
-Session is not active
+Error: Session is not active
+Error: Session is not active
+Error: Session is not active
diff --git a/ext/session/tests/user_session_module/session_set_save_handler_class_012.phpt b/ext/session/tests/user_session_module/session_set_save_handler_class_012.phpt
index f96206efbb6..ee69e9f52a4 100644
--- a/ext/session/tests/user_session_module/session_set_save_handler_class_012.phpt
+++ b/ext/session/tests/user_session_module/session_set_save_handler_class_012.phpt
@@ -35,7 +35,7 @@ public function read($key): string|false {
try {
var_dump(session_start());
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION);
@@ -43,7 +43,7 @@ public function read($key): string|false {
--EXPECTF--
*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***
Open:
-SessionHandler::open() expects exactly 2 arguments, 0 given
+ArgumentCountError: SessionHandler::open() expects exactly 2 arguments, 0 given
Warning: Undefined global variable $_SESSION in %s on line %d
string(0) ""
diff --git a/ext/session/tests/user_session_module/session_set_save_handler_error4.phpt b/ext/session/tests/user_session_module/session_set_save_handler_error4.phpt
index 6e05c209a79..1cac1bd95bd 100644
--- a/ext/session/tests/user_session_module/session_set_save_handler_error4.phpt
+++ b/ext/session/tests/user_session_module/session_set_save_handler_error4.phpt
@@ -14,37 +14,37 @@ function callback() { return true; }
try {
session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback");
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
session_set_save_handler("callback", "echo", "callback", "callback", "callback", "callback");
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
session_set_save_handler("callback", "callback", "echo", "callback", "callback", "callback");
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
session_set_save_handler("callback", "callback", "callback", "echo", "callback", "callback");
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
session_set_save_handler("callback", "callback", "callback", "callback", "echo", "callback");
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
session_set_save_handler("callback", "callback", "callback", "callback", "callback", "echo");
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback");
@@ -58,19 +58,19 @@ function callback() { return true; }
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-session_set_save_handler(): Argument #2 ($close) must be a valid callback, function "echo" not found or invalid function name
+TypeError: session_set_save_handler(): Argument #2 ($close) must be a valid callback, function "echo" not found or invalid function name
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-session_set_save_handler(): Argument #3 ($read) must be a valid callback, function "echo" not found or invalid function name
+TypeError: session_set_save_handler(): Argument #3 ($read) must be a valid callback, function "echo" not found or invalid function name
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-session_set_save_handler(): Argument #4 ($write) must be a valid callback, function "echo" not found or invalid function name
+TypeError: session_set_save_handler(): Argument #4 ($write) must be a valid callback, function "echo" not found or invalid function name
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-session_set_save_handler(): Argument #5 ($destroy) must be a valid callback, function "echo" not found or invalid function name
+TypeError: session_set_save_handler(): Argument #5 ($destroy) must be a valid callback, function "echo" not found or invalid function name
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-session_set_save_handler(): Argument #6 ($gc) must be a valid callback, function "echo" not found or invalid function name
+TypeError: session_set_save_handler(): Argument #6 ($gc) must be a valid callback, function "echo" not found or invalid function name
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
diff --git a/ext/session/tests/user_session_module/session_set_save_handler_error5.phpt b/ext/session/tests/user_session_module/session_set_save_handler_error5.phpt
index 4fc02237ba7..a44647085c2 100644
--- a/ext/session/tests/user_session_module/session_set_save_handler_error5.phpt
+++ b/ext/session/tests/user_session_module/session_set_save_handler_error5.phpt
@@ -10,7 +10,7 @@
session_set_save_handler(new \SessionHandler(), true);
session_start();
} catch (Throwable $e) {
- echo $e::class . ': ' . $e->getMessage() . "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
echo "ok";
?>
diff --git a/ext/session/tests/user_session_module/session_set_save_handler_iface_002.phpt b/ext/session/tests/user_session_module/session_set_save_handler_iface_002.phpt
index b1f0d4b2c57..f8417ec9766 100644
--- a/ext/session/tests/user_session_module/session_set_save_handler_iface_002.phpt
+++ b/ext/session/tests/user_session_module/session_set_save_handler_iface_002.phpt
@@ -73,7 +73,7 @@ function good_write($id, $data) {
try {
$ret = session_set_save_handler($handler);
} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+ echo $e::class, ': ', $e->getMessage(), "\n";
}
session_start();
@@ -83,7 +83,7 @@ function good_write($id, $data) {
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
bool(true)
-session_set_save_handler(): Argument #1 ($open) must be of type SessionHandlerInterface, MySession2 given
+TypeError: session_set_save_handler(): Argument #1 ($open) must be of type SessionHandlerInterface, MySession2 given
good handler writing
Deprecated: PHP Request Shutdown: Session callback must have a return value of type bool, int returned in Unknown on line 0
diff --git a/ext/session/tests/user_session_module/session_set_save_handler_type_error.phpt b/ext/session/tests/user_session_module/session_set_save_handler_type_error.phpt
index 6d5fb1748cd..db17dc3320c 100644
--- a/ext/session/tests/user_session_module/session_set_save_handler_type_error.phpt
+++ b/ext/session/tests/user_session_module/session_set_save_handler_type_error.phpt
@@ -15,28 +15,28 @@
$ret = session_set_save_handler($exceptionCallback, $validCallback, $validCallback, $validCallback, $validCallback, $validCallback);
session_start();
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
$ret = session_set_save_handler($deprecatedCallback, $validCallback, $validCallback, $validCallback, $validCallback, $validCallback);
session_start();
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
$ret = session_set_save_handler($validCallback, $exceptionCallback, $validCallback, $validCallback, $validCallback, $validCallback);
session_start();
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
$ret = session_set_save_handler($validCallback, $deprecatedCallback, $exceptionCallback, $validCallback, $validCallback, $validCallback);
session_start();
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
ob_end_flush();
@@ -44,7 +44,7 @@
?>
--EXPECTF--
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-Session callback must have a return value of type bool, array returned
+TypeError: Session callback must have a return value of type bool, array returned
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
@@ -53,7 +53,7 @@
Warning: session_start(): Failed to read session data: user (%s) in %s on line %d
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-Session callback must have a return value of type bool, array returned
+TypeError: Session callback must have a return value of type bool, array returned
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
diff --git a/ext/session/tests/user_session_module/session_set_save_handler_type_error2.phpt b/ext/session/tests/user_session_module/session_set_save_handler_type_error2.phpt
index 8c6b553f811..b19471d4632 100644
--- a/ext/session/tests/user_session_module/session_set_save_handler_type_error2.phpt
+++ b/ext/session/tests/user_session_module/session_set_save_handler_type_error2.phpt
@@ -15,13 +15,13 @@
$ret = session_set_save_handler($nullCallback, $validCallback, $validCallback, $validCallback, $validCallback, $validCallback);
session_start();
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
$ret = session_set_save_handler($oneCallback, $validCallback, $validCallback, $validCallback, $validCallback, $validCallback);
session_start();
} catch (TypeError $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
ob_end_flush();
@@ -29,7 +29,7 @@
?>
--EXPECTF--
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-Session callback must have a return value of type bool, null returned
+TypeError: Session callback must have a return value of type bool, null returned
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
-Session callback must have a return value of type bool, int returned
+TypeError: Session callback must have a return value of type bool, int returned
diff --git a/ext/session/tests/user_session_module/sessionhandler_open_001.phpt b/ext/session/tests/user_session_module/sessionhandler_open_001.phpt
index d3f0bf98962..5263fe88a0c 100644
--- a/ext/session/tests/user_session_module/sessionhandler_open_001.phpt
+++ b/ext/session/tests/user_session_module/sessionhandler_open_001.phpt
@@ -11,33 +11,33 @@
try {
$x->open('','');
} catch (Error $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
$x->open('','');
} catch (Error $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
$x->open('','');
} catch (Error $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
try {
$x->open('','');
} catch (Error $exception) {
- echo $exception->getMessage() . "\n";
+ echo $exception::class, ': ', $exception->getMessage(), "\n";
}
print "Done!\n";
?>
--EXPECT--
-Session is not active
-Session is not active
-Session is not active
-Session is not active
+Error: Session is not active
+Error: Session is not active
+Error: Session is not active
+Error: Session is not active
Done!