mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Deprecate calling session_set_save_handler() with more than 2 arguments
This commit is contained in:
@@ -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
|
||||
========================================
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"]);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -13,43 +13,45 @@ session.gc_divisor=1
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
function sOpen($path, $name)
|
||||
{
|
||||
echo "open: path = {$path}, name = {$name}\n";
|
||||
return TRUE;
|
||||
class MySessionHandler implements SessionHandlerInterface {
|
||||
function open($path, $name): bool
|
||||
{
|
||||
echo "open: path = {$path}, name = {$name}\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function close(): bool
|
||||
{
|
||||
echo "close\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function read($id): string|false
|
||||
{
|
||||
echo "read: id = {$id}\n";
|
||||
return '';
|
||||
}
|
||||
|
||||
function write($id, $data): bool
|
||||
{
|
||||
echo "write: id = {$id}, data = {$data}\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function destroy($id): bool
|
||||
{
|
||||
echo "destroy: id = {$id}\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function gc($maxlifetime): int
|
||||
{
|
||||
echo "gc: maxlifetime = {$maxlifetime}\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function sClose()
|
||||
{
|
||||
echo "close\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function sRead($id)
|
||||
{
|
||||
echo "read: id = {$id}\n";
|
||||
return '';
|
||||
}
|
||||
|
||||
function sWrite($id, $data)
|
||||
{
|
||||
echo "write: id = {$id}, data = {$data}\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function sDestroy($id)
|
||||
{
|
||||
echo "destroy: id = {$id}\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function sGC($maxlifetime)
|
||||
{
|
||||
echo "gc: maxlifetime = {$maxlifetime}\n";
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
session_set_save_handler( 'sOpen', 'sClose', 'sRead', 'sWrite', 'sDestroy', 'sGC' );
|
||||
session_set_save_handler(new MySessionHandler());
|
||||
|
||||
// without output buffering, the debug messages will cause all manner of warnings
|
||||
ob_start();
|
||||
|
||||
@@ -11,31 +11,33 @@ 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 {
|
||||
die("close: goodbye cruel world\n");
|
||||
}
|
||||
|
||||
function read($id): string|false {
|
||||
return '';
|
||||
}
|
||||
|
||||
function write($id, $session_data): bool {
|
||||
die("write: goodbye cruel world\n");
|
||||
}
|
||||
|
||||
function destroy($id): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
function gc($maxlifetime): int {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
die("close: goodbye cruel world\n");
|
||||
}
|
||||
|
||||
function read($id) {
|
||||
return '';
|
||||
}
|
||||
|
||||
function write($id, $session_data) {
|
||||
die("write: goodbye cruel world\n");
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
@@ -11,33 +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() {
|
||||
echo "close: goodbye cruel world\n";
|
||||
return true;
|
||||
}
|
||||
function close(): bool {
|
||||
echo "close: goodbye cruel world\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
function read($id) {
|
||||
return '';
|
||||
}
|
||||
function read($id): string|false {
|
||||
return '';
|
||||
}
|
||||
|
||||
function write($id, $session_data) {
|
||||
echo "write: goodbye cruel world\n";
|
||||
undefined_function();
|
||||
}
|
||||
function write($id, $session_data): bool {
|
||||
echo "write: goodbye cruel world\n";
|
||||
undefined_function();
|
||||
}
|
||||
|
||||
function destroy($id) {
|
||||
return true;
|
||||
}
|
||||
function destroy($id): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
function gc($maxlifetime) {
|
||||
return true;
|
||||
function gc($maxlifetime): int {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
@@ -53,7 +54,7 @@ write: goodbye cruel world
|
||||
|
||||
Fatal error: Uncaught Error: Call to undefined function undefined_function() in %s:%d
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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--
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -70,8 +70,10 @@ var_dump($_SESSION);
|
||||
<?php
|
||||
@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_sid_001');
|
||||
?>
|
||||
--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) {
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user