Merge branch '1.3' of github.com:cakephp/cakephp1x into 1.3

This commit is contained in:
Mark Story 2010-03-25 23:44:53 -04:00
commit 888fdd3dd5
3 changed files with 23 additions and 14 deletions
cake
libs
cake_session.php
controller/components
tests/cases/libs/controller/components

View file

@ -114,6 +114,13 @@ class CakeSession extends Object {
*/ */
var $id = null; var $id = null;
/**
* Session Started
*
* @var boolean
* @access protected
*/
var $_started = false;
/** /**
* Constructor. * Constructor.
* *
@ -181,16 +188,19 @@ class CakeSession extends Object {
/** /**
* Starts the Session. * Starts the Session.
* *
* @param string $name Variable name to check for * @return boolean True if session was started
* @return boolean True if variable is there
* @access public * @access public
*/ */
function start() { function start() {
if ($this->started()) {
return true;
}
if (function_exists('session_write_close')) { if (function_exists('session_write_close')) {
session_write_close(); session_write_close();
} }
$this->__initSession(); $this->__initSession();
return $this->__startSession(); $this->_started = $this->__startSession();
return $this->started();
} }
/** /**
@ -200,7 +210,7 @@ class CakeSession extends Object {
* @return boolean True if session has been started. * @return boolean True if session has been started.
*/ */
function started() { function started() {
if (isset($_SESSION)) { if (isset($_SESSION) && $this->_started) {
return true; return true;
} }
return false; return false;
@ -233,7 +243,7 @@ class CakeSession extends Object {
$this->id = $id; $this->id = $id;
session_id($this->id); session_id($this->id);
} }
if (isset($_SESSION)) { if ($this->started()) {
return session_id(); return session_id();
} else { } else {
return $this->id; return $this->id;

View file

@ -41,12 +41,12 @@ class SessionComponent extends CakeSession {
var $__active = true; var $__active = true;
/** /**
* Used to determine if Session has been started * Used to determine if request are from an Ajax request
* *
* @var boolean * @var boolean
* @access private * @access private
*/ */
var $__started = false; var $__bare = 0;
/** /**
* Class constructor * Class constructor
@ -69,7 +69,7 @@ class SessionComponent extends CakeSession {
* @access public * @access public
*/ */
function startup(&$controller) { function startup(&$controller) {
if ($this->__started === false && $this->__active === true) { if ($this->started() === false && $this->__active === true) {
$this->__start(); $this->__start();
} }
} }
@ -275,15 +275,14 @@ class SessionComponent extends CakeSession {
* @access private * @access private
*/ */
function __start() { function __start() {
if ($this->__started === false) { if ($this->started() === false) {
if (!$this->id() && parent::start()) { if (!$this->id() && parent::start()) {
$this->__started = true;
parent::_checkValid(); parent::_checkValid();
} else { } else {
$this->__started = parent::start(); parent::start();
} }
} }
return $this->__started; return $this->started();
} }
} }

View file

@ -112,13 +112,13 @@ class SessionComponentTest extends CakeTestCase {
Configure::write('Session.start', false); Configure::write('Session.start', false);
$Session =& new SessionComponent(); $Session =& new SessionComponent();
$this->assertFalse($Session->__active); $this->assertFalse($Session->__active);
$this->assertFalse($Session->__started); $this->assertFalse($Session->started());
$Session->startup(new SessionTestController()); $Session->startup(new SessionTestController());
Configure::write('Session.start', true); Configure::write('Session.start', true);
$Session =& new SessionComponent(); $Session =& new SessionComponent();
$this->assertTrue($Session->__active); $this->assertTrue($Session->__active);
$this->assertFalse($Session->__started); $this->assertFalse($Session->started());
$Session->startup(new SessionTestController()); $Session->startup(new SessionTestController());
$this->assertTrue(isset($_SESSION)); $this->assertTrue(isset($_SESSION));