Fixes #15318: Fixed "session_name(): Cannot change session name when session is active" errors

This commit is contained in:
bscheshirwork
2018-02-24 01:03:27 +03:00
committed by Alexander Makarov
parent 3c483a812f
commit 7473c422ee
3 changed files with 21 additions and 0 deletions

View File

@ -8,6 +8,7 @@ Yii Framework 2 Change Log
- Bug #15692: Fix ExistValidator with targetRelation ignores filter (developeruz) - Bug #15692: Fix ExistValidator with targetRelation ignores filter (developeruz)
- Bug #15693: Fixed `yii\filters\auth\HttpHeaderAuth` to work correctly when pattern is set but was not matched (bboure) - Bug #15693: Fixed `yii\filters\auth\HttpHeaderAuth` to work correctly when pattern is set but was not matched (bboure)
- Bug #15696: Fix magic getter for ActiveRecord (developeruz) - Bug #15696: Fix magic getter for ActiveRecord (developeruz)
- Bug #15318: Fixed "session_name(): Cannot change session name when session is active" errors (bscheshirwork, samdark)
- Bug #15726: Fix ExistValidator is broken for NOSQL (developeruz) - Bug #15726: Fix ExistValidator is broken for NOSQL (developeruz)
- Enh #15716: Implemented `\Traversable` in `yii\db\ArrayExpression` (silverfire) - Enh #15716: Implemented `\Traversable` in `yii\db\ArrayExpression` (silverfire)
- Bug #15678: Fixed `resetForm()` method in `yii.activeForm.js` which used an undefined variable (Izumi-kun) - Bug #15678: Fixed `resetForm()` method in `yii.activeForm.js` which used an undefined variable (Izumi-kun)

View File

@ -322,7 +322,9 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
*/ */
public function setName($value) public function setName($value)
{ {
$this->freeze();
session_name($value); session_name($value);
$this->unfreeze();
} }
/** /**

View File

@ -70,4 +70,22 @@ class SessionTest extends TestCase
$this->assertNotEquals($oldGcProbability, $newGcProbability); $this->assertNotEquals($oldGcProbability, $newGcProbability);
$this->assertEquals(100, $newGcProbability); $this->assertEquals(100, $newGcProbability);
} }
/**
* Test set name. Also check set name twice and after open
*/
public function testSetName()
{
$session = new Session();
$session->setName('oldName');
$this->assertEquals('oldName', $session->getName());
$session->open();
$session->setName('newName');
$this->assertEquals('newName', $session->getName());
$session->destroy();
}
} }