diff options
Diffstat (limited to 'ext/session/tests')
59 files changed, 746 insertions, 926 deletions
diff --git a/ext/session/tests/001.phpt b/ext/session/tests/001.phpt index 0643dce51f..adf63c5f6a 100644 --- a/ext/session/tests/001.phpt +++ b/ext/session/tests/001.phpt @@ -12,9 +12,9 @@ session.save_handler=files error_reporting(E_ALL); class foo { - public $bar = "ok"; + public $bar = "ok"; - function method() { $this->yes = "done"; } + function method() { $this->yes = "done"; } } $baz = new foo; diff --git a/ext/session/tests/003.phpt b/ext/session/tests/003.phpt index eae636593d..a20bc9940d 100644 --- a/ext/session/tests/003.phpt +++ b/ext/session/tests/003.phpt @@ -13,8 +13,8 @@ session.save_handler=files error_reporting(E_ALL); class foo { - public $bar = "ok"; - function method() { $this->yes++; } + public $bar = "ok"; + function method() { $this->yes++; } } session_id("abtest"); diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt index 9e34b7123f..4b81a088b2 100644 --- a/ext/session/tests/004.phpt +++ b/ext/session/tests/004.phpt @@ -33,7 +33,7 @@ class handler { function write($key, $val) { print "WRITE: $key, $val\n"; - $GLOBALS["hnd"]->data = $val; + $GLOBALS["hnd"]->data = $val; return true; } diff --git a/ext/session/tests/005.phpt b/ext/session/tests/005.phpt index 4046b3aebc..a7b42de7fa 100644 --- a/ext/session/tests/005.phpt +++ b/ext/session/tests/005.phpt @@ -14,7 +14,7 @@ error_reporting(E_ALL); ob_start(); class handler { - 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;}}'; + 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) { print "OPEN: $session_name\n"; @@ -22,7 +22,7 @@ class handler { } function close() { - print "CLOSE\n"; + print "CLOSE\n"; return true; } function read($key) @@ -34,7 +34,7 @@ class handler { function write($key, $val) { print "WRITE: $key, $val\n"; - $GLOBALS["hnd"]->data = $val; + $GLOBALS["hnd"]->data = $val; return true; } diff --git a/ext/session/tests/017.phpt b/ext/session/tests/017.phpt index baf7df8c57..957fcb2e45 100644 --- a/ext/session/tests/017.phpt +++ b/ext/session/tests/017.phpt @@ -13,10 +13,10 @@ session.save_handler=files error_reporting(E_ALL); class Kill { - function __construct() { - global $HTTP_SESSION_VARS; - session_start(); - } + function __construct() { + global $HTTP_SESSION_VARS; + session_start(); + } } $k = new Kill(); diff --git a/ext/session/tests/019.phpt b/ext/session/tests/019.phpt index 5846291769..d9a478245b 100644 --- a/ext/session/tests/019.phpt +++ b/ext/session/tests/019.phpt @@ -14,13 +14,13 @@ session.save_handler=files error_reporting(E_ALL); class TFoo { - public $c; - function __construct($c) { - $this->c = $c; - } - function inc() { - $this->c++; - } + public $c; + function __construct($c) { + $this->c = $c; + } + function inc() { + $this->c++; + } } session_id("abtest"); diff --git a/ext/session/tests/022.phpt b/ext/session/tests/022.phpt index 5923bbe0bf..e7e26f88b0 100644 --- a/ext/session/tests/022.phpt +++ b/ext/session/tests/022.phpt @@ -12,9 +12,9 @@ session.save_handler=files error_reporting(E_ALL); class foo { - public $bar = "ok"; + public $bar = "ok"; - function method() { $this->yes = "done"; } + function method() { $this->yes = "done"; } } $baz = new foo; diff --git a/ext/session/tests/023.phpt b/ext/session/tests/023.phpt index 592b4a8c3b..828358dc78 100644 --- a/ext/session/tests/023.phpt +++ b/ext/session/tests/023.phpt @@ -13,8 +13,8 @@ session.save_handler=files error_reporting(E_ALL); class foo { - public $bar = "ok"; - function method() { $this->yes++; } + public $bar = "ok"; + function method() { $this->yes++; } } session_id("abtest"); diff --git a/ext/session/tests/024.phpt b/ext/session/tests/024.phpt index d417a82ca1..174f2e2639 100644 --- a/ext/session/tests/024.phpt +++ b/ext/session/tests/024.phpt @@ -34,7 +34,7 @@ class handler { function write($key, $val) { print "WRITE: $key, $val\n"; - $GLOBALS["hnd"]->data = $val; + $GLOBALS["hnd"]->data = $val; return true; } diff --git a/ext/session/tests/025.phpt b/ext/session/tests/025.phpt index aa1f995c49..172ea579c6 100644 --- a/ext/session/tests/025.phpt +++ b/ext/session/tests/025.phpt @@ -23,7 +23,7 @@ class handler { } function close() { - print "CLOSE\n"; + print "CLOSE\n"; return true; } function read($key) diff --git a/ext/session/tests/bug31454.phpt b/ext/session/tests/bug31454.phpt index 24da588aa4..9e99135e5f 100644 --- a/ext/session/tests/bug31454.phpt +++ b/ext/session/tests/bug31454.phpt @@ -6,12 +6,12 @@ Bug #31454 (session_set_save_handler crashes PHP when supplied non-existent obje <?php session_set_save_handler( - array(&$arf, 'open'), - array(&$arf, 'close'), - array(&$arf, 'read'), - array(&$arf, 'write'), - array(&$arf, 'destroy'), - array(&$arf, 'gc')); + array(&$arf, 'open'), + array(&$arf, 'close'), + array(&$arf, 'read'), + array(&$arf, 'write'), + array(&$arf, 'destroy'), + array(&$arf, 'gc')); echo "Done\n"; ?> diff --git a/ext/session/tests/bug32330.phpt b/ext/session/tests/bug32330.phpt index 4d432ef1d4..4240ff7160 100644 --- a/ext/session/tests/bug32330.phpt +++ b/ext/session/tests/bug32330.phpt @@ -16,38 +16,38 @@ error_reporting(E_ALL); function sOpen($path, $name) { - echo "open: path = {$path}, name = {$name}\n"; - return TRUE; + echo "open: path = {$path}, name = {$name}\n"; + return TRUE; } function sClose() { - echo "close\n"; - return TRUE; + echo "close\n"; + return TRUE; } function sRead($id) { - echo "read: id = {$id}\n"; - return ''; + echo "read: id = {$id}\n"; + return ''; } function sWrite($id, $data) { - echo "write: id = {$id}, data = {$data}\n"; - return TRUE; + echo "write: id = {$id}, data = {$data}\n"; + return TRUE; } function sDestroy($id) { - echo "destroy: id = {$id}\n"; - return TRUE; + echo "destroy: id = {$id}\n"; + return TRUE; } function sGC($maxlifetime) { - echo "gc: maxlifetime = {$maxlifetime}\n"; - return TRUE; + echo "gc: maxlifetime = {$maxlifetime}\n"; + return TRUE; } session_set_save_handler( 'sOpen', 'sClose', 'sRead', 'sWrite', 'sDestroy', 'sGC' ); diff --git a/ext/session/tests/bug60634.phpt b/ext/session/tests/bug60634.phpt index 064f29a0d2..b303134e5b 100644 --- a/ext/session/tests/bug60634.phpt +++ b/ext/session/tests/bug60634.phpt @@ -16,15 +16,15 @@ function open($save_path, $session_name) { } function close() { - die("close: goodbye cruel world\n"); + die("close: goodbye cruel world\n"); } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - die("write: goodbye cruel world\n"); + die("write: goodbye cruel world\n"); } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_1.phpt b/ext/session/tests/bug60634_error_1.phpt index c573b65e36..9a1d2288a3 100644 --- a/ext/session/tests/bug60634_error_1.phpt +++ b/ext/session/tests/bug60634_error_1.phpt @@ -16,17 +16,17 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - return true; + echo "close: goodbye cruel world\n"; + return true; } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - echo "write: goodbye cruel world\n"; - undefined_function(); + echo "write: goodbye cruel world\n"; + undefined_function(); } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_2.phpt b/ext/session/tests/bug60634_error_2.phpt index 4ca598b4e7..ef06095692 100644 --- a/ext/session/tests/bug60634_error_2.phpt +++ b/ext/session/tests/bug60634_error_2.phpt @@ -16,17 +16,17 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - return true; + echo "close: goodbye cruel world\n"; + return true; } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - echo "write: goodbye cruel world\n"; - throw new Exception; + echo "write: goodbye cruel world\n"; + throw new Exception; } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_3.phpt b/ext/session/tests/bug60634_error_3.phpt index f97da00dce..1909fc8ada 100644 --- a/ext/session/tests/bug60634_error_3.phpt +++ b/ext/session/tests/bug60634_error_3.phpt @@ -16,17 +16,17 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - exit; + echo "close: goodbye cruel world\n"; + exit; } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - echo "write: goodbye cruel world\n"; - undefined_function(); + echo "write: goodbye cruel world\n"; + undefined_function(); } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_4.phpt b/ext/session/tests/bug60634_error_4.phpt index ca8672e4f4..e3834f262c 100644 --- a/ext/session/tests/bug60634_error_4.phpt +++ b/ext/session/tests/bug60634_error_4.phpt @@ -16,17 +16,17 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - exit; + echo "close: goodbye cruel world\n"; + exit; } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - echo "write: goodbye cruel world\n"; - throw new Exception; + echo "write: goodbye cruel world\n"; + throw new Exception; } function destroy($id) { diff --git a/ext/session/tests/bug60634_error_5.phpt b/ext/session/tests/bug60634_error_5.phpt index 5728d3a90c..333c86c67f 100644 --- a/ext/session/tests/bug60634_error_5.phpt +++ b/ext/session/tests/bug60634_error_5.phpt @@ -16,16 +16,16 @@ function open($save_path, $session_name) { } function close() { - echo "close: goodbye cruel world\n"; - undefined_function(); + echo "close: goodbye cruel world\n"; + undefined_function(); } function read($id) { - return ''; + return ''; } function write($id, $session_data) { - return true; + return true; } function destroy($id) { diff --git a/ext/session/tests/bug71162.phpt b/ext/session/tests/bug71162.phpt index 31d3370499..b475ae6080 100644 --- a/ext/session/tests/bug71162.phpt +++ b/ext/session/tests/bug71162.phpt @@ -36,13 +36,13 @@ class MySessionHandler extends SessionHandler implements SessionUpdateTimestampH return TRUE; } - public function create_sid() { - return sha1(random_bytes(32)); - } + public function create_sid() { + return sha1(random_bytes(32)); + } - public function validateId($sid) { - return TRUE; - } + public function validateId($sid) { + return TRUE; + } public function updateTimestamp($sessid, $sessdata) { echo __FUNCTION__, PHP_EOL; diff --git a/ext/session/tests/bug71972.phpt b/ext/session/tests/bug71972.phpt index e4c5c6b6d3..1384cae21e 100644 --- a/ext/session/tests/bug71972.phpt +++ b/ext/session/tests/bug71972.phpt @@ -13,13 +13,13 @@ $_SESSION['boogie'] = 1; $_SESSION['obj1'] = new stdClass(); for ( $x=2; $x < 20; $x++) { - cyclic_ref($x); + cyclic_ref($x); } function cyclic_ref($num) { - $_SESSION['obj'.$num] = new stdClass(); - $_SESSION['obj'.$num]->test = new stdClass();//NOTE: No bug if try commenting out this too. - $_SESSION['obj'.$num]->obj1 = $_SESSION['obj1']; + $_SESSION['obj'.$num] = new stdClass(); + $_SESSION['obj'.$num]->test = new stdClass();//NOTE: No bug if try commenting out this too. + $_SESSION['obj'.$num]->obj1 = $_SESSION['obj1']; } var_dump(session_decode(session_encode()) == $_SESSION); diff --git a/ext/session/tests/bug72562.phpt b/ext/session/tests/bug72562.phpt index b36cf6df25..8421e8940a 100644 --- a/ext/session/tests/bug72562.phpt +++ b/ext/session/tests/bug72562.phpt @@ -27,12 +27,12 @@ var_dump($out_2); function ptr2str($ptr) { - $out = ''; - for ($i = 0; $i < 8; $i++) { - $out .= chr($ptr & 0xff); - $ptr >>= 8; - } - return $out; + $out = ''; + for ($i = 0; $i < 8; $i++) { + $out .= chr($ptr & 0xff); + $ptr >>= 8; + } + return $out; } ?> --EXPECTF-- diff --git a/ext/session/tests/bug74514.phpt b/ext/session/tests/bug74514.phpt index f7c8d46998..5ff86c1bfb 100644 --- a/ext/session/tests/bug74514.phpt +++ b/ext/session/tests/bug74514.phpt @@ -23,7 +23,6 @@ var_dump(session_save_path()); var_dump(session_cache_limiter()); var_dump(session_cache_expire()); ?> -===DONE=== --EXPECT-- string(9) "PHPSESSID" string(3) "foo" @@ -31,4 +30,3 @@ string(5) "files" string(0) "" string(7) "nocache" int(180) -===DONE=== diff --git a/ext/session/tests/bug74541.phpt b/ext/session/tests/bug74541.phpt index dec2f25b5d..ccdfdbffde 100644 --- a/ext/session/tests/bug74541.phpt +++ b/ext/session/tests/bug74541.phpt @@ -10,8 +10,6 @@ $r = new ReflectionFunction('session_start'); var_dump($r->getNumberOfParameters()); var_dump($r->getNumberOfRequiredParameters()); ?> -===DONE=== --EXPECT-- int(1) int(0) -===DONE=== diff --git a/ext/session/tests/bug74833.phpt b/ext/session/tests/bug74833.phpt index fa167a1f3a..d299f4ee96 100644 --- a/ext/session/tests/bug74833.phpt +++ b/ext/session/tests/bug74833.phpt @@ -15,7 +15,5 @@ var_dump(isset($c['session']['SID'])); ob_end_flush(); ?> -==DONE== --EXPECT-- bool(true) -==DONE== diff --git a/ext/session/tests/bug74892.phpt b/ext/session/tests/bug74892.phpt index 0947df7761..3b11ec20a7 100644 --- a/ext/session/tests/bug74892.phpt +++ b/ext/session/tests/bug74892.phpt @@ -16,10 +16,8 @@ session_start(); <p><a href="index.php#place">External link with anchor</a></p> <p><a href="http://php.net#foo">External link with anchor 2</a></p> <p><a href="#place">Internal link</a></p> -===DONE=== --EXPECT-- <p><a href="index.php?PHPSESSID=sessionidhere">Click This Anchor Tag!</a></p> <p><a href="index.php?PHPSESSID=sessionidhere#place">External link with anchor</a></p> <p><a href="http://php.net?PHPSESSID=sessionidhere#foo">External link with anchor 2</a></p> <p><a href="#place">Internal link</a></p> -===DONE=== diff --git a/ext/session/tests/bug74936.phpt b/ext/session/tests/bug74936.phpt index aee7493c6c..7b502c85b5 100644 --- a/ext/session/tests/bug74936.phpt +++ b/ext/session/tests/bug74936.phpt @@ -12,9 +12,7 @@ var_dump(session_cache_expire()); var_dump(session_cache_limiter()); var_dump(session_save_path()); ?> -===DONE=== --EXPECT-- int(180) string(7) "nocache" string(0) "" -===DONE=== diff --git a/ext/session/tests/bug74941.phpt b/ext/session/tests/bug74941.phpt index 953d642b10..59b57e1b4d 100644 --- a/ext/session/tests/bug74941.phpt +++ b/ext/session/tests/bug74941.phpt @@ -15,8 +15,6 @@ echo ".\n"; session_id('BUG74941'); var_dump(session_start()); ?> -===DONE=== --EXPECT-- . bool(true) -===DONE=== diff --git a/ext/session/tests/save_handler_closures.inc b/ext/session/tests/save_handler_closures.inc index 50f33c1098..acf72f00f6 100644 --- a/ext/session/tests/save_handler_closures.inc +++ b/ext/session/tests/save_handler_closures.inc @@ -3,7 +3,7 @@ require_once 'save_handler.inc'; foreach (array ('open', 'close', 'read', 'write', 'destroy', 'gc') as $fn) { - ${$fn.'_closure'} = function () use ($fn) { return call_user_func_array ($fn, func_get_args ()); }; + ${$fn.'_closure'} = function () use ($fn) { return call_user_func_array ($fn, func_get_args ()); }; } ?> diff --git a/ext/session/tests/session_cache_expire_error.phpt b/ext/session/tests/session_cache_expire_error.phpt deleted file mode 100644 index 5ae5d95637..0000000000 --- a/ext/session/tests/session_cache_expire_error.phpt +++ /dev/null @@ -1,169 +0,0 @@ ---TEST-- -Test session_cache_expire() function : error functionality ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : int session_cache_expire([int $new_cache_expire]) - * Description : Return current cache expire - * Source code : ext/session/session.c - */ - -echo "*** Testing session_cache_expire() : error functionality ***\n"; - -// Get an unset variable -$unset_var = 10; -unset($unset_var); - -class classA -{ - public function __toString() { - return "Hello World!"; - } -} - -$heredoc = <<<EOT -Hello World! -EOT; - -$fp = fopen(__FILE__, "r"); - -// Unexpected values to be passed as arguments -$inputs = array( - - // Integer data -/*1*/ 0, - 1, - 12345, - -2345, - - // Float data -/*5*/ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - .5, - - // Null data -/*10*/ NULL, - null, - - // Boolean data -/*12*/ true, - false, - TRUE, - FALSE, - - // Empty strings -/*16*/ "", - '', - - // Invalid string data -/*18*/ "Nothing", - 'Nothing', - $heredoc, - - // Object data -/*21*/ new classA(), - - // Undefined data -/*22*/ @$undefined_var, - - // Unset data -/*23*/ @$unset_var, - - // Resource variable -/*24*/ $fp -); - - -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(session_cache_expire($input)); - $iterator++; -}; - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_cache_expire() : error functionality *** - --- Iteration 1 -- -int(180) - --- Iteration 2 -- -int(0) - --- Iteration 3 -- -int(1) - --- Iteration 4 -- -int(12345) - --- Iteration 5 -- -int(-2345) - --- Iteration 6 -- -int(10) - --- Iteration 7 -- -int(-10) - --- Iteration 8 -- -int(%s) - --- Iteration 9 -- -int(1) - --- Iteration 10 -- -int(0) - --- Iteration 11 -- -int(0) - --- Iteration 12 -- -int(0) - --- Iteration 13 -- -int(1) - --- Iteration 14 -- -int(0) - --- Iteration 15 -- -int(1) - --- Iteration 16 -- -int(0) - --- Iteration 17 -- -int(0) - --- Iteration 18 -- -int(0) - --- Iteration 19 -- -int(0) - --- Iteration 20 -- -int(0) - --- Iteration 21 -- -int(0) - --- Iteration 22 -- -int(0) - --- Iteration 23 -- -int(0) - --- Iteration 24 -- -int(0) -Done diff --git a/ext/session/tests/session_cache_limiter_error.phpt b/ext/session/tests/session_cache_limiter_error.phpt index 42b2cb0694..284649e277 100644 --- a/ext/session/tests/session_cache_limiter_error.phpt +++ b/ext/session/tests/session_cache_limiter_error.phpt @@ -75,9 +75,6 @@ $inputs = array( // Unset data /*23*/ @$unset_var, - - // Resource variable -/*24*/ $fp ); @@ -163,9 +160,4 @@ string(12) "Hello World!" -- Iteration 23 -- string(0) "" - --- Iteration 24 -- - -Warning: session_cache_limiter() expects parameter 1 to be string, resource given in %s on line %d -NULL Done diff --git a/ext/session/tests/session_decode_error2.phpt b/ext/session/tests/session_decode_error2.phpt index ff4e618a5e..20415c7a63 100644 --- a/ext/session/tests/session_decode_error2.phpt +++ b/ext/session/tests/session_decode_error2.phpt @@ -18,7 +18,7 @@ $data = "foo|a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}guff|R:1;blah|R:1;"; var_dump(session_start()); for($index = 0; $index < strlen($data); $index++) { - if(session_status() != PHP_SESSION_ACTIVE) { session_start(); } + if(session_status() != PHP_SESSION_ACTIVE) { session_start(); } echo "\n-- Iteration $index --\n"; $encoded = substr($data, 0, $index); var_dump(session_decode($encoded)); diff --git a/ext/session/tests/session_decode_variation3.phpt b/ext/session/tests/session_decode_variation3.phpt index a50feb0cf0..b926de323e 100644 --- a/ext/session/tests/session_decode_variation3.phpt +++ b/ext/session/tests/session_decode_variation3.phpt @@ -37,7 +37,7 @@ ob_end_flush(); Warning: session_start(): Cannot find serialization handler 'blah' - session startup failed in %s on line %d bool(false) -Notice: Undefined variable: _SESSION in %s on line %d +Warning: Undefined variable: _SESSION in %s on line %d NULL array(3) { ["foo"]=> diff --git a/ext/session/tests/session_encode_error2.phpt b/ext/session/tests/session_encode_error2.phpt index 1a87eb14a3..a947eab54e 100644 --- a/ext/session/tests/session_encode_error2.phpt +++ b/ext/session/tests/session_encode_error2.phpt @@ -84,7 +84,11 @@ $iterator = 1; foreach($inputs as $input) { echo "\n-- Iteration $iterator --\n"; var_dump(session_start()); - $_SESSION[$input] = "Hello World!"; + try { + $_SESSION[$input] = "Hello World!"; + } catch (Error $e) { + echo $e->getMessage(), "\n"; + } var_dump(session_encode()); var_dump(session_destroy()); $iterator++; @@ -225,8 +229,7 @@ bool(true) -- Iteration 21 -- bool(true) - -Warning: Illegal offset type in %s on line 82 +Illegal offset type bool(false) bool(true) @@ -243,7 +246,7 @@ bool(true) -- Iteration 24 -- bool(true) -Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d +Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d Notice: session_encode(): Skipping numeric key %d in %s on line %d bool(false) diff --git a/ext/session/tests/session_regenerate_id_cookie.phpt b/ext/session/tests/session_regenerate_id_cookie.phpt index c3c5464860..76667cdbcc 100644 --- a/ext/session/tests/session_regenerate_id_cookie.phpt +++ b/ext/session/tests/session_regenerate_id_cookie.phpt @@ -32,16 +32,16 @@ file_put_contents($file, '<?php ob_start(); function find_cookie_header() { - $headers = headers_list(); - $target = "Set-Cookie: PHPSESSID="; - foreach ($headers as $h) { - if (strstr($h, $target) !== FALSE) { - echo $h."\n"; - return TRUE; - } - } - var_dump($headers); - return FALSE; + $headers = headers_list(); + $target = "Set-Cookie: PHPSESSID="; + foreach ($headers as $h) { + if (strstr($h, $target) !== FALSE) { + echo $h."\n"; + return TRUE; + } + } + var_dump($headers); + return FALSE; } var_dump(session_start()); @@ -64,7 +64,7 @@ echo "Done"; ?> --EXPECTF-- *** Testing session_regenerate_id() : basic functionality for cookie *** -string(%d) "X-Powered-By: PHP/7.%s +string(%d) "X-Powered-By: PHP/%d.%d.%s Expires: %s Cache-Control: no-store, no-cache, must-revalidate Pragma: no-cache diff --git a/ext/session/tests/session_save_path_variation4.phpt b/ext/session/tests/session_save_path_variation4.phpt index 1cb86e1c30..a95b990dbc 100644 --- a/ext/session/tests/session_save_path_variation4.phpt +++ b/ext/session/tests/session_save_path_variation4.phpt @@ -26,7 +26,7 @@ chdir($initdir); // Delete the existing directory if (file_exists($sessions) === TRUE) { - @rmdir($sessions); + @rmdir($sessions); } var_dump(mkdir($sessions)); diff --git a/ext/session/tests/session_save_path_variation5.phpt b/ext/session/tests/session_save_path_variation5.phpt index 557634c903..b97badf7f6 100644 --- a/ext/session/tests/session_save_path_variation5.phpt +++ b/ext/session/tests/session_save_path_variation5.phpt @@ -27,7 +27,7 @@ chdir($directory); ini_set('open_basedir', '.'); // Delete the existing directory if (file_exists($sessions) === TRUE) { - @rmdir($sessions); + @rmdir($sessions); } var_dump(mkdir($sessions)); diff --git a/ext/session/tests/session_set_save_handler_class_001.phpt b/ext/session/tests/session_set_save_handler_class_001.phpt index ea8fc81d74..33d2a76425 100644 --- a/ext/session/tests/session_set_save_handler_class_001.phpt +++ b/ext/session/tests/session_set_save_handler_class_001.phpt @@ -20,57 +20,57 @@ ob_start(); echo "*** Testing session_set_save_handler() : basic class wrapping existing handler ***\n"; class MySession extends SessionHandler { - public $i = 0; - public function open($path, $name) { - ++$this->i; - echo 'Open ', session_id(), "\n"; - return parent::open($path, $name); - } - public function create_sid() { - // This method should be removed when 5.5 become unsupported. - ++$this->i; - echo 'Old Create SID ', session_id(), "\n"; - return parent::create_sid(); - } - public function read($key) { - ++$this->i; - echo 'Read ', session_id(), "\n"; - return parent::read($key); - } - public function write($key, $data) { - ++$this->i; - echo 'Write ', session_id(), "\n"; - return parent::write($key, $data); - } - public function close() { - ++$this->i; - echo 'Close ', session_id(), "\n"; - return parent::close(); - } - public function createSid() { - // User should use this rather than create_sid() - // If both create_sid() and createSid() exists, - // createSid() is used. - ++$this->i; - echo 'New Create ID ', session_id(), "\n"; - return parent::create_sid(); - } - public function validateId($key) { - ++$this->i; - echo 'Validate ID ', session_id(), "\n"; - return TRUE; - // User must implement their own method and - // cannot call parent as follows. - // return parent::validateSid($key); - } - public function updateTimestamp($key, $data) { - ++$this->i; - echo 'Update Timestamp ', session_id(), "\n"; - return parent::write($key, $data); - // User must implement their own method and - // cannot call parent as follows - // return parent::updateTimestamp($key, $data); - } + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function create_sid() { + // This method should be removed when 5.5 become unsupported. + ++$this->i; + echo 'Old Create SID ', session_id(), "\n"; + return parent::create_sid(); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } + public function write($key, $data) { + ++$this->i; + echo 'Write ', session_id(), "\n"; + return parent::write($key, $data); + } + public function close() { + ++$this->i; + echo 'Close ', session_id(), "\n"; + return parent::close(); + } + public function createSid() { + // User should use this rather than create_sid() + // If both create_sid() and createSid() exists, + // createSid() is used. + ++$this->i; + echo 'New Create ID ', session_id(), "\n"; + return parent::create_sid(); + } + public function validateId($key) { + ++$this->i; + echo 'Validate ID ', session_id(), "\n"; + return TRUE; + // User must implement their own method and + // cannot call parent as follows. + // return parent::validateSid($key); + } + public function updateTimestamp($key, $data) { + ++$this->i; + echo 'Update Timestamp ', session_id(), "\n"; + return parent::write($key, $data); + // User must implement their own method and + // cannot call parent as follows + // return parent::updateTimestamp($key, $data); + } } $oldHandler = ini_get('session.save_handler'); 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 29b1d270c6..6343cfdc0e 100644 --- a/ext/session/tests/session_set_save_handler_class_002.phpt +++ b/ext/session/tests/session_set_save_handler_class_002.phpt @@ -19,46 +19,46 @@ ob_start(); echo "*** Testing session_set_save_handler() : full handler implementation ***\n"; class MySession2 extends SessionHandler { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - return true; - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + return true; + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } } $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, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); session_start(); $_SESSION['foo'] = "hello"; diff --git a/ext/session/tests/session_set_save_handler_class_003.phpt b/ext/session/tests/session_set_save_handler_class_003.phpt index ba0311b96b..b3aba74989 100644 --- a/ext/session/tests/session_set_save_handler_class_003.phpt +++ b/ext/session/tests/session_set_save_handler_class_003.phpt @@ -19,22 +19,22 @@ ob_start(); echo "*** Testing session_set_save_handler() : inheritance ***\n"; class MySession3 extends SessionHandler { - public $i = 0; - public function open($path, $name) { - ++$this->i; - return parent::open($path, $name); - } - public function read($key) { - ++$this->i; - return parent::read($key); - } + public $i = 0; + public function open($path, $name) { + ++$this->i; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + return parent::read($key); + } } class MySession4 extends MySession3 { - public function write($id, $data) { - $this->i = "hai"; - return parent::write($id, $data); - } + public function write($id, $data) { + $this->i = "hai"; + return parent::write($id, $data); + } } $handler = new MySession3; 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 bada7f52c5..c6f8dfe622 100644 --- a/ext/session/tests/session_set_save_handler_class_005.phpt +++ b/ext/session/tests/session_set_save_handler_class_005.phpt @@ -20,15 +20,15 @@ ob_start(); echo "*** Testing session_set_save_handler() : incomplete implementation ***\n"; class MySession6 extends SessionHandler { - public function open($path, $name) { - // don't call parent - return true; - } - - public function read($id) { - // should error because parent::open hasn't been called - return parent::read($id); - } + public function open($path, $name) { + // don't call parent + return true; + } + + public function read($id) { + // should error because parent::open hasn't been called + return parent::read($id); + } } $handler = new MySession6; diff --git a/ext/session/tests/session_set_save_handler_class_006.phpt b/ext/session/tests/session_set_save_handler_class_006.phpt index 3f86437207..5b7d3be084 100644 --- a/ext/session/tests/session_set_save_handler_class_006.phpt +++ b/ext/session/tests/session_set_save_handler_class_006.phpt @@ -19,19 +19,19 @@ ob_start(); echo "*** Testing session_set_save_handler() : using objects in close ***\n"; class MySession7_Foo { - public $state = 'ok'; - function __destruct() { - $this->state = 'destroyed'; - } + public $state = 'ok'; + function __destruct() { + $this->state = 'destroyed'; + } } class MySession7 extends SessionHandler { - public $foo; - public function close() { - var_dump($this->foo); - @var_dump($GLOBALS['bar']); - return parent::close(); - } + public $foo; + public function close() { + var_dump($this->foo); + @var_dump($GLOBALS['bar']); + return parent::close(); + } } $bar = new MySession7_Foo; diff --git a/ext/session/tests/session_set_save_handler_class_007.phpt b/ext/session/tests/session_set_save_handler_class_007.phpt index 0416a894c6..b2ad9eee34 100644 --- a/ext/session/tests/session_set_save_handler_class_007.phpt +++ b/ext/session/tests/session_set_save_handler_class_007.phpt @@ -19,28 +19,28 @@ ob_start(); echo "*** Testing session_set_save_handler() : manual shutdown, reopen ***\n"; class MySession extends SessionHandler { - public $num; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - } - public function finish() { - $id = session_id(); - echo "(#$this->num) finish called $id\n"; - session_write_close(); - } - public function write($id, $data) { - echo "(#$this->num) writing $id = $data\n"; - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - echo "(#$this->num) closing $id\n"; - return parent::close(); - } + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } } $handler = new MySession(1); diff --git a/ext/session/tests/session_set_save_handler_class_008.phpt b/ext/session/tests/session_set_save_handler_class_008.phpt index da9611a8c7..1d39fbd535 100644 --- a/ext/session/tests/session_set_save_handler_class_008.phpt +++ b/ext/session/tests/session_set_save_handler_class_008.phpt @@ -19,28 +19,28 @@ ob_start(); echo "*** Testing session_set_save_handler() : manual shutdown ***\n"; class MySession extends SessionHandler { - public $num; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - } - public function finish() { - $id = session_id(); - echo "(#$this->num) finish called $id\n"; - session_write_close(); - } - public function write($id, $data) { - echo "(#$this->num) writing $id = $data\n"; - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - echo "(#$this->num) closing $id\n"; - return parent::close(); - } + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } } $handler = new MySession(1); diff --git a/ext/session/tests/session_set_save_handler_class_009.phpt b/ext/session/tests/session_set_save_handler_class_009.phpt index d878450540..6969542251 100644 --- a/ext/session/tests/session_set_save_handler_class_009.phpt +++ b/ext/session/tests/session_set_save_handler_class_009.phpt @@ -19,28 +19,28 @@ ob_start(); echo "*** Testing session_set_save_handler() : implicit shutdown ***\n"; class MySession extends SessionHandler { - public $num; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - } - public function finish() { - $id = session_id(); - echo "(#$this->num) finish called $id\n"; - $this->shutdown(); - } - public function write($id, $data) { - echo "(#$this->num) writing $id = $data\n"; - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - echo "(#$this->num) closing $id\n"; - return parent::close(); - } + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + $this->shutdown(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } } $handler = new MySession(1); diff --git a/ext/session/tests/session_set_save_handler_class_010.phpt b/ext/session/tests/session_set_save_handler_class_010.phpt index 2424a08d68..8734f71f9f 100644 --- a/ext/session/tests/session_set_save_handler_class_010.phpt +++ b/ext/session/tests/session_set_save_handler_class_010.phpt @@ -19,28 +19,28 @@ ob_start(); echo "*** Testing session_set_save_handler() : manual shutdown function ***\n"; class MySession extends SessionHandler { - public $num; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - } - public function finish() { - $id = session_id(); - echo "(#$this->num) finish called $id\n"; - session_write_close(); - } - public function write($id, $data) { - echo "(#$this->num) writing $id = $data\n"; - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - echo "(#$this->num) closing $id\n"; - return parent::close(); - } + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } } $handler = new MySession(1); diff --git a/ext/session/tests/session_set_save_handler_class_011.phpt b/ext/session/tests/session_set_save_handler_class_011.phpt index 05a84a359a..396bdbc59f 100644 --- a/ext/session/tests/session_set_save_handler_class_011.phpt +++ b/ext/session/tests/session_set_save_handler_class_011.phpt @@ -19,33 +19,33 @@ ob_start(); echo "*** Testing session_set_save_handler() : shutdown failure ***\n"; class MySession extends SessionHandler { - public $num; - public $destroyed = false; - public function __construct($num) { - $this->num = $num; - echo "(#$this->num) constructor called\n"; - } - public function __destruct() { - echo "(#$this->num) destructor called\n"; - $this->destroyed = true; - } - public function write($id, $data) { - if ($this->destroyed) { - echo "(#$this->num) destroyed, cannot write\n"; - } else { - echo "(#$this->num) writing $id = $data\n"; - } - return parent::write($id, $data); - } - public function close() { - $id = session_id(); - if ($this->destroyed) { - echo "(#$this->num) destroyed, cannot write\n"; - } else { - echo "(#$this->num) closing $id\n"; - } - return parent::close(); - } + public $num; + public $destroyed = false; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + $this->destroyed = true; + } + public function write($id, $data) { + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) writing $id = $data\n"; + } + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) closing $id\n"; + } + return parent::close(); + } } $handler = new MySession(1); 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 b7bcc3fca6..f81207d2a7 100644 --- a/ext/session/tests/session_set_save_handler_class_012.phpt +++ b/ext/session/tests/session_set_save_handler_class_012.phpt @@ -20,43 +20,41 @@ ob_start(); echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***\n"; class MySession extends SessionHandler { - public $i = 0; - public function open($path, $name) { - ++$this->i; - echo 'Open ', session_id(), "\n"; - // This test was written for broken return value handling - // Mimmick what was actually being tested by returning true here - return (null === parent::open()); - } - public function read($key) { - ++$this->i; - echo 'Read ', session_id(), "\n"; - return parent::read($key); - } + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + // This test was written for broken return value handling + // Mimmick what was actually being tested by returning true here + return (null === parent::open()); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } } $oldHandler = ini_get('session.save_handler'); $handler = new MySession; session_set_save_handler($handler); -var_dump(session_start()); +try { + var_dump(session_start()); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); --EXPECTF-- *** Testing session_set_save_handler() : incorrect arguments for existing handler open *** Open -Warning: SessionHandler::open() expects exactly 2 parameters, 0 given in %s on line %d -Read %s - -Warning: SessionHandler::read(): Parent session handler is not open in %s on line %d +Warning: session_start(): Failed to initialize storage module: user (path: ) in %s on line %d +SessionHandler::open() expects exactly 2 parameters, 0 given -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) +Warning: Undefined variable: _SESSION in %s on line %d string(0) "" string(5) "files" string(4) "user" -int(2) -array(0) { -} +int(1) +NULL diff --git a/ext/session/tests/session_set_save_handler_class_013.phpt b/ext/session/tests/session_set_save_handler_class_013.phpt index 28e49c9f98..886d6440a7 100644 --- a/ext/session/tests/session_set_save_handler_class_013.phpt +++ b/ext/session/tests/session_set_save_handler_class_013.phpt @@ -19,20 +19,20 @@ ob_start(); echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler close ***\n"; class MySession extends SessionHandler { - public $i = 0; - public function open($path, $name) { - ++$this->i; - echo 'Open ', session_id(), "\n"; - return parent::open($path, $name); - } - public function read($key) { - ++$this->i; - echo 'Read ', session_id(), "\n"; - return parent::read($key); - } - public function close() { - return parent::close(false); - } + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } + public function close() { + return parent::close(false); + } } $oldHandler = ini_get('session.save_handler'); @@ -41,6 +41,7 @@ session_set_save_handler($handler); session_start(); var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); +?> --EXPECTF-- *** Testing session_set_save_handler() : incorrect arguments for existing handler close *** Open @@ -52,4 +53,10 @@ int(2) array(0) { } -Warning: SessionHandler::close() expects exactly 0 parameters, 1 given in %s on line %d +Fatal error: Uncaught ArgumentCountError: SessionHandler::close() expects exactly 0 parameters, 1 given in %s:%d +Stack trace: +#0 %s(%d): SessionHandler->close(false) +#1 [internal function]: MySession->close() +#2 [internal function]: session_write_close() +#3 {main} + thrown in %s on line %d 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 eadfead304..03bb8eaf95 100644 --- a/ext/session/tests/session_set_save_handler_class_016.phpt +++ b/ext/session/tests/session_set_save_handler_class_016.phpt @@ -19,44 +19,44 @@ ob_start(); echo "*** Testing session_set_save_handler() function: class with create_sid ***\n"; class MySession2 extends SessionHandler { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return parent::create_sid(); - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return parent::create_sid(); + } } $handler = new MySession2; 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 460552a620..563d86c013 100644 --- a/ext/session/tests/session_set_save_handler_class_017.phpt +++ b/ext/session/tests/session_set_save_handler_class_017.phpt @@ -19,44 +19,44 @@ ob_start(); echo "*** Testing session_set_save_handler() function: class with create_sid ***\n"; class MySession2 extends SessionHandler { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return 'my_sid'; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return pathinfo(__FILE__)['filename']; + } } $handler = new MySession2; @@ -72,12 +72,12 @@ session_unset(); session_start(); var_dump($_SESSION); - -session_write_close(); -session_unset(); ---EXPECTF-- +--CLEAN-- +<?php +@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_class_017'); +--EXPECT-- *** Testing session_set_save_handler() function: class with create_sid *** -string(%d) "my_sid" +string(34) "session_set_save_handler_class_017" string(4) "user" array(1) { ["foo"]=> diff --git a/ext/session/tests/session_set_save_handler_class_018.phpt b/ext/session/tests/session_set_save_handler_class_018.phpt index c0b2eb61bf..30d72b4708 100644 --- a/ext/session/tests/session_set_save_handler_class_018.phpt +++ b/ext/session/tests/session_set_save_handler_class_018.phpt @@ -19,48 +19,48 @@ ob_start(); echo "*** Testing session_set_save_handler() function: class with validate_sid ***\n"; class MySession2 extends SessionHandler { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return @file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return file_put_contents($this->path . $id, $data)===FALSE ? FALSE : TRUE ; - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return 'my_sid'; - } - - public function validate_sid($id) { - return 'my_sid'===$id; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data)===FALSE ? FALSE : TRUE ; + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return pathinfo(__FILE__)['filename']; + } + + public function validate_sid($id) { + return pathinfo(__FILE__)['filename']===$id; + } } $handler = new MySession2; @@ -76,12 +76,12 @@ session_unset(); session_start(); var_dump($_SESSION); - -session_write_close(); -session_unset(); ---EXPECTF-- +--CLEAN-- +<?php +@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_class_018'); +--EXPECT-- *** Testing session_set_save_handler() function: class with validate_sid *** -string(%d) "my_sid" +string(34) "session_set_save_handler_class_018" string(4) "user" array(1) { ["foo"]=> 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 362ad90dd6..c1981c91b0 100644 --- a/ext/session/tests/session_set_save_handler_iface_001.phpt +++ b/ext/session/tests/session_set_save_handler_iface_001.phpt @@ -19,45 +19,45 @@ ob_start(); echo "*** Testing session_set_save_handler() function: interface ***\n"; class MySession2 implements SessionHandlerInterface { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } } $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, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); session_start(); $_SESSION['foo'] = "hello"; 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 bc9f801a5e..cd8f6af9d9 100644 --- a/ext/session/tests/session_set_save_handler_iface_002.phpt +++ b/ext/session/tests/session_set_save_handler_iface_002.phpt @@ -19,71 +19,72 @@ ob_start(); echo "*** Testing session_set_save_handler() function: interface wrong ***\n"; interface MySessionHandlerInterface { - public function open($path, $name); - public function close(); - public function read($id); - public function write($id, $data); - public function destroy($id); - public function gc($maxlifetime); + public function open($path, $name); + public function close(); + public function read($id); + public function write($id, $data); + public function destroy($id); + public function gc($maxlifetime); } class MySession2 implements MySessionHandlerInterface { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } - - public function write($id, $data) { - echo "Unsupported session handler in use\n"; - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + echo "Unsupported session handler in use\n"; + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } } function good_write($id, $data) { - global $handler; - echo "good handler writing\n"; - return file_put_contents($handler->path . $id, $data); + global $handler; + echo "good handler writing\n"; + return file_put_contents($handler->path . $id, $data); } $handler = new MySession2; $ret = session_set_save_handler(array($handler, 'open'), array($handler, 'close'), - array($handler, 'read'), 'good_write', array($handler, 'destroy'), array($handler, 'gc')); + array($handler, 'read'), 'good_write', array($handler, 'destroy'), array($handler, 'gc')); var_dump($ret); -$ret = session_set_save_handler($handler); -var_dump($ret); +try { + $ret = session_set_save_handler($handler); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} session_start(); --EXPECTF-- *** Testing session_set_save_handler() function: interface wrong *** bool(true) - -Warning: session_set_save_handler() expects parameter 1 to be SessionHandlerInterface, object given in %s -bool(false) +session_set_save_handler() expects parameter 1 to be SessionHandlerInterface, object given good handler writing diff --git a/ext/session/tests/session_set_save_handler_iface_003.phpt b/ext/session/tests/session_set_save_handler_iface_003.phpt index 5a73d6d5f5..61714e0bb3 100644 --- a/ext/session/tests/session_set_save_handler_iface_003.phpt +++ b/ext/session/tests/session_set_save_handler_iface_003.phpt @@ -19,45 +19,45 @@ ob_start(); echo "*** Testing session_set_save_handler() function: id interface ***\n"; class MySession2 implements SessionHandlerInterface, SessionIdInterface { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return @file_get_contents($this->path . $id); - } - - public function write($id, $data) { - // Empty $data = 0 = false - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return 'my_sid'; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + // Empty $data = 0 = false + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return pathinfo(__FILE__)['filename']; + } } $handler = new MySession2; @@ -73,12 +73,12 @@ session_unset(); session_start(); var_dump($_SESSION); - -session_write_close(); -session_unset(); ---EXPECTF-- +--CLEAN-- +<?php +@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_iface_003'); +--EXPECT-- *** Testing session_set_save_handler() function: id interface *** -string(%d) "my_sid" +string(34) "session_set_save_handler_iface_003" string(4) "user" array(1) { ["foo"]=> diff --git a/ext/session/tests/session_set_save_handler_sid_001.phpt b/ext/session/tests/session_set_save_handler_sid_001.phpt index 4d297d98f7..d4097158ed 100644 --- a/ext/session/tests/session_set_save_handler_sid_001.phpt +++ b/ext/session/tests/session_set_save_handler_sid_001.phpt @@ -13,50 +13,50 @@ ob_start(); echo "*** Testing session_set_save_handler() function: create_sid ***\n"; class MySession2 { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return @file_get_contents($this->path . $id); - } - - public function write($id, $data) { - // Empty $data = 0 = false - return (bool)file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return 'my_sid'; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return (string)@file_get_contents($this->path . $id); + } + + public function write($id, $data) { + // Empty $data = 0 = false + return (bool)file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return pathinfo(__FILE__)['filename']; + } } $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')); + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'), array($handler, 'create_sid')); session_start(); $_SESSION['foo'] = "hello"; @@ -68,12 +68,12 @@ session_unset(); session_start(); var_dump($_SESSION); - -session_write_close(); -session_unset(); ---EXPECTF-- +--CLEAN-- +<?php +@unlink(session_save_path().'/u_sess_PHPSESSIDsession_set_save_handler_sid_001'); +--EXPECT-- *** Testing session_set_save_handler() function: create_sid *** -string(%d) "my_sid" +string(32) "session_set_save_handler_sid_001" string(4) "user" array(1) { ["foo"]=> 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 76ffb63991..faa7663655 100644 --- a/ext/session/tests/session_set_save_handler_sid_002.phpt +++ b/ext/session/tests/session_set_save_handler_sid_002.phpt @@ -14,49 +14,49 @@ ob_start(); echo "*** Testing session_set_save_handler() function: create_sid ***\n"; class MySession2 { - public $path; - - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } - - public function close() { - return true; - } - - public function read($id) { - return @file_get_contents($this->path . $id); - } - - public function write($id, $data) { - return file_put_contents($this->path . $id, $data); - } - - public function destroy($id) { - @unlink($this->path . $id); - } - - public function gc($maxlifetime) { - foreach (glob($this->path . '*') as $filename) { - if (filemtime($filename) + $maxlifetime < time()) { - @unlink($filename); - } - } - return true; - } - - public function create_sid() { - return null; - } + public $path; + + public function open($path, $name) { + if (!$path) { + $path = sys_get_temp_dir(); + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } + + public function create_sid() { + return null; + } } $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')); + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc'), array($handler, 'create_sid')); session_start(); $_SESSION['foo'] = "hello"; diff --git a/ext/session/tests/session_set_save_handler_variation4.phpt b/ext/session/tests/session_set_save_handler_variation4.phpt index bf74385839..abe3abbeb2 100644 --- a/ext/session/tests/session_set_save_handler_variation4.phpt +++ b/ext/session/tests/session_set_save_handler_variation4.phpt @@ -23,9 +23,9 @@ ob_start(); echo "*** Testing session_set_save_handler() : variation ***\n"; function noisy_gc($maxlifetime) { - echo("GC [".$maxlifetime."]\n"); - echo gc($maxlifetime)." deleted\n"; - return true; + echo("GC [".$maxlifetime."]\n"); + echo gc($maxlifetime)." deleted\n"; + return true; } require_once "save_handler.inc"; diff --git a/ext/session/tests/session_set_save_handler_variation5.phpt b/ext/session/tests/session_set_save_handler_variation5.phpt index 23847aadf4..ad11729b94 100644 --- a/ext/session/tests/session_set_save_handler_variation5.phpt +++ b/ext/session/tests/session_set_save_handler_variation5.phpt @@ -22,9 +22,9 @@ ob_start(); */ function noisy_gc($maxlifetime) { - echo("GC [".$maxlifetime."]\n"); - echo gc($maxlifetime)." deleted\n"; - return true; + echo("GC [".$maxlifetime."]\n"); + echo gc($maxlifetime)." deleted\n"; + return true; } echo "*** Testing session_set_save_handler() : variation ***\n"; diff --git a/ext/session/tests/skipif.inc b/ext/session/tests/skipif.inc index e63f963c5c..c259d9eaca 100644 --- a/ext/session/tests/skipif.inc +++ b/ext/session/tests/skipif.inc @@ -9,17 +9,17 @@ if (!extension_loaded("session")) { } $save_path = ini_get("session.save_path"); if ($save_path) { - if (!file_exists($save_path)) { - die("skip Session save_path doesn't exist"); - } + if (!file_exists($save_path)) { + die("skip Session save_path doesn't exist"); + } - if ($save_path && !@is_writable($save_path)) { - if (($p = strpos($save_path, ';')) !== false) { - $save_path = substr($save_path, ++$p); - } - if (!@is_writable($save_path)) { - die("skip session.save_path $save_path is not writable\n"); - } - } + if ($save_path && !@is_writable($save_path)) { + if (($p = strpos($save_path, ';')) !== false) { + $save_path = substr($save_path, ++$p); + } + if (!@is_writable($save_path)) { + die("skip session.save_path $save_path is not writable\n"); + } + } } ?> |