追跡できないような奇妙な問題があります。ユーザーを表す Zend_Db_Table_Row_Abstract を拡張するカスタム クラス ("Person") があります。特に、このクラスには、init() メソッドで設定されるカスタム変数があります。たとえば、次のとおりです。
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; // this is saved to $this->_cdata['fullName']
}
ログイン時に、このクラスのオブジェクトを Zend Auth Identity として保存します。
$r = $auth->authenticate($authAdapter);
if($r->isValid())
{
$user = $db->getUserByEmail($email); // Retrieves an object of class "Person"
$auth->getStorage()->write($user);
}
ここで、ログインと同じアクション リクエストで Auth Identity を呼び出すと、問題なく動作します。
echo $user->fullName; // Will print "John Smith" or whatever it is
ただし、別のアクションを呼び出して Auth Identity を呼び出すと、「_cdata」配列に保存したものはすべて失われます。
$auth = Zend_Auth::getInstance();
if($auth->hasIdentity() {
$user = $auth->getIdentity();
echo $user->fullName; // Prints nothing...$_cdata['fullName'] does not exist.
}
何か案は?