PHP反序列化不断抛出相同的错误超过100次 [英] PHP unserialize keeps throwing same error over 100 times

查看:61
本文介绍了PHP反序列化不断抛出相同的错误超过100次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大型二维数组,我将它序列化和 base64_encode 并放入数据库中.在另一个页面上,我将数组拉出,当我 base64_decode 序列化数组时,我可以将其回显出来,它看起来确实有效.

I have a large 2d array that I serialize and base64_encode and throw into a database. On a different page I pull the array out and when I base64_decode the serialized array I can echo it out and it definitely looks valid.

但是,如果我尝试 unserialize(base64_decode($serializedArray)) 它只会抛出相同的错误,以至于 Firefox 几乎崩溃.

However, if I try to unserialize(base64_decode($serializedArray)) it just throws the same error to the point of nearly crashing Firefox.

错误是:

警告:unserialize() [function.unserialize]:第 24 行的/var/www/dev/wc_paul/inc/analyzerTester.php 中不再存在节点

Warning: unserialize() [function.unserialize]: Node no longer exists in /var/www/dev/wc_paul/inc/analyzerTester.php on line 24

我会包含我回显的整个序列化数组,但上次我在这个表单上尝试它时它使我的 Firefox 崩溃了.

I would include the entire serialized array that I echo out but last time I tried that on this form it crashed my Firefox.

有人知道为什么会发生这种情况吗?

Does anyone have any idea why this might be happening?

推荐答案

你确定你只是序列化一个数组,而不是一个对象(例如 DOMNode?) 像资源一样,并不是所有的类都会乐于反序列化.作为 DOM 的示例(您的错误向我表明您正在使用),每个节点都有对 parentNode 的引用,如果在节点被反序列化时 parentNode 不存在,则无法重新创建该参考,问题随之而来.

Are you sure you're just serializing an array, and not an object (e.g. DOMNode?) Like resources, not all classes are going to be happy with being unserialized. As an example with the DOM (which your error suggests to me you're working with), every node has a reference to the parentNode, and if the parentNode doesn't exist at the moment a node is being unserialized, it's not able to recreate that reference and problems ensue.

我建议将 dom 树以 XML 格式保存到数据库中,然后再加载回来.

I would suggest saving the dom tree as XML to the database and loading it back later.

这篇关于PHP反序列化不断抛出相同的错误超过100次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆