Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php
  • Loading branch information
Maks3w committed Jan 16, 2013
2 parents 64d00bb + 46100cd commit d80d076
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 23 deletions.
3 changes: 1 addition & 2 deletions library/Zend/Mvc/Controller/Plugin/FlashMessenger.php
Expand Up @@ -15,7 +15,6 @@
use IteratorAggregate;
use Zend\Session\Container;
use Zend\Session\ManagerInterface as Manager;
use Zend\Session\SessionManager;
use Zend\Stdlib\SplQueue;

/**
Expand Down Expand Up @@ -79,7 +78,7 @@ public function setSessionManager(Manager $manager)
public function getSessionManager()
{
if (!$this->session instanceof Manager) {
$this->setSessionManager(new SessionManager());
$this->setSessionManager(Container::getDefaultManager());
}
return $this->session;
}
Expand Down
18 changes: 18 additions & 0 deletions library/Zend/Mvc/Controller/Plugin/PostRedirectGet.php
Expand Up @@ -28,6 +28,24 @@ class PostRedirectGet extends AbstractPlugin
*/
protected $sessionContainer;

/**
* Perform PRG logic
*
* If a null value is present for the $redirect, the current route is
* retrieved and use to generate the URL for redirect.
*
* If the request method is POST, creates a session container set to expire
* after 1 hop containing the values of the POST. It then redirects to the
* specified URL using a status 303.
*
* If the request method is GET, checks to see if we have values in the
* session container, and, if so, returns them; otherwise, it returns a
* boolean false.
*
* @param null|string $redirect
* @param bool $redirectToUrl
* @return \Zend\Http\Response|array|Traversable|false
*/
public function __invoke($redirect = null, $redirectToUrl = false)
{
$controller = $this->getController();
Expand Down
16 changes: 9 additions & 7 deletions library/Zend/Session/SessionManager.php
Expand Up @@ -11,7 +11,6 @@
namespace Zend\Session;

use Zend\EventManager\EventManagerInterface;
use Zend\Session\SaveHandler\SaveHandlerInterface;

/**
* Session ManagerInterface implementation utilizing ext/session
Expand Down Expand Up @@ -43,14 +42,17 @@ class SessionManager extends AbstractManager
protected $validatorChain;

/**
* Destructor
* Ensures that writeClose is called.
* Constructor
*
* @return void
* @param Config\ConfigInterface|null $config
* @param Storage\StorageInterface|null $storage
* @param SaveHandler\SaveHandlerInterface|null $saveHandler
* @throws Exception\RuntimeException
*/
public function __destruct()
public function __construct(Config\ConfigInterface $config = null, Storage\StorageInterface $storage = null, SaveHandler\SaveHandlerInterface $saveHandler = null)
{
$this->writeClose();
parent::__construct($config, $storage, $saveHandler);
register_shutdown_function(array($this, 'writeClose'));
}

/**
Expand Down Expand Up @@ -89,7 +91,7 @@ public function start($preserveStorage = false)
}

$saveHandler = $this->getSaveHandler();
if ($saveHandler instanceof SaveHandlerInterface) {
if ($saveHandler instanceof SaveHandler\SaveHandlerInterface) {
// register the session handler with ext/session
$this->registerSaveHandler($saveHandler);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/ZendTest/Mvc/Controller/Plugin/FlashMessengerTest.php
Expand Up @@ -27,6 +27,11 @@ public function setUp()
$this->helper->setSessionManager($this->session);
}

public function tearDown()
{
$this->session->getStorage()->clear();
}

public function seedMessages()
{
$helper = new FlashMessenger();
Expand Down
3 changes: 2 additions & 1 deletion tests/ZendTest/Mvc/Controller/Plugin/PostRedirectGetTest.php
Expand Up @@ -65,7 +65,8 @@ public function setUp()
$this->sessionManager->destroy();

$this->controller->setEvent($this->event);
$this->controller->flashMessenger()->setSessionManager($this->sessionManager);
$plugins = $this->controller->getPluginManager();
$plugins->get('flashmessenger')->setSessionManager($this->sessionManager);
}

public function testReturnsFalseOnIntialGet()
Expand Down
12 changes: 0 additions & 12 deletions tests/ZendTest/Session/SessionManagerTest.php
Expand Up @@ -326,18 +326,6 @@ public function testCallingWriteCloseMarksStorageAsImmutable()
$this->assertTrue($storage->isImmutable());
}

/**
* @runInSeparateProcess
*/
public function testCallingDestructorMarksStorageAsImmutable()
{
$this->manager->start();
$storage = $this->manager->getStorage();
$storage['foo'] = 'bar';
$this->manager = null;
$this->assertTrue($storage->isImmutable());
}

/**
* @runInSeparateProcess
*/
Expand Down
Expand Up @@ -15,7 +15,9 @@
class TestSaveHandlerWithValidator implements SaveHandler
{
public function open($save_path, $name)
{return true;}
{
return true;
}

public function close()
{}
Expand Down

0 comments on commit d80d076

Please sign in to comment.