From b36eac94d26bdced150d9d2178f6209893d9961f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 22 Nov 2023 23:02:25 +0100 Subject: [PATCH] Deprecate calling session_set_save_handler() with more than 2 arguments --- UPGRADING | 4 ++ ext/session/session.c | 5 ++ .../tests/session_module_name_variation2.phpt | 16 +++-- .../tests/session_module_name_variation3.phpt | 22 +++--- .../basic_set_save_handler_test.phpt | 46 ++++++------ .../basic_set_save_handler_test02.phpt | 10 +-- .../tests/user_session_module/bug31454.phpt | 3 +- .../tests/user_session_module/bug32330.phpt | 72 ++++++++++--------- .../tests/user_session_module/bug60634.phpt | 48 +++++++------ .../user_session_module/bug60634_error_1.phpt | 45 ++++++------ .../user_session_module/bug60634_error_2.phpt | 54 +++++++------- .../user_session_module/bug60634_error_3.phpt | 1 + .../user_session_module/bug60634_error_4.phpt | 8 +-- .../user_session_module/bug60634_error_5.phpt | 52 +++++++------- .../tests/user_session_module/bug61728.phpt | 54 +++++++------- .../tests/user_session_module/bug80889a.phpt | 7 +- .../tests/user_session_module/gh7787.phpt | 2 + .../session_set_save_handler_basic.phpt | 4 ++ .../session_set_save_handler_class_002.phpt | 2 + .../session_set_save_handler_closures.phpt | 4 ++ .../session_set_save_handler_error2.phpt | 18 ++--- .../session_set_save_handler_error3.phpt | 2 + .../session_set_save_handler_error4.phpt | 14 ++++ .../session_set_save_handler_iface_001.phpt | 2 + .../session_set_save_handler_iface_002.phpt | 4 +- .../session_set_save_handler_multiple.phpt | 5 +- .../session_set_save_handler_sid_001.phpt | 4 +- .../session_set_save_handler_sid_002.phpt | 6 +- .../session_set_save_handler_type_error.phpt | 7 ++ .../session_set_save_handler_type_error2.phpt | 5 +- .../session_set_save_handler_variation2.phpt | 2 + .../session_set_save_handler_variation3.phpt | 2 + .../session_set_save_handler_variation4.phpt | 4 ++ .../session_set_save_handler_variation5.phpt | 4 ++ .../session_set_save_handler_variation6.phpt | 6 ++ 35 files changed, 317 insertions(+), 227 deletions(-) diff --git a/UPGRADING b/UPGRADING index 87dac6d3112..fee935d01cd 100644 --- a/UPGRADING +++ b/UPGRADING @@ -173,6 +173,10 @@ PHP 8.4 UPGRADE NOTES . Calling ReflectionMethod::__construct() with 1 argument is deprecated. Use ReflectionMethod::createFromMethodName() instead. +- Session: + . Calling session_set_save_handler() with more than 2 arguments is + deprecated. Use the 2-parameter signature instead. + ======================================== 5. Changed Functions ======================================== diff --git a/ext/session/session.c b/ext/session/session.c index 3ec9315d882..afe82db897b 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -2092,6 +2092,11 @@ PHP_FUNCTION(session_set_save_handler) RETURN_TRUE; } + zend_error(E_DEPRECATED, "Calling session_set_save_handler() with more than 2 arguments is deprecated"); + if (UNEXPECTED(EG(exception))) { + RETURN_THROWS(); + } + /* Procedural version */ zend_fcall_info open_fci = {0}; zend_fcall_info_cache open_fcc; diff --git a/ext/session/tests/session_module_name_variation2.phpt b/ext/session/tests/session_module_name_variation2.phpt index ac7c0a1b233..0e78ab86621 100644 --- a/ext/session/tests/session_module_name_variation2.phpt +++ b/ext/session/tests/session_module_name_variation2.phpt @@ -11,15 +11,17 @@ ob_start(); echo "*** Testing session_module_name() : variation ***\n"; -function open($save_path, $session_name) { } -function close() { } -function read($id) { } -function write($id, $session_data) { } -function destroy($id) { } -function gc($maxlifetime) { } +class MySessionHandler implements SessionHandlerInterface { + public function open($save_path, $session_name): bool { return false; } + public function close(): bool { return false; } + public function read($id): string|false { return false; } + public function write($id, $session_data): bool { return false; } + public function destroy($id): bool { return false; } + public function gc($maxlifetime): int { return 1; } +} var_dump(session_module_name("files")); -session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_set_save_handler(new MySessionHandler()); var_dump(session_module_name()); ob_end_flush(); diff --git a/ext/session/tests/session_module_name_variation3.phpt b/ext/session/tests/session_module_name_variation3.phpt index 9650e4e7516..2a055e8c04b 100644 --- a/ext/session/tests/session_module_name_variation3.phpt +++ b/ext/session/tests/session_module_name_variation3.phpt @@ -14,18 +14,20 @@ session ob_start(); echo "*** Testing session_module_name() : variation ***\n"; -function open($save_path, $session_name) { - throw new Exception("Stop...!"); + +class MySessionHandler implements SessionHandlerInterface { + public function open($save_path, $session_name): bool { + throw new Exception("Stop...!"); + } + public function close(): bool { return true; } + public function read($id): string|false { return ''; } + public function write($id, $session_data): bool { return true; } + public function destroy($id): bool { return true; } + public function gc($maxlifetime): int { return 1; } } -function close() { return true; } -function read($id) { return ''; } -function write($id, $session_data) { return true; } -function destroy($id) { return true; } -function gc($maxlifetime) { return true; } - var_dump(session_module_name("files")); -session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_set_save_handler(new MySessionHandler()); var_dump(session_module_name()); var_dump(session_start()); var_dump(session_module_name()); @@ -40,7 +42,7 @@ string(4) "user" Fatal error: Uncaught Exception: Stop...! in %s:%d Stack trace: -#0 [internal function]: open('', 'PHPSESSID') +#0 [internal function]: MySessionHandler->open('', 'PHPSESSID') #1 %s(%d): session_start() #2 {main} thrown in %s on line %d 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 de7d39b45b0..d1b41dc4c50 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 @@ -13,7 +13,7 @@ session.serialize_handler=php error_reporting(E_ALL); ob_start(); -class handler { +class handler implements SessionHandlerInterface { public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; function open($save_path, $session_name): bool { @@ -43,7 +43,7 @@ class handler { return true; } - function gc() { return true; } + function gc($max_lifetime): int { return 1; } } $hnd = new handler; @@ -54,7 +54,7 @@ class foo { function method() { $this->yes++; } } -session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_set_save_handler(new handler()); session_id("test004"); session_start(); @@ -66,7 +66,7 @@ var_dump($_SESSION["arr"]); session_write_close(); -session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_set_save_handler(new handler()); session_start(); var_dump($_SESSION["baz"]); @@ -77,7 +77,25 @@ session_destroy(); --EXPECT-- OPEN: PHPSESSID READ: test004 -object(foo)#2 (2) { +object(foo)#3 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) +} +array(1) { + [3]=> + object(foo)#4 (2) { + ["bar"]=> + string(2) "ok" + ["yes"]=> + int(2) + } +} +WRITE: test004, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} +OPEN: PHPSESSID +READ: test004 +object(foo)#4 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -92,22 +110,4 @@ array(1) { int(2) } } -WRITE: test004, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} -OPEN: PHPSESSID -READ: test004 -object(foo)#3 (2) { - ["bar"]=> - string(2) "ok" - ["yes"]=> - int(2) -} -array(1) { - [3]=> - object(foo)#2 (2) { - ["bar"]=> - string(2) "ok" - ["yes"]=> - int(2) - } -} DESTROY: test004 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 a111f2fd1c7..ec2858fe2d8 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 @@ -13,7 +13,7 @@ session.serialize_handler=php error_reporting(E_ALL); ob_start(); -class handler { +class handler implements SessionHandlerInterface { public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'; function open($save_path, $session_name): bool { @@ -44,7 +44,7 @@ class handler { return true; } - function gc() { return true; } + function gc($max_lifetime): int { return 1; } } $hnd = new handler; @@ -55,7 +55,7 @@ class foo { function method() { $this->yes++; } } -session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_set_save_handler($hnd); session_id("test005"); session_start(); @@ -69,7 +69,7 @@ var_dump($_SESSION["arr"]); session_write_close(); -session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_set_save_handler($hnd); session_start(); $_SESSION["baz"]->method(); $_SESSION["arr"][3]->method(); @@ -82,7 +82,7 @@ var_dump($_SESSION["c"]); session_write_close(); -session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); +session_set_save_handler($hnd); session_start(); var_dump($_SESSION["baz"]); var_dump($_SESSION["arr"]); diff --git a/ext/session/tests/user_session_module/bug31454.phpt b/ext/session/tests/user_session_module/bug31454.phpt index de97e6962fe..8fbe42bb8fa 100644 --- a/ext/session/tests/user_session_module/bug31454.phpt +++ b/ext/session/tests/user_session_module/bug31454.phpt @@ -20,6 +20,7 @@ try { echo "Done\n"; ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Calling session_set_save_handler() with more than 2 arguments 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 Done diff --git a/ext/session/tests/user_session_module/bug32330.phpt b/ext/session/tests/user_session_module/bug32330.phpt index 7c38bb22a56..e14161c1e7b 100644 --- a/ext/session/tests/user_session_module/bug32330.phpt +++ b/ext/session/tests/user_session_module/bug32330.phpt @@ -13,43 +13,45 @@ session.gc_divisor=1 write('%s', '') #1 %s(%d): session_write_close() #2 {main} thrown in %s on line %d 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 0a8b31f4858..0de1f0b70b6 100644 --- a/ext/session/tests/user_session_module/bug60634_error_2.phpt +++ b/ext/session/tests/user_session_module/bug60634_error_2.phpt @@ -11,33 +11,35 @@ session ob_start(); -function open($save_path, $session_name) { - return true; +class MySessionHandler implements SessionHandlerInterface { + function open($save_path, $session_name): bool { + return true; + } + + function close(): bool { + echo "close: goodbye cruel world\n"; + return true; + } + + function read($id): string|false { + return ''; + } + + function write($id, $session_data): bool { + echo "write: goodbye cruel world\n"; + throw new Exception; + } + + function destroy($id): bool { + return true; + } + + function gc($maxlifetime): int { + return true; + } } -function close() { - echo "close: goodbye cruel world\n"; - return true; -} - -function read($id) { - return ''; -} - -function write($id, $session_data) { - echo "write: goodbye cruel world\n"; - throw new Exception; -} - -function destroy($id) { - return true; -} - -function gc($maxlifetime) { - return true; -} - -session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); +session_set_save_handler(new MySessionHandler()); session_start(); session_write_close(); echo "um, hi\n"; @@ -48,7 +50,7 @@ write: goodbye cruel world Fatal error: Uncaught Exception in %s Stack trace: -#0 [internal function]: write('%s', '') +#0 [internal function]: MySessionHandler->write('%s', '') #1 %s(%d): session_write_close() #2 {main} thrown in %s on line %d diff --git a/ext/session/tests/user_session_module/bug60634_error_3.phpt b/ext/session/tests/user_session_module/bug60634_error_3.phpt index 8e6aa4b3251..f6162b0d47e 100644 --- a/ext/session/tests/user_session_module/bug60634_error_3.phpt +++ b/ext/session/tests/user_session_module/bug60634_error_3.phpt @@ -42,6 +42,7 @@ session_start(); ?> --EXPECTF-- +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d write: goodbye cruel world Fatal error: Uncaught Error: Call to undefined function undefined_function() in %s:%d diff --git a/ext/session/tests/user_session_module/bug60634_error_4.phpt b/ext/session/tests/user_session_module/bug60634_error_4.phpt index cdc7a4739b6..a229f29bf34 100644 --- a/ext/session/tests/user_session_module/bug60634_error_4.phpt +++ b/ext/session/tests/user_session_module/bug60634_error_4.phpt @@ -14,34 +14,30 @@ ob_start(); function open($save_path, $session_name) { return true; } - function close() { echo "close: goodbye cruel world\n"; exit; } - function read($id) { return ''; } - function write($id, $session_data) { echo "write: goodbye cruel world\n"; throw new Exception; } - function destroy($id) { return true; } - function gc($maxlifetime) { return true; } - session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); + session_start(); ?> --EXPECTF-- +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d write: goodbye cruel world Fatal error: Uncaught Exception in %s 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 568d3c3a267..4103b43b982 100644 --- a/ext/session/tests/user_session_module/bug60634_error_5.phpt +++ b/ext/session/tests/user_session_module/bug60634_error_5.phpt @@ -11,32 +11,34 @@ session ob_start(); -function open($save_path, $session_name) { - return true; +class MySessionHandler implements SessionHandlerInterface { + function open($save_path, $session_name): bool { + return true; + } + + function close(): bool { + echo "close: goodbye cruel world\n"; + undefined_function(); + } + + function read($id): string { + return ''; + } + + function write($id, $session_data): bool { + return true; + } + + function destroy($id): bool { + return true; + } + + function gc($maxlifetime): int { + return 1; + } } -function close() { - echo "close: goodbye cruel world\n"; - undefined_function(); -} - -function read($id) { - return ''; -} - -function write($id, $session_data) { - return true; -} - -function destroy($id) { - return true; -} - -function gc($maxlifetime) { - return true; -} - -session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc'); +session_set_save_handler(new MySessionHandler()); session_start(); session_write_close(); echo "um, hi\n"; @@ -47,7 +49,7 @@ close: goodbye cruel world Fatal error: Uncaught Error: Call to undefined function undefined_function() in %s:%d Stack trace: -#0 [internal function]: close() +#0 [internal function]: MySessionHandler->close() #1 %s(%d): session_write_close() #2 {main} thrown in %s on line %d diff --git a/ext/session/tests/user_session_module/bug61728.phpt b/ext/session/tests/user_session_module/bug61728.phpt index a9b8af40430..fd79fa6b2bc 100644 --- a/ext/session/tests/user_session_module/bug61728.phpt +++ b/ext/session/tests/user_session_module/bug61728.phpt @@ -8,34 +8,36 @@ function output_html($ext) { return strlen($ext); } -function open ($save_path, $session_name) { - return true; +class MySessionHandler implements SessionHandlerInterface { + function open ($save_path, $session_name): bool { + return true; + } + + function close(): bool { + return true; + } + + function read ($id): string { + return ''; + } + + function write ($id, $sess_data): bool { + ob_start("output_html"); + echo "laruence"; + ob_end_flush(); + return true; + } + + function destroy ($id): bool { + return true; + } + + function gc ($maxlifetime): int { + return 1; + } } -function close() { - return true; -} - -function read ($id) { - return ''; -} - -function write ($id, $sess_data) { - ob_start("output_html"); - echo "laruence"; - ob_end_flush(); - return true; -} - -function destroy ($id) { - return true; -} - -function gc ($maxlifetime) { - return true; -} - -session_set_save_handler ("open", "close", "read", "write", "destroy", "gc"); +session_set_save_handler(new MySessionHandler()); session_start(); ?> --EXPECT-- diff --git a/ext/session/tests/user_session_module/bug80889a.phpt b/ext/session/tests/user_session_module/bug80889a.phpt index 200fdf71271..58e1f70ca58 100644 --- a/ext/session/tests/user_session_module/bug80889a.phpt +++ b/ext/session/tests/user_session_module/bug80889a.phpt @@ -30,6 +30,9 @@ session_set_save_handler( $setHandler = ini_get('session.save_handler'); var_dump($initHandler, $setHandler); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d + +Warning: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent in %s on line %d +string(8) "whatever" string(8) "whatever" -string(4) "user" diff --git a/ext/session/tests/user_session_module/gh7787.phpt b/ext/session/tests/user_session_module/gh7787.phpt index 124e82ce07e..67975ca636f 100644 --- a/ext/session/tests/user_session_module/gh7787.phpt +++ b/ext/session/tests/user_session_module/gh7787.phpt @@ -82,6 +82,8 @@ Warning: session_write_close(): Failed to write session data using user defined Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: %S, handler: MySessionHandler::updateTimestamp) in %s on line %d +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d + Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: %S, handler: write) in %s on line %d Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: %S, handler: update_timestamp) in %s on line %d diff --git a/ext/session/tests/user_session_module/session_set_save_handler_basic.phpt b/ext/session/tests/user_session_module/session_set_save_handler_basic.phpt index 7192c728b1a..e1be047624b 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_basic.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_basic.phpt @@ -74,6 +74,8 @@ bool(false) Warning: session_module_name(): Session handler module "foo" cannot be found in %s on line %d bool(false) + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open [%s,PHPSESSID] Read [%s,%s] array(3) { @@ -95,6 +97,8 @@ array(3) { int(1234567890) } Starting session again..! + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open [%s,PHPSESSID] Read [%s,%s] array(3) { 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 f93bbf89799..900b3e81946 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 @@ -86,6 +86,8 @@ session_unset(); ?> --EXPECTF-- *** Testing session_set_save_handler() : full handler implementation *** + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d string(%d) "%s" string(4) "user" array(1) { diff --git a/ext/session/tests/user_session_module/session_set_save_handler_closures.phpt b/ext/session/tests/user_session_module/session_set_save_handler_closures.phpt index e724eead9d0..3a7b159d5ee 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_closures.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_closures.phpt @@ -61,6 +61,8 @@ bool(false) Warning: session_module_name(): Session handler module "foo" cannot be found in %s on line %d bool(false) + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open [%s,PHPSESSID] Read [%s,%s] array(3) { @@ -82,6 +84,8 @@ array(3) { int(1234567890) } Starting session again..! + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open [%s,PHPSESSID] Read [%s,%s] array(4) { diff --git a/ext/session/tests/user_session_module/session_set_save_handler_error2.phpt b/ext/session/tests/user_session_module/session_set_save_handler_error2.phpt index 35bbae9d515..47da9d4bff1 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_error2.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_error2.phpt @@ -11,14 +11,16 @@ ob_start(); echo "*** Testing session_set_save_handler() : error functionality ***\n"; -function open($save_path, $session_name) { return true; } -function close() { return true; } -function read($id) { return false; } -function write($id, $session_data) { } -function destroy($id) { return true; } -function gc($maxlifetime) { return true; } +class MySessionHandler implements SessionHandlerInterface { + function open($save_path, $session_name): bool { return true; } + function close(): bool { return true; } + function read($id): string|false { return false; } + function write($id, $session_data): bool { } + function destroy($id): bool { return true; } + function gc($maxlifetime): int|false { return true; } +} -session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_set_save_handler(new MySessionHandler()); session_start(); $_SESSION["Blah"] = "Hello World!"; @@ -28,7 +30,7 @@ var_dump($_SESSION); session_write_close(); var_dump($_SESSION); -session_set_save_handler("open", "close", "read", "write", "destroy", "gc"); +session_set_save_handler(new MySessionHandler()); session_start(); var_dump($_SESSION); session_destroy(); diff --git a/ext/session/tests/user_session_module/session_set_save_handler_error3.phpt b/ext/session/tests/user_session_module/session_set_save_handler_error3.phpt index f11dab9831c..7b6acbea78f 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_error3.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_error3.phpt @@ -29,6 +29,8 @@ ob_end_flush(); --EXPECTF-- *** Testing session_set_save_handler() : error functionality *** +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d + Fatal error: Uncaught Exception: Do something bad..! in %s:%d Stack trace: #0 [internal function]: open('', 'PHPSESSID') 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 3e2f677fe01..622bffd4d62 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 @@ -54,11 +54,25 @@ ob_end_flush(); ?> --EXPECTF-- *** Testing session_set_save_handler() : error functionality *** + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d + +Deprecated: Calling session_set_save_handler() with more than 2 arguments 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 + +Deprecated: Calling session_set_save_handler() with more than 2 arguments 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 + +Deprecated: Calling session_set_save_handler() with more than 2 arguments 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 + +Deprecated: Calling session_set_save_handler() with more than 2 arguments 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 + +Deprecated: Calling session_set_save_handler() with more than 2 arguments 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 +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d + Warning: session_start(): Failed to read session data: user (%s) in %s on line %d bool(false) diff --git a/ext/session/tests/user_session_module/session_set_save_handler_iface_001.phpt b/ext/session/tests/user_session_module/session_set_save_handler_iface_001.phpt index 6fa6026cbe4..3ee5bd54664 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_iface_001.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_iface_001.phpt @@ -82,6 +82,8 @@ session_unset(); ?> --EXPECTF-- *** Testing session_set_save_handler() function: interface *** + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d string(%d) "%s" string(4) "user" array(1) { 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 4c5301493f4..5535d6bae95 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 @@ -78,8 +78,10 @@ try { session_start(); ?> ---EXPECT-- +--EXPECTF-- *** Testing session_set_save_handler() function: interface wrong *** + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d bool(true) session_set_save_handler(): Argument #1 ($open) must be of type SessionHandlerInterface, MySession2 given good handler writing diff --git a/ext/session/tests/user_session_module/session_set_save_handler_multiple.phpt b/ext/session/tests/user_session_module/session_set_save_handler_multiple.phpt index 9da914d440b..635140e4d4b 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_multiple.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_multiple.phpt @@ -72,13 +72,16 @@ session_write_close(); ob_end_flush(); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open Create SID OLD Read Write Close New handlers: + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open Validate ID Read diff --git a/ext/session/tests/user_session_module/session_set_save_handler_sid_001.phpt b/ext/session/tests/user_session_module/session_set_save_handler_sid_001.phpt index 0e41963c225..1c74b3da85d 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_sid_001.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_sid_001.phpt @@ -70,8 +70,10 @@ var_dump($_SESSION); ---EXPECT-- +--EXPECTF-- *** Testing session_set_save_handler() function: create_sid *** + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d string(32) "session_set_save_handler_sid_001" string(4) "user" array(1) { 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 583b619d4cb..3b9a3f411ef 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 @@ -11,7 +11,7 @@ ob_start(); echo "*** Testing session_set_save_handler() function: create_sid ***\n"; -class MySession2 { +class MySession2 implements SessionHandlerInterface, SessionIdInterface { public $path; public function open($path, $name): bool { @@ -54,9 +54,7 @@ class MySession2 { } } -$handler = new MySession2; -session_set_save_handler(array($handler, 'open'), array($handler, 'close'), - array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'), array($handler, 'create_sid')); +session_set_save_handler(new MySession2()); session_start(); $_SESSION['foo'] = "hello"; 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 f9d7cdbd523..c44ddb5324f 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 @@ -43,13 +43,20 @@ ob_end_flush(); ?> --EXPECTF-- +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Session callback must have a return value of type bool, array returned +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d + Deprecated: session_start(): Session callback must have a return value of type bool, int returned in %s on line %d Warning: session_start(): Failed to read session data: user (%s) in %s on line %d + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Session callback must have a return value of type bool, array returned +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d + Deprecated: session_start(): Session callback must have a return value of type bool, int returned in %s on line %d Warning: session_start(): Failed to read session data: user (%s) 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 a0d9232d4c2..d39c8086653 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 @@ -27,6 +27,9 @@ try { ob_end_flush(); ?> ---EXPECT-- +--EXPECTF-- +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Session callback must have a return value of type bool, null returned + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Session callback must have a return value of type bool, int returned diff --git a/ext/session/tests/user_session_module/session_set_save_handler_variation2.phpt b/ext/session/tests/user_session_module/session_set_save_handler_variation2.phpt index 96248fee39f..1e9e1150e28 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_variation2.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_variation2.phpt @@ -28,6 +28,8 @@ rmdir($path); *** Testing session_set_save_handler() : variation *** bool(true) +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d + Warning: session_set_save_handler(): Session save handler cannot be changed when a session is active in %s on line %d bool(false) bool(true) diff --git a/ext/session/tests/user_session_module/session_set_save_handler_variation3.phpt b/ext/session/tests/user_session_module/session_set_save_handler_variation3.phpt index 57ff352ce5f..340a8f20f46 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_variation3.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_variation3.phpt @@ -31,6 +31,8 @@ int(2) Warning: session_save_path(): Session save path cannot be changed when a session is active in %s on line %d +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d + Warning: session_set_save_handler(): Session save handler cannot be changed when a session is active in %s on line %d bool(false) bool(true) diff --git a/ext/session/tests/user_session_module/session_set_save_handler_variation4.phpt b/ext/session/tests/user_session_module/session_set_save_handler_variation4.phpt index f097131a4dc..bff2f5bb8e7 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_variation4.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_variation4.phpt @@ -50,6 +50,8 @@ rmdir($path); ?> --EXPECTF-- *** Testing session_set_save_handler() : variation *** + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open [%s,PHPSESSID] Read [%s,%s] GC [0] @@ -65,6 +67,8 @@ array(3) { Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;] Close [%s,PHPSESSID] bool(true) + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open [%s,PHPSESSID] Read [%s,%s] GC [0] diff --git a/ext/session/tests/user_session_module/session_set_save_handler_variation5.phpt b/ext/session/tests/user_session_module/session_set_save_handler_variation5.phpt index 5285b8e9145..cd9916d1172 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_variation5.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_variation5.phpt @@ -58,6 +58,8 @@ rmdir($path); *** Testing session_set_save_handler() : variation *** string(0) "" *** Without lazy_write *** + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d bool(true) Open [%s,PHPSESSID] CreateID [PHPT-%d] @@ -72,6 +74,8 @@ bool(true) string(%d) "PHPT-%d" *** With lazy_write *** string(%d) "PHPT-%d" + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d bool(true) Open [%s,PHPSESSID] ValidateID [%s,PHPT-%d] diff --git a/ext/session/tests/user_session_module/session_set_save_handler_variation6.phpt b/ext/session/tests/user_session_module/session_set_save_handler_variation6.phpt index 96ef3be6ed6..9037931971f 100644 --- a/ext/session/tests/user_session_module/session_set_save_handler_variation6.phpt +++ b/ext/session/tests/user_session_module/session_set_save_handler_variation6.phpt @@ -62,6 +62,8 @@ rmdir($path); ?> --EXPECTF-- *** Testing session_set_save_handler() : test write short circuit *** + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open [%s,PHPSESSID] CreateID [PHPT-%s] Read [%s,%s] @@ -84,6 +86,8 @@ array(3) { int(1234567890) } Starting session again..! + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open [%s,PHPSESSID] Read [%s,%s] array(3) { @@ -97,6 +101,8 @@ array(3) { Write [%s,%s,Blah|s:12:"Hello World!";Foo|b:0;Guff|i:1234567890;Bar|s:3:"Foo";] Close [%s,PHPSESSID] Starting session again..! + +Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d Open [%s,PHPSESSID] Read [%s,%s] array(4) {