diff options
Diffstat (limited to 'ext/session/tests')
24 files changed, 250 insertions, 52 deletions
diff --git a/ext/session/tests/016.phpt b/ext/session/tests/016.phpt index 82a85d2705..f23605eb47 100644 --- a/ext/session/tests/016.phpt +++ b/ext/session/tests/016.phpt @@ -22,5 +22,5 @@ session_write_close(); print "I live\n"; ?> --EXPECTF-- -Warning: session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (123;:/really%scompletely:::/invalid;;,23123;213) in %s on line %d +Warning: session_start(): Failed to read session data: files (path: 123;:/really%scompletely:::/invalid;;,23123;213) in %s on line %d I live diff --git a/ext/session/tests/bug55688.phpt b/ext/session/tests/bug55688.phpt index 8db48384af..b073dc3c5c 100644 --- a/ext/session/tests/bug55688.phpt +++ b/ext/session/tests/bug55688.phpt @@ -12,4 +12,4 @@ $x = new SessionHandler; $x->gc(1); ?> --EXPECTF-- -Warning: SessionHandler::gc(): Parent session handler is not open in %s on line %d +Warning: SessionHandler::gc(): Session is not active in %s on line %d diff --git a/ext/session/tests/bug60634.phpt b/ext/session/tests/bug60634.phpt index 86dcb11526..b2f5076287 100644 --- a/ext/session/tests/bug60634.phpt +++ b/ext/session/tests/bug60634.phpt @@ -39,8 +39,17 @@ session_start(); session_write_close(); echo "um, hi\n"; +/* +FIXME: Since session module try to write/close session data in +RSHUTDOWN, write() is executed twices. This is caused by undefined +function error and zend_bailout(). Current session module codes +depends on this behavior. These codes should be modified to remove +multiple write(). +*/ + ?> --EXPECTF-- write: goodbye cruel world +write: goodbye cruel world close: goodbye cruel world diff --git a/ext/session/tests/bug60634_error_1.phpt b/ext/session/tests/bug60634_error_1.phpt index d0733f5a5a..fa76ff522a 100644 --- a/ext/session/tests/bug60634_error_1.phpt +++ b/ext/session/tests/bug60634_error_1.phpt @@ -41,6 +41,11 @@ session_start(); session_write_close(); echo "um, hi\n"; +/* +FIXME: Something wrong. It should try to close after error, otherwise session +may keep "open" state. +*/ + ?> --EXPECTF-- write: goodbye cruel world @@ -51,3 +56,4 @@ Stack trace: #1 %s(%d): session_write_close() #2 {main} thrown in %s on line %d + diff --git a/ext/session/tests/bug61728.phpt b/ext/session/tests/bug61728.phpt index 3f8dbeb58a..2780d7b7e2 100644 --- a/ext/session/tests/bug61728.phpt +++ b/ext/session/tests/bug61728.phpt @@ -8,32 +8,34 @@ function output_html($ext) { return strlen($ext); } -function open ($save_path, $session_name) { +function open ($save_path, $session_name) { return true; -} +} -function close() { +function close() { return true; -} +} -function read ($id) { -} +function read ($id) { + return ''; +} -function write ($id, $sess_data) { +function write ($id, $sess_data) { ob_start("output_html"); echo "laruence"; ob_end_flush(); return true; -} +} -function destroy ($id) { -} +function destroy ($id) { + return true; +} -function gc ($maxlifetime) { - return true; -} +function gc ($maxlifetime) { + return true; +} -session_set_save_handler ("open", "close", "read", "write", "destroy", "gc"); +session_set_save_handler ("open", "close", "read", "write", "destroy", "gc"); session_start(); --EXPECTF-- 8 diff --git a/ext/session/tests/bug67972.phpt b/ext/session/tests/bug67972.phpt index 63ed3a95b8..92c3044ac5 100644 --- a/ext/session/tests/bug67972.phpt +++ b/ext/session/tests/bug67972.phpt @@ -7,4 +7,5 @@ Bug #67972: SessionHandler Invalid memory read create_sid() (new SessionHandler)->create_sid(); --EXPECTF-- -Fatal error: SessionHandler::create_sid(): Cannot call default session handler in %s on line %d +Warning: SessionHandler::create_sid(): Session is not active in %s on line %d + diff --git a/ext/session/tests/bug68063.phpt b/ext/session/tests/bug68063.phpt index d3da470d06..ec3a70d156 100644 --- a/ext/session/tests/bug68063.phpt +++ b/ext/session/tests/bug68063.phpt @@ -3,18 +3,22 @@ Bug #68063 (Empty session IDs do still start sessions) --SKIPIF-- <?php include('skipif.inc'); ?> --INI-- +session.use_strict_mode=0 +session.hash_function=1 +session.hash_bits_per_character=4 --FILE-- <?php +// Empty session ID may happen by browser bugs + // Could also be set with a cookie like "PHPSESSID=; path=/" session_id(''); -// Will still start the session and return true +// Start the session with empty string should result in new session ID var_dump(session_start()); -// Returns an empty string +// Returns newly created session ID var_dump(session_id()); ?> --EXPECTF-- -Warning: session_start(): Cannot start session with empty session ID in %s on line %d -bool(false) -string(0) "" +bool(true) +string(40) "%s" diff --git a/ext/session/tests/bug70133.phpt b/ext/session/tests/bug70133.phpt new file mode 100644 index 0000000000..3e019e483b --- /dev/null +++ b/ext/session/tests/bug70133.phpt @@ -0,0 +1,41 @@ +--TEST-- +Bug #70133 (Extended SessionHandler::read is ignoring $session_id when calling parent) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=files +session.save_path= +session.use_strict_mode=0 +--FILE-- +<?php + +class CustomReadHandler extends \SessionHandler { + + public function read($session_id) { + return parent::read('mycustomsession'); + } +} + +ob_start(); + +session_set_save_handler(new CustomReadHandler(), true); + +session_id('mycustomsession'); +session_start(); +$_SESSION['foo'] = 'hoge'; +var_dump(session_id()); +session_commit(); + +session_id('otherid'); +session_start(); +var_dump($_SESSION); +var_dump(session_id()); + +?> +--EXPECT-- +string(15) "mycustomsession" +array(1) { + ["foo"]=> + string(4) "hoge" +} +string(7) "otherid" diff --git a/ext/session/tests/bug71162.phpt b/ext/session/tests/bug71162.phpt new file mode 100644 index 0000000000..fe38ea2999 --- /dev/null +++ b/ext/session/tests/bug71162.phpt @@ -0,0 +1,79 @@ +--TEST-- +updateTimestamp never called when session data is empty +--INI-- +session.use_strict_mode=0 +--XFAIL-- +Current session module is designed to write empty session always. In addition, +current session module only supports SessionHandlerInterface only from PHP 7.0. +--FILE-- +<?php +class MySessionHandler implements SessionUpdateTimestampHandlerInterface +{ + public function open($path, $sessname) { + return TRUE; + } + + public function close() { + return TRUE; + } + + public function read($sessid) { + return ''; + } + + public function write($sessid, $sessdata) { + echo __FUNCTION__, PHP_EOL; + return TRUE; + } + + public function destroy($sessid) { + return TRUE; + } + + public function gc($maxlifetime) { + return TRUE; + } + + public function create_sid() { + return sha1(random_bytes(32)); + } + + public function validateId($sid) { + return TRUE; + } + + public function updateTimestamp($sessid, $sessdata) { + echo __FUNCTION__, PHP_EOL; + return TRUE; + } +} + +ob_start(); +$handler = new MySessionHandler(); +session_set_save_handler($handler); + +session_id(sha1('')); +var_dump(session_id()); +var_dump(session_start(['lazy_write'=>1])); +session_commit(); + +session_id(sha1('')); +var_dump(session_id()); +var_dump(session_start(['lazy_write'=>1])); +session_commit(); + +session_id(sha1('')); +var_dump(session_id()); +var_dump(session_start(['lazy_write'=>0])); +session_commit(); +?> +--EXPECT-- +string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709" +bool(true) +write +string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709" +bool(true) +updateTimestamp +string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709" +bool(true) +write diff --git a/ext/session/tests/bug71186.phpt b/ext/session/tests/bug71186.phpt new file mode 100644 index 0000000000..5eeba6035f --- /dev/null +++ b/ext/session/tests/bug71186.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #71186 session.hash_function - algorithm changes +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.hash_function=sha512 +session.save_handler=files +--FILE-- +<?php +ob_start(); +ini_set('session.use_strict_mode', 1); + +session_start(); +$orig = session_id(); +session_regenerate_id(); +$new = session_id(); +var_dump(strlen($orig),strlen($new)); +session_commit(); + +ini_set('session.hash_function','sha1'); +session_id('invalid'); +session_start(); +$orig = session_id(); +session_regenerate_id(); +$new = session_id(); +var_dump(strlen($orig),strlen($new)); +?> +--EXPECT-- +int(128) +int(128) +int(40) +int(40) diff --git a/ext/session/tests/rfc1867_sid_invalid.phpt b/ext/session/tests/rfc1867_sid_invalid.phpt index 4dd8f1f979..a9114e3e1d 100644 --- a/ext/session/tests/rfc1867_sid_invalid.phpt +++ b/ext/session/tests/rfc1867_sid_invalid.phpt @@ -47,13 +47,13 @@ session_destroy(); --EXPECTF-- Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 -Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 +Warning: Unknown: Failed to read session data: files (path: ) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0 Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 -Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 +Warning: Unknown: Failed to read session data: files (path: ) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0 string(%d) "%s" diff --git a/ext/session/tests/session_save_path_variation2.phpt b/ext/session/tests/session_save_path_variation2.phpt index 4cf44b75a4..60675aec3c 100644 --- a/ext/session/tests/session_save_path_variation2.phpt +++ b/ext/session/tests/session_save_path_variation2.phpt @@ -33,8 +33,12 @@ ob_end_flush(); string(5) "/blah" Warning: session_start(): open(%sblah%e%s, O_RDWR) failed: No such file or directory (2) in %s on line %d -bool(true) + +Warning: session_start(): Failed to read session data: files (path: %sblah) in %s on line %d +bool(false) string(5) "/blah" -bool(true) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) string(5) "/blah" Done diff --git a/ext/session/tests/session_save_path_variation3.phpt b/ext/session/tests/session_save_path_variation3.phpt index b064f30183..1d290d95b3 100644 --- a/ext/session/tests/session_save_path_variation3.phpt +++ b/ext/session/tests/session_save_path_variation3.phpt @@ -33,8 +33,12 @@ ob_end_flush(); string(5) "/blah" Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d -bool(true) + +Warning: session_start(): Failed to read session data: files (path: %sblah) in %s on line %d +bool(false) string(5) "/blah" -bool(true) + +Warning: session_destroy(): Trying to destroy uninitialized session in %s on line %d +bool(false) string(5) "/blah" Done diff --git a/ext/session/tests/session_save_path_variation4.phpt b/ext/session/tests/session_save_path_variation4.phpt index 80db6caf7d..a4c4e995d3 100644 --- a/ext/session/tests/session_save_path_variation4.phpt +++ b/ext/session/tests/session_save_path_variation4.phpt @@ -57,4 +57,3 @@ string(0) "" Warning: session_start(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %s on line %d Fatal error: session_start(): Failed to initialize storage module: files (path: ) in %s on line %d - diff --git a/ext/session/tests/session_set_save_handler_class_002.phpt b/ext/session/tests/session_set_save_handler_class_002.phpt index b75a7e6390..880bc33425 100644 --- a/ext/session/tests/session_set_save_handler_class_002.phpt +++ b/ext/session/tests/session_set_save_handler_class_002.phpt @@ -34,7 +34,7 @@ class MySession2 extends SessionHandler { } public function read($id) { - return @file_get_contents($this->path . $id); + return (string)@file_get_contents($this->path . $id); } public function write($id, $data) { diff --git a/ext/session/tests/session_set_save_handler_class_005.phpt b/ext/session/tests/session_set_save_handler_class_005.phpt index 5be735306a..1b8c1ce645 100644 --- a/ext/session/tests/session_set_save_handler_class_005.phpt +++ b/ext/session/tests/session_set_save_handler_class_005.phpt @@ -33,7 +33,7 @@ class MySession6 extends SessionHandler { $handler = new MySession6; session_set_save_handler($handler); -session_start(); +var_dump(session_start()); var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); @@ -45,13 +45,12 @@ session_unset(); *** Testing session_set_save_handler() : incomplete implementation *** Warning: SessionHandler::read(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d + +Warning: SessionHandler::close(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d + +Warning: session_start(): Failed to read session data: user (%s) in %ssession_set_save_handler_class_005.php on line %d +bool(false) string(%d) "%s" string(4) "user" array(0) { } - -Warning: SessionHandler::write(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d - -Warning: session_write_close(): Failed to write session data %s in %ssession_set_save_handler_class_005.php on line %d - -Warning: SessionHandler::close(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d diff --git a/ext/session/tests/session_set_save_handler_class_012.phpt b/ext/session/tests/session_set_save_handler_class_012.phpt index 91e751bdfc..0ce03f865e 100644 --- a/ext/session/tests/session_set_save_handler_class_012.phpt +++ b/ext/session/tests/session_set_save_handler_class_012.phpt @@ -38,7 +38,7 @@ class MySession extends SessionHandler { $oldHandler = ini_get('session.save_handler'); $handler = new MySession; session_set_save_handler($handler); -session_start(); +var_dump(session_start()); var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); @@ -50,15 +50,14 @@ Warning: SessionHandler::open() expects exactly 2 parameters, 0 given in %s on l Read %s Warning: SessionHandler::read(): Parent session handler is not open in %s on line %d + +Warning: SessionHandler::close(): Parent session handler is not open in %s on line %d + +Warning: session_start(): Failed to read session data: user (%s) in %s on line %d +bool(false) string(%d) "%s" string(5) "files" string(4) "user" int(2) array(0) { } - -Warning: SessionHandler::write(): Parent session handler is not open in Unknown on line 0 - -Warning: session_write_close(): Failed to write session data %s in %s on line %d - -Warning: SessionHandler::close(): Parent session handler is not open in Unknown on line 0 diff --git a/ext/session/tests/session_set_save_handler_class_016.phpt b/ext/session/tests/session_set_save_handler_class_016.phpt index 521bd86f31..4095813c9d 100644 --- a/ext/session/tests/session_set_save_handler_class_016.phpt +++ b/ext/session/tests/session_set_save_handler_class_016.phpt @@ -10,10 +10,10 @@ session.name=PHPSESSID ob_start(); -/* +/* * Prototype : bool session_set_save_handler(SessionHandlerInterface $handler [, bool $register_shutdown_function = true]) * Description : Sets user-level session storage functions - * Source code : ext/session/session.c + * Source code : ext/session/session.c */ echo "*** Testing session_set_save_handler() function: class with create_sid ***\n"; @@ -34,7 +34,7 @@ class MySession2 extends SessionHandler { } public function read($id) { - return @file_get_contents($this->path . $id); + return (string)@file_get_contents($this->path . $id); } public function write($id, $data) { diff --git a/ext/session/tests/session_set_save_handler_class_017.phpt b/ext/session/tests/session_set_save_handler_class_017.phpt index 6f42d7809a..b8e7d7a7ad 100644 --- a/ext/session/tests/session_set_save_handler_class_017.phpt +++ b/ext/session/tests/session_set_save_handler_class_017.phpt @@ -34,7 +34,7 @@ class MySession2 extends SessionHandler { } public function read($id) { - return @file_get_contents($this->path . $id); + return (string)@file_get_contents($this->path . $id); } public function write($id, $data) { diff --git a/ext/session/tests/session_set_save_handler_error4.phpt b/ext/session/tests/session_set_save_handler_error4.phpt index be3429b084..4267195ee1 100644 --- a/ext/session/tests/session_set_save_handler_error4.phpt +++ b/ext/session/tests/session_set_save_handler_error4.phpt @@ -24,7 +24,7 @@ session_set_save_handler("callback", "callback", "callback", "echo", "callback", session_set_save_handler("callback", "callback", "callback", "callback", "echo", "callback"); session_set_save_handler("callback", "callback", "callback", "callback", "callback", "echo"); session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback"); -session_start(); +var_dump(session_start()); ob_end_flush(); ?> --EXPECTF-- @@ -39,3 +39,6 @@ Warning: session_set_save_handler(): Argument 4 is not a valid callback in %s on Warning: session_set_save_handler(): Argument 5 is not a valid callback in %s on line %d Warning: session_set_save_handler(): Argument 6 is not a valid callback 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/session_set_save_handler_iface_001.phpt b/ext/session/tests/session_set_save_handler_iface_001.phpt index 03ee42865c..6943d59cbe 100644 --- a/ext/session/tests/session_set_save_handler_iface_001.phpt +++ b/ext/session/tests/session_set_save_handler_iface_001.phpt @@ -34,7 +34,7 @@ class MySession2 implements SessionHandlerInterface { } public function read($id) { - return @file_get_contents($this->path . $id); + return (string)@file_get_contents($this->path . $id); } public function write($id, $data) { diff --git a/ext/session/tests/session_set_save_handler_iface_002.phpt b/ext/session/tests/session_set_save_handler_iface_002.phpt index 40c9ac6825..204d88c785 100644 --- a/ext/session/tests/session_set_save_handler_iface_002.phpt +++ b/ext/session/tests/session_set_save_handler_iface_002.phpt @@ -43,7 +43,7 @@ class MySession2 implements MySessionHandlerInterface { } public function read($id) { - return @file_get_contents($this->path . $id); + return (string)@file_get_contents($this->path . $id); } public function write($id, $data) { diff --git a/ext/session/tests/session_set_save_handler_sid_002.phpt b/ext/session/tests/session_set_save_handler_sid_002.phpt index f9a72aebca..1d00586e89 100644 --- a/ext/session/tests/session_set_save_handler_sid_002.phpt +++ b/ext/session/tests/session_set_save_handler_sid_002.phpt @@ -74,4 +74,13 @@ session_unset(); --EXPECTF-- *** Testing session_set_save_handler() function: create_sid *** -Fatal error: session_start(): Session id must be a string in %s on line %d +Fatal error: Uncaught Error: Session id must be a string in %s:%d +Stack trace: +#0 %s(%d): session_start() +#1 {main} + +Next Error: Failed to create session ID: user (path: ) in %s:%d +Stack trace: +#0 %s(%d): session_start() +#1 {main} + thrown in %s on line %d diff --git a/ext/session/tests/sessionhandler_open_001.phpt b/ext/session/tests/sessionhandler_open_001.phpt index 6ade9e00a5..e6e913a6a5 100644 --- a/ext/session/tests/sessionhandler_open_001.phpt +++ b/ext/session/tests/sessionhandler_open_001.phpt @@ -16,4 +16,11 @@ print "Done!\n"; ?> --EXPECTF-- +Warning: SessionHandler::open(): Session is not active in %s on line 5 + +Warning: SessionHandler::open(): Session is not active in %s on line 6 + +Warning: SessionHandler::open(): Session is not active in %s on line 7 + +Warning: SessionHandler::open(): Session is not active in %s on line 8 Done! |
