PHPCMS 错误日志 Only variables should be passed by ...

有几个网站是PHPCMS V9做的,但这两天发现一个问题,PHPCMS 的错误日志超过了20M ,后台报警,然后我看了下错误日志,其中两万多行都是一个错误,错误信息如下:


1 <?php exit;?>11-03 10:24:46 | 2048 | Only variables should be passed by reference | caches/caches_model/caches_data/content_output.class.php | 79

然后查找 根源 caches/caches_model/caches_data/content_output.class.php 的第79行

1 extract(string2array($this->fields[$field]['setting']));

PHP extract() 函数从数组中把变量导入到当前的符号表中。
对于数组中的每个元素,键名用于变量名,键值用于变量值。


于是我怀疑extract()的参数不是数组 造成的。

由于报错的这个位置试过缓存文件,找到源文件的位置为

网站根目录/phpcms/modules/content/fields/box/output.inc.php

修改文件里面的


1 extract(string2array($this->fields[$field]['setting']));
为:
1 $setting = string2array($this->fields[$field]['setting']); is_array($setting) && extract($setting);


这样,先判断下extract()的参数是不是一个数组,如果是数组的话,才执行extract(),这样就避免错误,

然后在PHPCMS 更新缓存,这样后面就不会报错了

原文地址:https://www.cnblogs.com/wawahaha/p/3547415.html