Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
16 changes: 9 additions & 7 deletions src/SessionManager.php
Original file line number Diff line number Diff line change
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
12 changes: 0 additions & 12 deletions test/SessionManagerTest.php
Original file line number Diff line number Diff line change
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
4 changes: 3 additions & 1 deletion test/TestAsset/TestSaveHandlerWithValidator.php
Original file line number Diff line number Diff line change
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 6a22f1e

Please sign in to comment.