Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Reproduction code for ZF-12494 (http://framework.zend.com/issues/browse/ZF-12494): A class implementing __wakeup() and a controller using it.
<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
switch ($this->_getParam('what', 'test')) {
case 'store': $this->_store(); break;
case 'retrieve': $this->_retrieve(); break;
case 'clear': $this->_clear(); break;
case 'test':
default: $this->_test(); break;
}
echo '<hr />';
echo '<a href="' .$this->_helper->url->url(array('controller' => 'index', 'action' => 'index', 'what' => 'test')) . '">Test object (no session)</a> | ';
echo '<a href="' .$this->_helper->url->url(array('controller' => 'index', 'action' => 'index', 'what' => 'store')) . '">Store (Note: clear before storing again)</a> | ';
echo '<a href="' .$this->_helper->url->url(array('controller' => 'index', 'action' => 'index', 'what' => 'retrieve')) . '">Retrieve</a> | ';
echo '<a href="' .$this->_helper->url->url(array('controller' => 'index', 'action' => 'index', 'what' => 'clear')) . '">Clear</a>';
}
protected function _getSubject()
{
$s = new Application_Model_SleepingModel();
$s->aMember = 'foo';
$s->anotherMember = 'bar';
return $s;
}
protected function _test()
{
$subject = $this->_getSubject();
echo 'My test subject:';
var_dump($subject);
echo 'Serialize:';
$subject_ser = serialize($subject);
var_dump($subject_ser);
echo 'Wake-up :';
$o2 = unserialize($subject_ser);
var_dump($o2);
}
protected function _store()
{
echo '(please clear before storing again)<br />';
$subject = $this->_getSubject();
$subject->anotherMember = 'baz';
echo 'My test subject:';
var_dump($subject);
echo 'Storing in session...';
$session = new Zend_Session_Namespace('testingSleepingModel');
$session->mySleeper = $subject;
echo '... done';
}
protected function _retrieve()
{
echo 'Fetching from session...';
$session = new Zend_Session_Namespace('testingSleepingModel');
var_dump($session->mySleeper);
echo '... done';
}
protected function _clear()
{
@Zend_Session::destroy(true, false);
}
}
<?php
class Application_Model_SleepingModel
{
public $aMember;
public $anotherMember;
public function __wakeup()
{
$arr = array();
$foo = @$arr['bar']; // Try to use some index that doesn't exists (but silence the error with @)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.