如何解决 Opencart 报错 PHP Notice: unserialize(): Error at offset?

前几日在维护一个客户的opencart商城网站时,遇到一个问题,报错如下

1
2
PHP Notice:  unserialize(): Error at offset 2365 of 2385 bytes
in /public_html/catalog/model/extension/module.php on line 7

查看该文件第7行 有如下操作 使用了 php的反序列函数 unserialize

1
return unserialize($query->row['setting']);

解决办法如下:将这一行替换为如下即可:

1
return unserialize(preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':"$2";'", $query->row['setting']));
avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: