Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2766' into develop
Browse files Browse the repository at this point in the history
Forward port #2766
  • Loading branch information
weierophinney committed Oct 16, 2012
2 parents ca70c22 + 8937e66 commit f122968
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
20 changes: 17 additions & 3 deletions library/Zend/Session/Storage/ArrayStorage.php
Expand Up @@ -47,13 +47,25 @@ public function __construct(
$iteratorClass = '\\ArrayIterator'
) {
parent::__construct($input, $flags, $iteratorClass);
$this->setMetadata('_REQUEST_ACCESS_TIME', microtime(true));
$this->setRequestAccessTime(microtime(true));
}

/**
* Set the request access time
*
* @param float $time
* @return ArrayStorage
*/
protected function setRequestAccessTime($time)
{
$this->setMetadata('_REQUEST_ACCESS_TIME', $time);
return $this;
}

/**
* Retrieve the request access time
*
* @return int
* @return float
*/
public function getRequestAccessTime()
{
Expand Down Expand Up @@ -289,7 +301,7 @@ public function clear($key = null)
throw new Exception\RuntimeException('Cannot clear storage as it is marked immutable');
}
if (null === $key) {
$this->exchangeArray(array());
$this->fromArray(array());
return $this;
}

Expand Down Expand Up @@ -317,7 +329,9 @@ public function clear($key = null)
*/
public function fromArray(array $array)
{
$ts = $this->getRequestAccessTime();
$this->exchangeArray($array);
$this->setRequestAccessTime($ts);
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Session/Storage/SessionStorage.php
Expand Up @@ -76,7 +76,7 @@ public function __destruct()
*/
public function fromArray(array $array)
{
$this->exchangeArray($array);
parent::fromArray($array);
if ($_SESSION !== $this) {
$_SESSION = $this;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ZendTest/Session/SessionManagerTest.php
Expand Up @@ -311,7 +311,7 @@ public function testPassingClearStorageOptionWhenCallingDestroyClearsStorage()
$storage = $this->manager->getStorage();
$storage['foo'] = 'bar';
$this->manager->destroy(array('clear_storage' => true));
$this->assertSame(array(), (array) $storage);
$this->assertFalse(isset($storage['foo']));
}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/ZendTest/Session/StorageTest.php
Expand Up @@ -220,4 +220,11 @@ public function testClearWhenStorageMarkedImmutableRaisesException()
'Cannot clear storage as it is marked immutable');
$this->storage->clear();
}

public function testRequestAccessTimeIsPreservedEvenInFactoryMethod()
{
$this->assertNotEmpty($this->storage->getRequestAccessTime());
$this->storage->fromArray(array());
$this->assertNotEmpty($this->storage->getRequestAccessTime());
}
}

0 comments on commit f122968

Please sign in to comment.