Permalink
Browse files

Merge branch 'hotfix/3356' into develop

Forward port #3356
  • Loading branch information...
2 parents e9c7523 + 6725bd4 commit bede9495684b02370f9b76fdb97ec3a7928b6607 @weierophinney weierophinney committed Jan 7, 2013
@@ -84,9 +84,7 @@ public function start($preserveStorage = false)
}
session_start();
- if (!$this->isValid()) {
- throw new Exception\RuntimeException('Session validation failed');
- }
+
$storage = $this->getStorage();
// Since session is starting, we need to potentially repopulate our
@@ -97,6 +95,9 @@ public function start($preserveStorage = false)
}
$_SESSION = $storage;
}
+ if (!$this->isValid()) {
+ throw new Exception\RuntimeException('Session validation failed');
+ }
}
/**
@@ -525,16 +525,18 @@ public function testForgetMeShouldSendCookieWithZeroTimestamp()
public function testStartingSessionThatFailsAValidatorShouldRaiseException()
{
$chain = $this->manager->getValidatorChain();
- $chain->attach('session.validate', array($this, 'validateSession'));
+ $chain->attach('session.validate', array(new TestAsset\TestFailingValidator(), 'isValid'));
$this->setExpectedException('Zend\Session\Exception\RuntimeException', 'failed');
$this->manager->start();
}
/**
- * @see testStartingSessionThatFailsAValidatorShouldRaiseException()
+ * @runInSeparateProcess
*/
- public static function validateSession()
+ public function testResumeSessionThatFailsAValidatorShouldRaiseException()
{
- return false;
+ $this->manager->setSaveHandler(new TestAsset\TestSaveHandlerWithValidator);
+ $this->setExpectedException('Zend\Session\Exception\RuntimeException', 'failed');
+ $this->manager->start();
}
}
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * 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)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Session
+ */
+
+namespace ZendTest\Session\TestAsset;
+
+use Zend\Session\Validator\ValidatorInterface;
+
+class TestFailingValidator implements ValidatorInterface
+{
+
+ public function getData()
+ {
+ return false;
+ }
+
+ public function getName()
+ {
+ return __CLASS__;
+ }
+
+ public function isValid()
+ {
+ return $this->getData();
+ }
+}
@@ -0,0 +1,36 @@
+<?php
+/**
+ * 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)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Session
+ */
+
+namespace ZendTest\Session\TestAsset;
+
+use Zend\Session\SaveHandler\SaveHandlerInterface as SaveHandler;
+
+class TestSaveHandlerWithValidator implements SaveHandler
+{
+ public function open($save_path, $name)
+ {return true;}
+
+ public function close()
+ {}
+
+ public function read($id)
+ {
+ return '__ZF|a:1:{s:6:"_VALID";a:1:{s:47:"ZendTest\Session\TestAsset\TestFailingValidator";s:0:"";}}';
+ }
+
+ public function write($id, $data)
+ {}
+
+ public function destroy($id)
+ {}
+
+ public function gc($maxlifetime)
+ {}
+}

0 comments on commit bede949

Please sign in to comment.