Merge pull request #2449 from cakephp/fix-session-cyclic-error

Fixed error in CakeSession that would call start() in an infinite loop
This commit is contained in:
José Lorenzo Rodríguez 2013-12-09 02:18:21 -08:00
commit 6358741944
3 changed files with 82 additions and 22 deletions

View file

@ -546,9 +546,13 @@ class CakeSessionTest extends CakeTestCase {
'engine' => 'TestAppLibSession'
)
));
TestCakeSession::destroy();
TestCakeSession::start();
$this->assertTrue(TestCakeSession::started());
TestCakeSession::destroy();
$this->assertFalse(TestCakeSession::started());
App::build();
}
@ -570,9 +574,12 @@ class CakeSessionTest extends CakeTestCase {
)
));
TestCakeSession::destroy();
TestCakeSession::start();
$this->assertTrue(TestCakeSession::started());
TestCakeSession::destroy();
$this->assertFalse(TestCakeSession::started());
App::build();
}
@ -750,4 +757,31 @@ class CakeSessionTest extends CakeTestCase {
$this->assertEquals(400, Configure::read('Session.timeout'));
}
/**
* Proves that invalid sessions will be destroyed and re-created
* if invalid
*
* @return void
*/
public function testInvalidSessionRenew() {
TestCakeSession::start();
$this->assertNotEmpty($_SESSION['Config']);
$data = $_SESSION;
session_write_close();
$_SESSION = null;
TestCakeSession::start();
$this->assertEquals($data, $_SESSION);
TestCakeSession::write('Foo', 'Bar');
session_write_close();
$_SESSION = null;
TestCakeSession::userAgent('bogus!');
TestCakeSession::start();
$this->assertNotEquals($data, $_SESSION);
$this->assertEquals('bogus!', $_SESSION['Config']['userAgent']);
}
}