mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
Merging in changes from Voidet to correct session times. Minutes were
being used instead of seconds, for a value that expected seconds. Conflicts: cake/libs/cake_session.php cake/tests/cases/libs/controller/components/session.test.php
This commit is contained in:
parent
b9383f13dc
commit
c119ec4d23
3 changed files with 16 additions and 11 deletions
|
@ -167,7 +167,7 @@
|
||||||
Configure::write('Session.cookie', 'CAKEPHP');
|
Configure::write('Session.cookie', 'CAKEPHP');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session time out time (in seconds).
|
* Session time out time (in minutes).
|
||||||
* Actual value depends on 'Security.level' setting.
|
* Actual value depends on 'Security.level' setting.
|
||||||
*/
|
*/
|
||||||
Configure::write('Session.timeout', '120');
|
Configure::write('Session.timeout', '120');
|
||||||
|
|
|
@ -125,7 +125,7 @@ class CakeSession extends Object {
|
||||||
/**
|
/**
|
||||||
* Session timeout multiplier factor
|
* Session timeout multiplier factor
|
||||||
*
|
*
|
||||||
* @var ineteger
|
* @var integer
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $timeout = null;
|
var $timeout = null;
|
||||||
|
@ -188,7 +188,7 @@ class CakeSession extends Object {
|
||||||
if (!class_exists('Security')) {
|
if (!class_exists('Security')) {
|
||||||
App::import('Core', 'Security');
|
App::import('Core', 'Security');
|
||||||
}
|
}
|
||||||
$this->sessionTime = $this->time + (Security::inactiveMins() * Configure::read('Session.timeout'));
|
$this->sessionTime = $this->time + (Security::inactiveMins() * 60 * Configure::read('Session.timeout'));
|
||||||
$this->security = Configure::read('Security.level');
|
$this->security = Configure::read('Security.level');
|
||||||
}
|
}
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
@ -466,7 +466,7 @@ class CakeSession extends Object {
|
||||||
if ($iniSet && ($this->security === 'high' || $this->security === 'medium')) {
|
if ($iniSet && ($this->security === 'high' || $this->security === 'medium')) {
|
||||||
ini_set('session.referer_check', $this->host);
|
ini_set('session.referer_check', $this->host);
|
||||||
}
|
}
|
||||||
$this->cookieLifeTime = Configure::read('Session.timeout') * Security::inactiveMins();
|
$this->cookieLifeTime = Configure::read('Session.timeout') * (Security::inactiveMins() * 60);
|
||||||
|
|
||||||
switch (Configure::read('Session.save')) {
|
switch (Configure::read('Session.save')) {
|
||||||
case 'cake':
|
case 'cake':
|
||||||
|
@ -593,7 +593,7 @@ class CakeSession extends Object {
|
||||||
$check -= 1;
|
$check -= 1;
|
||||||
$this->write('Config.timeout', $check);
|
$this->write('Config.timeout', $check);
|
||||||
|
|
||||||
if (time() > ($time - (Security::inactiveMins() * Configure::read('Session.timeout')) + 2) || $check < 1) {
|
if (time() > ($time - (Security::inactiveMins() * 60 * Configure::read('Session.timeout')) + 2) || $check < 1) {
|
||||||
$this->renew();
|
$this->renew();
|
||||||
$this->write('Config.timeout', Security::inactiveMins());
|
$this->write('Config.timeout', Security::inactiveMins());
|
||||||
}
|
}
|
||||||
|
@ -735,7 +735,7 @@ class CakeSession extends Object {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __write($id, $data) {
|
function __write($id, $data) {
|
||||||
$expires = time() + Configure::read('Session.timeout') * Security::inactiveMins();
|
$expires = time() + Configure::read('Session.timeout') * Security::inactiveMins() * 60;
|
||||||
$model =& ClassRegistry::getObject('Session');
|
$model =& ClassRegistry::getObject('Session');
|
||||||
$return = $model->save(compact('id', 'data', 'expires'));
|
$return = $model->save(compact('id', 'data', 'expires'));
|
||||||
return $return;
|
return $return;
|
||||||
|
|
|
@ -341,7 +341,7 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$Session->destroy('Test');
|
$Session->destroy('Test');
|
||||||
$this->assertNull($Session->read('Test'));
|
$this->assertNull($Session->read('Test'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testSessionTimeout method
|
* testSessionTimeout method
|
||||||
*
|
*
|
||||||
|
@ -354,28 +354,33 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
Configure::write('Security.level', 'low');
|
Configure::write('Security.level', 'low');
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
|
|
||||||
|
$this->assertEqual($Session->sessionTime, mktime() + (300 * 60 * Configure::read('Session.timeout')));
|
||||||
$this->assertEqual($_SESSION['Config']['timeout'], Security::inactiveMins());
|
$this->assertEqual($_SESSION['Config']['timeout'], Security::inactiveMins());
|
||||||
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
|
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
|
||||||
$this->assertEqual($Session->time, mktime());
|
$this->assertEqual($Session->time, mktime());
|
||||||
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * Configure::read('Session.timeout')));
|
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * 60 * Configure::read('Session.timeout')));
|
||||||
|
|
||||||
session_destroy();
|
session_destroy();
|
||||||
Configure::write('Security.level', 'medium');
|
Configure::write('Security.level', 'medium');
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
|
$this->assertEqual($Session->sessionTime, mktime() + (100 * 60 * Configure::read('Session.timeout')));
|
||||||
$this->assertEqual($_SESSION['Config']['timeout'], Security::inactiveMins());
|
$this->assertEqual($_SESSION['Config']['timeout'], Security::inactiveMins());
|
||||||
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
|
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
|
||||||
$this->assertEqual($Session->time, mktime());
|
$this->assertEqual($Session->time, mktime());
|
||||||
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * Configure::read('Session.timeout')));
|
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * 60 * Configure::read('Session.timeout')));
|
||||||
|
|
||||||
|
|
||||||
session_destroy();
|
session_destroy();
|
||||||
Configure::write('Security.level', 'high');
|
Configure::write('Security.level', 'high');
|
||||||
$Session =& new SessionComponent();
|
$Session =& new SessionComponent();
|
||||||
$Session->write('Test', 'some value');
|
$Session->write('Test', 'some value');
|
||||||
|
$this->assertEqual($Session->sessionTime, mktime() + (10 * 60 * Configure::read('Session.timeout')));
|
||||||
$this->assertEqual($_SESSION['Config']['timeout'], Security::inactiveMins());
|
$this->assertEqual($_SESSION['Config']['timeout'], Security::inactiveMins());
|
||||||
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
|
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
|
||||||
$this->assertEqual($Session->time, mktime());
|
$this->assertEqual($Session->time, mktime());
|
||||||
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * Configure::read('Session.timeout')));
|
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * 60 * Configure::read('Session.timeout')));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue