diff --git a/composer.json b/composer.json index 165d632b..01151e80 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ } }, "require": { - "php": ">=5.3.3", + "php": ">=5.3.23", "zendframework/zend-eventmanager": "self.version", "zendframework/zend-stdlib": "self.version" }, @@ -23,6 +23,7 @@ "zendframework/zend-http": "self.version", "zendframework/zend-servicemanager": "self.version", "zendframework/zend-validator": "self.version", + "zendframework/zend-eventmanager": "self.version", "fabpot/php-cs-fixer": "1.7.*", "satooshi/php-coveralls": "dev-master", "phpunit/PHPUnit": "~4.0" diff --git a/src/Config/SessionConfig.php b/src/Config/SessionConfig.php index e909e504..4dfb24f6 100644 --- a/src/Config/SessionConfig.php +++ b/src/Config/SessionConfig.php @@ -42,6 +42,7 @@ class SessionConfig extends StandardConfig * @var array Valid cache limiters (per session.cache_limiter) */ protected $validCacheLimiters = array( + '', 'nocache', 'public', 'private', diff --git a/src/Container.php b/src/Container.php index 53e2eb0b..7c116290 100644 --- a/src/Container.php +++ b/src/Container.php @@ -9,12 +9,6 @@ namespace Zend\Session; -if (version_compare(PHP_VERSION, '5.3.4', 'lt')) { - class_alias('Zend\Session\AbstractContainer', 'Zend\Session\AbstractBaseContainer'); -} else { - class_alias('Zend\Session\Container\PhpReferenceCompatibility', 'Zend\Session\AbstractBaseContainer'); -} - /** * Session storage container * @@ -23,6 +17,24 @@ class_alias('Zend\Session\Container\PhpReferenceCompatibility', 'Zend\Session\Ab * Additionally, expiries may be absolute TTLs or measured in "hops", which * are based on how many times the key or container were accessed. */ -class Container extends AbstractBaseContainer +class Container extends AbstractContainer { + /** + * Retrieve a specific key in the container + * + * @param string $key + * @return mixed + */ + public function &offsetGet($key) + { + $ret = null; + if (!$this->offsetExists($key)) { + return $ret; + } + $storage = $this->getStorage(); + $name = $this->getName(); + $ret =& $storage[$name][$key]; + + return $ret; + } } diff --git a/src/Container/PhpReferenceCompatibility.php b/src/Container/PhpReferenceCompatibility.php deleted file mode 100644 index a367fba8..00000000 --- a/src/Container/PhpReferenceCompatibility.php +++ /dev/null @@ -1,37 +0,0 @@ -offsetExists($key)) { - return $ret; - } - $storage = $this->getStorage(); - $name = $this->getName(); - $ret =& $storage[$name][$key]; - - return $ret; - } -} diff --git a/src/Service/SessionManagerFactory.php b/src/Service/SessionManagerFactory.php index f69e2987..c8099038 100644 --- a/src/Service/SessionManagerFactory.php +++ b/src/Service/SessionManagerFactory.php @@ -53,6 +53,7 @@ class SessionManagerFactory implements FactoryInterface * - enable_default_container_manager: whether to inject the created instance * as the default manager for Container instances. The default value for * this is true; set it to false to disable. + * - validators: ... * * @param ServiceLocatorInterface $services * @return SessionManager @@ -112,6 +113,15 @@ public function createService(ServiceLocatorInterface $services) ) { $managerConfig = array_merge($managerConfig, $configService['session_manager']); } + // Attach validators to session manager, if any + if (isset($managerConfig['validators'])) { + $chain = $manager->getValidatorChain(); + foreach ($managerConfig['validators'] as $validator) { + $validator = new $validator(); + $chain->attach('session.validate', array($validator, 'isValid')); + + } + } } // If configuration enables the session manager as the default manager for container diff --git a/src/Storage/SessionArrayStorage.php b/src/Storage/SessionArrayStorage.php index 0362077f..a8da9292 100644 --- a/src/Storage/SessionArrayStorage.php +++ b/src/Storage/SessionArrayStorage.php @@ -9,15 +9,30 @@ namespace Zend\Session\Storage; -if (version_compare(PHP_VERSION, '5.3.4', 'lt')) { - class_alias('Zend\Session\Storage\AbstractSessionArrayStorage', 'Zend\Session\Storage\AbstractBaseSessionArrayStorage'); -} else { - class_alias('Zend\Session\Storage\SessionArrayStorage\PhpReferenceCompatibility', 'Zend\Session\Storage\AbstractBaseSessionArrayStorage'); -} - /** * Session storage in $_SESSION */ -class SessionArrayStorage extends AbstractBaseSessionArrayStorage +class SessionArrayStorage extends AbstractSessionArrayStorage { + /** + * Get Offset + * + * @param mixed $key + * @return mixed + */ + public function &__get($key) + { + return $_SESSION[$key]; + } + + /** + * Offset Get + * + * @param mixed $key + * @return mixed + */ + public function &offsetGet($key) + { + return $_SESSION[$key]; + } } diff --git a/src/Storage/SessionArrayStorage/PhpReferenceCompatibility.php b/src/Storage/SessionArrayStorage/PhpReferenceCompatibility.php deleted file mode 100644 index 3a3b2947..00000000 --- a/src/Storage/SessionArrayStorage/PhpReferenceCompatibility.php +++ /dev/null @@ -1,40 +0,0 @@ -markTestSkipped('Known issue on versions of PHP less than 5.3.4'); - } $this->container->foo = array('bar' => 'baz'); unset($this->container['foo']['bar']); $this->assertSame(array(), $this->container->foo); diff --git a/test/SaveHandler/CacheTest.php b/test/SaveHandler/CacheTest.php index f636095b..a8b394f7 100644 --- a/test/SaveHandler/CacheTest.php +++ b/test/SaveHandler/CacheTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/SaveHandler/DbTableGatewayOptionsTest.php b/test/SaveHandler/DbTableGatewayOptionsTest.php index 89908422..12e375c7 100644 --- a/test/SaveHandler/DbTableGatewayOptionsTest.php +++ b/test/SaveHandler/DbTableGatewayOptionsTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/SaveHandler/DbTableGatewayTest.php b/test/SaveHandler/DbTableGatewayTest.php index 687f46dc..27e12444 100644 --- a/test/SaveHandler/DbTableGatewayTest.php +++ b/test/SaveHandler/DbTableGatewayTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/SaveHandler/MongoDBOptionsTest.php b/test/SaveHandler/MongoDBOptionsTest.php index 61869757..5c3332c3 100644 --- a/test/SaveHandler/MongoDBOptionsTest.php +++ b/test/SaveHandler/MongoDBOptionsTest.php @@ -4,7 +4,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/SaveHandler/MongoDBTest.php b/test/SaveHandler/MongoDBTest.php index e6a3084e..15ec22fc 100644 --- a/test/SaveHandler/MongoDBTest.php +++ b/test/SaveHandler/MongoDBTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/Service/ContainerAbstractServiceFactoryTest.php b/test/Service/ContainerAbstractServiceFactoryTest.php index db9d1b83..418ff722 100644 --- a/test/Service/ContainerAbstractServiceFactoryTest.php +++ b/test/Service/ContainerAbstractServiceFactoryTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/Service/SessionConfigFactoryTest.php b/test/Service/SessionConfigFactoryTest.php index a6a60b7f..23a7703c 100644 --- a/test/Service/SessionConfigFactoryTest.php +++ b/test/Service/SessionConfigFactoryTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/Service/SessionManagerFactoryTest.php b/test/Service/SessionManagerFactoryTest.php index ee43f0b7..81a2eaeb 100644 --- a/test/Service/SessionManagerFactoryTest.php +++ b/test/Service/SessionManagerFactoryTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -74,4 +74,17 @@ public function testCanDisableContainerDefaultManagerInjectionViaConfiguration() $manager = $this->services->get('Zend\Session\ManagerInterface'); $this->assertNotSame($manager, Container::getDefaultManager()); } + + public function testFactoryWillAddValidatorViaConfiguration() + { + $config = array('session_manager' => array( + 'validators' => array( + 'Zend\Session\Validator\RemoteAddr', + ), + )); + $this->services->setService('Config', $config); + $manager = $this->services->get('Zend\Session\ManagerInterface'); + + $this->assertEquals(1, $manager->getValidatorChain()->getListeners('session.validate')->count()); + } } diff --git a/test/Service/StorageFactoryTest.php b/test/Service/StorageFactoryTest.php index fd183c09..95bafbc9 100644 --- a/test/Service/StorageFactoryTest.php +++ b/test/Service/StorageFactoryTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/SessionArrayStorageTest.php b/test/SessionArrayStorageTest.php index fe37b67a..ba0d57ef 100644 --- a/test/SessionArrayStorageTest.php +++ b/test/SessionArrayStorageTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -108,9 +108,6 @@ public function testUnset() public function testMultiDimensionalUnset() { - 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'] = array('bar' => array('baz' => 'boo')); unset($this->storage['foo']['bar']['baz']); $this->assertFalse(isset($this->storage['foo']['bar']['baz'])); @@ -144,10 +141,6 @@ public function testToArrayWithMetaData() 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'; diff --git a/test/SessionManagerTest.php b/test/SessionManagerTest.php index b454eefd..19d86ea9 100644 --- a/test/SessionManagerTest.php +++ b/test/SessionManagerTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/SessionStorageTest.php b/test/SessionStorageTest.php index 4229a669..3a47ca85 100644 --- a/test/SessionStorageTest.php +++ b/test/SessionStorageTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -94,9 +94,6 @@ public function testMarkingOneSessionObjectImmutableShouldMarkOtherInstancesImmu public function testMultiDimensionalUnset() { - 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'] = array('bar' => array('baz' => 'boo')); unset($this->storage['foo']['bar']['baz']); $this->assertFalse(isset($this->storage['foo']['bar']['baz'])); diff --git a/test/StorageTest.php b/test/StorageTest.php index c150b006..5fa02d4d 100644 --- a/test/StorageTest.php +++ b/test/StorageTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -242,9 +242,6 @@ public function testToArrayWithMetaData() public function testUnsetMultidimensional() { - 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'] = array('bar' => array('baz' => 'boo')); unset($this->storage['foo']['bar']['baz']); unset($this->storage['foo']['bar']); diff --git a/test/TestAsset/TestFailingValidator.php b/test/TestAsset/TestFailingValidator.php index 36b9e71d..8349c64c 100644 --- a/test/TestAsset/TestFailingValidator.php +++ b/test/TestAsset/TestFailingValidator.php @@ -4,7 +4,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/TestAsset/TestManager.php b/test/TestAsset/TestManager.php index 28dd044b..d72e3e3a 100644 --- a/test/TestAsset/TestManager.php +++ b/test/TestAsset/TestManager.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/TestAsset/TestSaveHandler.php b/test/TestAsset/TestSaveHandler.php index 30fa0cd5..61995048 100644 --- a/test/TestAsset/TestSaveHandler.php +++ b/test/TestAsset/TestSaveHandler.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/TestAsset/TestSaveHandlerWithValidator.php b/test/TestAsset/TestSaveHandlerWithValidator.php index 9d9ddbb2..d617a72b 100644 --- a/test/TestAsset/TestSaveHandlerWithValidator.php +++ b/test/TestAsset/TestSaveHandlerWithValidator.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ diff --git a/test/Validator/RemoteAddrTest.php b/test/Validator/RemoteAddrTest.php index 2ec7b560..43900147 100644 --- a/test/Validator/RemoteAddrTest.php +++ b/test/Validator/RemoteAddrTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */