【问题标题】:unserialize offset Error反序列化偏移错误
【发布时间】:2011-10-15 16:02:07
【问题描述】:

--

我有一个序列化数组发送到我的应用程序中的另一个函数。 然后我尝试反序列化数据并将其呈现在另一个地方。

反序列化功能适用于较小的数据量,例如数百条记录。当涉及 3000 多条记录时,我收到以下错误消息:

Notice (8): unserialize() [function.unserialize]: Error at offset 23048 of 3499833 bytes [APP/controllers/jobs_controller.php, line 475]

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 19]

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 20]

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 21]

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 22]

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 23]

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 24]

Warning (2): Cannot modify header information - headers already sent by (output started at /home/v/s/vsdev/web/public_html/cake/libs/debugger.php:683) [APP/views/helpers/xls.php, line 25]

Link Job Job Ref Company Link Profession Specialism Sub Specialism Zone Country Region City Seniority Date Published Date Archived Days Active Email Enabled Created Modified

Warning (2): Invalid argument supplied for foreach() [APP/views/jobs/search_export.ctp, line 37]

怎么了?

【问题讨论】:

  • 您需要检查偏移量 23048(1 个偏移量 = 1 个字符)处的未序列化/原始字符串并从那里开始。 serialize() 不是unserialize()(或之前)可能存在问题

标签: php cakephp serialization


【解决方案1】:

几乎可以肯定,引发错误的记录中的数据已损坏。这应该与您请求的记录数量无关,只是一个或多个具有无效序列化数据的特定记录。尝试找出导致错误的记录,并检查其数据。

附带说明:您使用什么列类型来存储序列化数据?我发现在 MySQL 中使用 TEXT 时,MySQL 对文本执行的操作可能会不可逆地损坏序列化数据,从而导致 unserialize() 错误。对序列化的数据列使用 BLOB,这样数据保持不变。

【讨论】:

  • 我不存储序列化数据。我只是序列化它,以便我可以发送它并在另一个函数中重新打开它。
  • 不存储数据为什么还要序列化?
  • 我有一个搜索。它是一个查询,这个查询的结果是一个数组。为了显示结果,我有一个循环遍历数组。在底部有一个按钮“导出结果”。此功能使我可以导出结果。为此,我需要对结果进行序列化,以便将其作为隐藏值发送,然后在 .xls 视图中对其进行反序列化。
  • 啊,这就解释了。但是,发送这样的数据几乎不是一个好主意..看起来数据量可能有点太多而无法序列化,或者由于其大小而以某种方式损坏(在您的示例中,它超过 3mb) .您不能将搜索条件传递给导出器脚本,然后重做查询吗?
猜你喜欢
  • 1970-01-01
  • 2011-08-03
  • 2016-04-11
  • 1970-01-01
  • 2013-04-20
  • 2018-09-24
  • 1970-01-01
  • 1970-01-01
  • 2014-02-19
相关资源
最近更新 更多