mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Add test for path containing question, and fix assignment of CakeSession::path
This commit is contained in:
parent
f5565895e9
commit
a63474a54d
2 changed files with 33 additions and 24 deletions
|
@ -144,6 +144,7 @@ class CakeSession {
|
||||||
if ($start === true) {
|
if ($start === true) {
|
||||||
self::_setPath($base);
|
self::_setPath($base);
|
||||||
self::_setHost();
|
self::_setHost();
|
||||||
|
self::start();
|
||||||
}
|
}
|
||||||
if (isset($_SESSION) || $start === true) {
|
if (isset($_SESSION) || $start === true) {
|
||||||
self::$sessionTime = self::$time + (Security::inactiveMins() * Configure::read('Session.timeout'));
|
self::$sessionTime = self::$time + (Security::inactiveMins() * Configure::read('Session.timeout'));
|
||||||
|
@ -162,14 +163,13 @@ class CakeSession {
|
||||||
self::$path = '/';
|
self::$path = '/';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$path = $base;
|
|
||||||
if (strpos($base, 'index.php') !== false) {
|
if (strpos($base, 'index.php') !== false) {
|
||||||
self::$path = str_replace('index.php', '', $base);
|
$base = str_replace('index.php', '', $base);
|
||||||
}
|
}
|
||||||
if (strpos($base, '?') !== false) {
|
if (strpos($base, '?') !== false) {
|
||||||
self::$path = str_replace('?', '', $base);
|
$base = str_replace('?', '', $base);
|
||||||
}
|
}
|
||||||
|
self::$path = $base;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,28 +222,19 @@ class CakeSession {
|
||||||
* @return boolean True if session was started
|
* @return boolean True if session was started
|
||||||
*/
|
*/
|
||||||
public static function start() {
|
public static function start() {
|
||||||
if (!self::started()) {
|
if (self::started()) {
|
||||||
session_write_close();
|
return true;
|
||||||
self::__initSession();
|
|
||||||
self::_startSession();
|
|
||||||
}
|
}
|
||||||
return self::started();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
session_write_close();
|
||||||
* Begins the session if it hasn't already been started, and runs _checkValid which sets up some
|
self::__initSession();
|
||||||
* session tampering settings.
|
self::_startSession();
|
||||||
*
|
$started = self::started();
|
||||||
* @return void
|
|
||||||
*/
|
if (!self::id() && $started) {
|
||||||
public static function begin() {
|
self::_checkValid();
|
||||||
if (self::started() === false) {
|
|
||||||
if (!self::id() && self::start()) {
|
|
||||||
self::_checkValid();
|
|
||||||
} else {
|
|
||||||
self::start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$error = array();
|
self::$error = array();
|
||||||
return self::started();
|
return self::started();
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,17 +96,35 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testSessionPath() {
|
function testSessionPath() {
|
||||||
// $Session = new CakeSession('/index.php');
|
|
||||||
TestCakeSession::init('/index.php');
|
TestCakeSession::init('/index.php');
|
||||||
$this->assertEqual('/', TestCakeSession::$path);
|
$this->assertEqual('/', TestCakeSession::$path);
|
||||||
|
|
||||||
TestCakeSession::init('/sub_dir/index.php');
|
TestCakeSession::init('/sub_dir/index.php');
|
||||||
$this->assertEqual('/sub_dir/', TestCakeSession::$path);
|
$this->assertEqual('/sub_dir/', TestCakeSession::$path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testCakeSessionPathEmpty
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testCakeSessionPathEmpty() {
|
||||||
TestCakeSession::init('');
|
TestCakeSession::init('');
|
||||||
$this->assertEqual('/', TestCakeSession::$path, 'Session path is empty, with "" as $base needs to be / %s');
|
$this->assertEqual('/', TestCakeSession::$path, 'Session path is empty, with "" as $base needs to be / %s');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testCakeSessionPathContainsParams
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testCakeSessionPathContainsQuestion() {
|
||||||
|
TestCakeSession::init('/index.php?');
|
||||||
|
$this->assertEqual('/', TestCakeSession::$path);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testCheck method
|
* testCheck method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue