[HttpFoundation] removed Serializable from SessionInterface

If you need to serialize the session, you need to get the bags and
serialize them instead.
This commit is contained in:
Fabien Potencier 2012-02-12 14:00:25 +01:00
parent 574f2542df
commit fc7d0110f7
3 changed files with 1 additions and 51 deletions

View File

@ -151,33 +151,6 @@ class Session implements SessionInterface
return $this->storage->getId();
}
/**
* Implements the \Serialize interface.
*
* @return string
*/
public function serialize()
{
return serialize($this->storage);
}
/**
* Implements the \Serialize interface.
*
* @param string $serialized
*
* @throws \InvalidArgumentException If the passed string does not unserialize to an instance of SessionStorageInterface
*/
public function unserialize($serialized)
{
$storage = unserialize($serialized);
if (!$storage instanceof SessionStorageInterface) {
throw new \InvalidArgumentException('Serialized data did not return a valid instance of SessionStorageInterface');
}
$this->storage = $storage;
}
/**
* Registers a SessionBagInterface with the sessio.
*

View File

@ -16,7 +16,7 @@ namespace Symfony\Component\HttpFoundation\Session;
*
* @author Drak <drak@zikula.org>
*/
interface SessionInterface extends \Serializable
interface SessionInterface
{
/**
* Starts the session storage.

View File

@ -139,29 +139,6 @@ class SessionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(333, $this->session->get('migrate'));
}
public function testSerialize()
{
$compare = serialize($this->storage);
$this->assertSame($compare, $this->session->serialize());
$this->session->unserialize($compare);
$_storage = new \ReflectionProperty(get_class($this->session), 'storage');
$_storage->setAccessible(true);
$this->assertEquals($_storage->getValue($this->session), $this->storage, 'storage match');
}
/**
* @expectedException \InvalidArgumentException
*/
public function testUnserializeException()
{
$serialized = serialize(new \ArrayObject());
$this->session->unserialize($serialized);
}
public function testGetId()
{
$this->assertEquals('', $this->session->getId());