duanfei7508 2013-10-22 07:12
浏览 120

unserialize()...函数spl_autoload_call()尚未定义它所调用的类

I'm using factory to create an object and the static method to unserialize this object:

public static function factory($idText) {
    $fetchedObject = self::fetchStoredObject($idText);
    return $fetchedObject;
}

private static function fetchStoredObject($idText) {
    $fetchedText = DB::select()
                    ->from(table)
                    ->where('idText', '=', $idText)
                    ->execute()->as_array();
    if (!empty($fetchedText)) {
        return unserialize(base64_decode($fetchedText[0]['txtContent']));
    } else {
        return NULL;
    }
}

The object is created in this way:

$text = Article::factory($idText);

But I get the following error:

unserialize() [<a href='function.unserialize'>function.unserialize</a>]: 
Function spl_autoload_call() hasn't defined the class it was called for

On this line of fetchStoredObject method:

return unserialize(base64_decode($fetchedText[0]['txtContent']));

Why does this error occur?

EDIT

My class has the following structure:

class Article {
    private $phpMorphy;
    private $words; //contains instances of class Word
    ...
    private function __construct($idText) {
        $this->initPhpMorphy(); // $this->phpMorphy gets reference to the object here
    }

    public function __sleep() {
        return Array(
            'rawText',
            'idText',
            'properties',
            'words',
            'links'
        );
    }

public function __wakeup() {
    $this->initPhpMorphy();
}

}

The Word class doesn't contain the reference to phpMorphy as own property, but uses it in its methods as function parameter. Here is the part of the serialized string:

" Article words";a:107:{i:0;O:4:"Word":10:{s:5:" * id";O:9:"phpMorphy":7:{s:18:" * storage_factory";O:25:

It appears the phpMorphy is serialized with connectrion to the Word class. Am I right?

  • 写回答

3条回答 默认 最新

  • dso15221 2013-10-22 07:36
    关注

    What version of PHP did you use? Where did you store your Article class? Try to require() it manually.

    评论

报告相同问题?

悬赏问题

  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计