duanjingwei7239 2016-04-30 11:38
浏览 31

Drupal注意:unserialize():_menu_link_translate()中110字节的偏移104错误(mysite \ includes \ menu.inc的第882行)

Hi i am using drupal 7 i get this strange issue

Notice: unserialize(): Error at offset 104 of 110 bytes in _menu_link_translate() (line 882 of path_to_mysite\includes\menu.inc).

Following function shows line number 882

function _menu_link_translate(&$item, $translate = FALSE) {
  if (!is_array($item['options'])) {
    $item['options'] = unserialize($item['options']);//**this is line number 882**
  }
  if ($item['external']) {
    $item['access'] = 1;
    $map = array();
    $item['href'] = $item['link_path'];
    $item['title'] = $item['link_title'];
    $item['localized_options'] = $item['options'];
  }

I have already installed Variable Check Module and it's clear of any error. I also tried following query, but its empty please guide me here.

SELECT name, LENGTH( value ) , value

FROM variable

WHERE LENGTH( value ) = 882
  • 写回答

1条回答 默认 最新

  • dongmeixian9665 2016-05-04 00:44
    关注

    This means that the link in question is corrupted. Some function, process or arbitrary query has altered the link in the database so that the serialized data is not the expected length.

    When you serialize data, you are generally storing an array or object in one single field. This might look something like this:

    a:1:{s:10:"attributes";a:1:{s:5:"title";s:33:"Select and configure your themes.";}}
    

    What this means is:

    - Array with 1 element, which contains:
    -- A string that is 10 characters long (attributes) (this is the element key)
    -- An array with 1 element (this is the first Array's value), which contains:
    --- A string that is 5 characters long (title) (this is the second Array's element key)
    --- A string that is 33 characters long (Select and configure your themes.) (This is the second Array's element value)
    

    In this example, if you went directly into your database and manually changed the word "attributes" to be "llama", but you DIDN'T change the "s:10" just before it to "s:5", you would get an unserialize error similar to the one you are receiving.

    To fix this issue, you need to first track down which link specifically is causing the issue. You can do this with dpm() (as Stanislav mentions above). You can also query your menu_links table directly and scour the options column for any links that have a mismatch between string length and the number that describes the string length. You can also just start deleting suspicious links and re-adding them (though this may not be practical on a production or large site).

    There are more complex methods of sussing out the bad links, but these in my experience are the best methods (in that order).

    Good luck!

    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程