diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-03 22:52:20 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-03 22:52:20 +0100 |
| commit | f8d795820e780a6322e054c26c581570613c14f0 (patch) | |
| tree | 99d3ae01ce564752807341c5743863b4c92513f8 /ext/session/tests | |
| parent | d2cb200e10ada6fa44c54a29292bb4665728fff0 (diff) | |
| download | php-git-f8d795820e780a6322e054c26c581570613c14f0.tar.gz | |
Reindent phpt files
Diffstat (limited to 'ext/session/tests')
49 files changed, 686 insertions, 686 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/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_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_regenerate_id_cookie.phpt b/ext/session/tests/session_regenerate_id_cookie.phpt index 79d99f3375..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()); 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 bbf125bc9a..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,19 +20,19 @@ 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'); 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 79c732f30c..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'); 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 456ea55dff..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 pathinfo(__FILE__)['filename']; - } + 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; 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 7336b4ae88..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 (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; - } + 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; 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 cf01d8badb..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,61 +19,61 @@ 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); try { 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 40474cb72e..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 (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']; - } + 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; 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 bd8c18424f..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 $path; - public function open($path, $name) { - if (!$path) { - $path = sys_get_temp_dir(); - } - $this->path = $path . '/u_sess_' . $name; - return true; - } + 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 close() { + return true; + } - public function read($id) { - return (string)@file_get_contents($this->path . $id); - } + 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 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 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 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 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"; 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"); + } + } } ?> |
