i have strange problem can't seem track down. have custom class ("person") extending zend_db_table_row_abstract represents user. among other things, class has custom variables set in init() method, instance:
class person extends zend_db_table_row_abstract { protected $_cdata = array(); // non-db-table data gets put here through __set() public function init() { $this->fullname = $this->firstname." ".$this->lastname; // saved $this->_cdata['fullname'] } upon login, store object of class zend auth identity:
$r = $auth->authenticate($authadapter); if($r->isvalid()) { $user = $db->getuserbyemail($email); // retrieves object of class "person" $auth->getstorage()->write($user); } now, if call auth identity in same action request login, work alright:
echo $user->fullname; // print "john smith" or whatever however, when call action, , call auth identity, lose whatever have stored in "_cdata" array:
$auth = zend_auth::getinstance(); if($auth->hasidentity() { $user = $auth->getidentity(); echo $user->fullname; // prints nothing...$_cdata['fullname'] not exist. } any ideas?
the reason why that's happening because zend_auth identity data gets serialized (and deserialized) between requests.
which leads closer onto __sleep method of zend_db_table_row_abstract class, 1 gets called once $user object serialized.
public function __sleep() { return array('_tableclass', '_primary', '_data', '_cleandata', '_readonly' ,'_modifiedfields'); } what need override method in person class, includes $_cdata array well. property serialized , available in next http request.
Comments
Post a Comment