FuelPHP ORM问题 - 即使它们不应该调用魔术方法

时间:2013-07-29 14:31:48

标签: php orm fuelphp

首先,请允许我说下列情况并非一直发生,但可能每天发生一次或两次(有时甚至不是每天一次)。此外,它只发生在生产上。因此,我很难进行适当的调试,而我所能做的就是捕获回溯并将其写入日志中。

我有一个ORM模型,它扩展了\Orm\Model。我正在使用Model_X::find()来获取所需的对象。但是,在该模型的构造函数中,奇怪的事情开始发生:

构造函数的第一行是

if( ! empty($this->_data))

这会触发魔法__isset('_data'),然后从这一行调用魔法__get('_custom_data')

elseif (array_key_exists($property, $this->_custom_data))

接下来,直到最终抛出异常:

Undefined property: Model_X::$_view

从这一行:

elseif ($this->_view and in_array($property, static::$_views_cached[get_class($this)][$this->_view]['columns']))

这里奇怪的是,所有这些属性_data,_view,_custom_data都在\Orm\Model类中定义。我的理解是如果定义了属性,则不需要调用__get,因为“在与尚未声明或在当前范围中不可见的属性或方法交互时调用重载方法”< /强>

我的问题是:为什么空($ this-&gt; _data)调用__isset(并触发所有后续调用),实际上,该属性是为此类定义的?

这是回溯的相关部分:

"file": "/fuel/packages/orm/classes/model.php",
"line": 1028,
"function": "{closure}",
"args": [8, "Undefined property: Model_Supplier::$_view", "/fuel/packages/orm/classes/model.php", 1028, {
    "property": "_view",
    "rel": false,
    "this": {},
    "value": false

"file": "/fuel/packages/orm/classes/model.php",
"line": 865,
"function": "get",
"class": "Orm\\Model",
"object": {},
"type": "->",
"args": ["_view"]

"file": "/fuel/packages/orm/classes/model.php",
"line": 1028,
"function": "__get",
"class": "Orm\\Model",
"object": {},
"type": "->",
"args": ["_view"]

"file": "/fuel/packages/orm/classes/model.php",
"line": 865,
"function": "get",
"class": "Orm\\Model",
"object": {},
"type": "->",
"args": ["_custom_data"]

"file": "/fuel/packages/orm/classes/model.php",
"line": 899,
"function": "__get",
"class": "Orm\\Model",
"object": {},
"type": "->",
"args": ["_custom_data"]

"file": "/fuel/packages/orm/classes/model.php",
"line": 730,
"function": "__isset",
"class": "Orm\\Model",
"object": {},
"type": "->",
"args": ["_data"]

"file": "/fuel/packages/orm/classes/model.php",
"line": 124,
"function": "__construct",
"class": "Orm\\Model",
"object": {},
"type": "->",

编辑:我实际上已经解决了这个问题(我认为)。由于php-fpm重新启动后错误消失了,我的想法是这样 - 缓存被破坏,重启后损坏的缓存被清除。唯一的缓存是APC,所以我去了并禁用它。

0 个答案:

没有答案