mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-05 11:02:40 +00:00
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:
commit
6358741944
3 changed files with 82 additions and 22 deletions
|
@ -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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue