From 6e76fa7a236eae4c3deabf03acc77ecf44a91e31 Mon Sep 17 00:00:00 2001 From: Martin-P Date: Thu, 15 Jan 2015 23:56:13 +0100 Subject: [PATCH 1/2] Fix undefined variable --- src/SessionManager.php | 5 ++++- test/Service/SessionManagerFactoryTest.php | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/SessionManager.php b/src/SessionManager.php index 77219f64..1a825052 100644 --- a/src/SessionManager.php +++ b/src/SessionManager.php @@ -93,7 +93,10 @@ public function start($preserveStorage = false) $this->registerSaveHandler($saveHandler); } - $oldSessionData = $_SESSION; + $oldSessionData = array(); + if (isset($_SESSION)) { + $oldSessionData = $_SESSION; + } session_start(); diff --git a/test/Service/SessionManagerFactoryTest.php b/test/Service/SessionManagerFactoryTest.php index fee441ba..526fcb65 100644 --- a/test/Service/SessionManagerFactoryTest.php +++ b/test/Service/SessionManagerFactoryTest.php @@ -87,4 +87,16 @@ public function testFactoryWillAddValidatorViaConfiguration() $this->assertEquals(1, $manager->getValidatorChain()->getListeners('session.validate')->count()); } + + /** + * @runInSeparateProcess + */ + public function testStartingSessionManagerFromFactoryDoesNotTriggerUndefinedVariable() + { + $storage = new ArrayStorage(); + $this->services->setService('Zend\Session\Storage\StorageInterface', $storage); + + $manager = $this->services->get('Zend\Session\ManagerInterface'); + $manager->start(); + } } From 966e7d625800d758bc1459a51b37f20e76b8118c Mon Sep 17 00:00:00 2001 From: Martin-P Date: Fri, 16 Jan 2015 17:08:34 +0100 Subject: [PATCH 2/2] Assertion to check if storage is set --- test/Service/SessionManagerFactoryTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Service/SessionManagerFactoryTest.php b/test/Service/SessionManagerFactoryTest.php index 526fcb65..5a2fc0c8 100644 --- a/test/Service/SessionManagerFactoryTest.php +++ b/test/Service/SessionManagerFactoryTest.php @@ -98,5 +98,7 @@ public function testStartingSessionManagerFromFactoryDoesNotTriggerUndefinedVari $manager = $this->services->get('Zend\Session\ManagerInterface'); $manager->start(); + + $this->assertSame($storage, $manager->getStorage()); } }