Resolved Issue: #3748 - offsetGet and __get should do a direct proxy to $_SESSION #3793

Closed
wants to merge 2 commits into
from
View
12 library/Zend/Session/Storage/SessionArrayStorage.php
@@ -22,11 +22,7 @@ class SessionArrayStorage extends AbstractSessionArrayStorage
*/
public function &__get($key)
{
- if (isset($_SESSION[$key])) {
- return $_SESSION[$key];
- }
-
- return null;
+ return $_SESSION[$key];
}
/**
@@ -37,10 +33,6 @@ public function &__get($key)
*/
public function &offsetGet($key)
{
- if (isset($_SESSION[$key])) {
- return $_SESSION[$key];
- }
-
- return null;
+ return $_SESSION[$key];
}
}
View
21 tests/ZendTest/Session/SessionArrayStorageTest.php
@@ -145,4 +145,25 @@ public function testToArrayWithMetaData()
$this->assertSame($expected, $this->storage->toArray(true));
}
+ public function testUndefinedSessionManipulation()
+ {
+ if (version_compare(PHP_VERSION, '5.3.4') < 0) {
+ $this->markTestSkipped('Known issue on versions of PHP less than 5.3.4');
+ }
+
+ $this->storage['foo'] = 'bar';
+ $this->storage['bar'][] = 'bar';
+ $this->storage['baz']['foo'] = 'bar';
+
+ $expected = array(
+ '__ZF' => array(
+ '_REQUEST_ACCESS_TIME' => $this->storage->getRequestAccessTime(),
+ ),
+ 'foo' => 'bar',
+ 'bar' => array('bar'),
+ 'baz' => array('foo' => 'bar'),
+ );
+ $this->assertSame($expected, $this->storage->toArray(true));
+ }
+
}