Updated: Comment #23

Problem/Motivation:-
After upgrading drupal 6 , clicking on edit primary or secondary links leads to Fatal error Unsupported operand types in includes/common.inc on line 1551 (caused by menu.admin.inc)

Steps to reproduce the problem:-
To reproduce the problem refer to #11 and #16
#19

Proposed resolution
http://justinhileman.info/article/unsupported-operand-types-in-drupal-6x/
https://drupal.org/node/228435#comment-782632
#7
#17

Remaining tasks

Patch needs to be reviewed#21

Related Issues
http://drupal.org/node/739158#comment-2768442

Original report by @Lenn-art

After upgrading, i get this error:

Fatal error: Unsupported operand types in /home/xxx/public_html/drupal6/includes/common.inc on line 1551

This is the code around 1551 (last line is 1551)

  // Merge in defaults.
  $options += array(
      'attributes' => array(),
      'html' => FALSE,
    );

Any help would be appreciated!

Comments

MatthijsG’s picture

Oh, and the error is only showing up when i want to edit the primary links.

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

You might want to try adding this little bit of debugging code I wrote in http://drupal.org/node/362799. It sounds most likely that some kind of contrib module is messing this code up (since no one else has reported the problem with Drupal core).

darkdim’s picture

Issue tags: +common.inc

Sorry, I have the same problem with primary links, as Lenn-art. In section http://drupal.org/node/362799 I have written "little bit of debugging code" but the error all the same appears. What it is possible to undertake for debugging?

PS Read this http://justinhileman.info/articles/unsupported-operand-types-in-drupal-6x and add conversion code in common.inc stroke 1378
// Die.
if (!is_array($options)) {
$args = func_get_args();
echo "

";
    print_r($args);
    echo "

";
echo "


";
echo "
";
    debug_print_backtrace();
    die();
  }

The debugging code has specified for the line 71 modules menu.admin.inc where a code 
    // Don't show callbacks; these have $item['hidden'] < 0.
    if ($item && $item['hidden'] >= 0) {
      ........
      $form[$mlid]['title']['#value'] = l($item['title'], $item['href'], $item['localized_options']) . ($item['hidden'] ? ' ('. t('disabled') .')' : '');
      
In mysql base i'm find this $item in table {menu_links} and change hidden to -1. Site works! 
But from what there is this error?
MatthijsG’s picture

I added the code and nothing happenend ... i mean, the error is stil there.

darkdim’s picture

see http://justinhileman.info/articles/unsupported-operand-types-in-drupal-6x There it is described why there is this error and a method of its elimination

agarwal.sudhanshu’s picture

Same issue at /admin/build/menu-customize/secondary-links

I have tried the code
if (!is_array($options)) {
echo "

";
    $backtrace = debug_backtrace();
    var_export($backtrace[0]);
    die();
  }
It showed me the following result
array (
  'file' => '/home/xxx/public_html/mysite/modules/menu/menu.admin.inc',
  'line' => 72,
  'function' => 'l',
  'args' => 
  array (
    0 => 'Submit Content',
    1 => 'node/19',
    2 => false,
  ),
)
Is there any problem in menu.admin.inc on line 72 ?

I have uninstalled all contributed and core-optional modules except menu module.
Switched the current theme to default garlend.
removed the contributed themes and modules and then again run update.php
So now I have code of drupal 6.11 core only. but error still comming

I think there is any problem in update script for upgrading drupal 6.10 to 6.11 
this problem is coming only after upgrading existing site. new installation is working file.


agarwal.sudhanshu’s picture

I searched it little bit and found that
In menu.inc line no 636
function _menu_link_translate(&$item) {
$item['options'] = unserialize($item['options']);

In above code unserialize function was returning FALSE value and this is the reason for error.

From menu_links table I searched the value of field 'option' for 'node/19' in my case.
it was
a:1:{s:10:"attributes";a:1:{s:5:"title";s:15:"Submit content";}}
I have changed it to
a:1:{s:10:"attributes";a:1:{s:5:"title";s:14:"Submit content";}}

as "Submit content" have 14 characters not 15 .

after updating this, my Issue resolved and site start working properly.
I am still not sure why it stored wrong serialized data.

agarwal.sudhanshu’s picture

Status: Postponed (maintainer needs more info) » Needs review
dave reid’s picture

Status: Needs review » Active

There is no code for review or an idea how this problem was caused in the db.

usa2k’s picture

#5 fixed my issue on Drupal 6.11 for comments added to the forum module.

I hope this is useful to others?

anthonybruno’s picture

Im currently having the same issue as well. After editing a page that is a primary link, the node becomes unpublished. After publishing, I get the common.inc error.

MatthijsG’s picture

reply on #7
How did you get the FALSE? I mean, how to execute this lines & where did you see that these lines gives an error?

And how did you discover that (in your case) node/19 was the 'bug'?

MatthijsG’s picture

At least, at least, at least ... pffff

I followed exactly http://justinhileman.info/articles/unsupported-operand-types-in-drupal-6x but step 3 (Find and fix the source) did i a little different: "Add this (instead of the argument conversion code)" > i added the code. Not instead, but with the code mentioned above. The result was a nice error, which lead to the error.

The error was a node with some strange characters in the title (dutch):

‘HOOP-vol-afscheid’

I think, these where "...". The input was done with FCKeditor. Is there somewhere a filter added who can prevent this problem?

agarwal.sudhanshu’s picture

reply on #7
Hello Lenn-art
Your questions are
1. How did you get the FALSE -

$item['options'] = unserialize($item['options']); //line 637 in menu.inc
here value of $item['options'] should an array.
I used print_r( $item['options']);die; code and it displayed FALSE .

2. how did you discover that (in your case) node/19 was the 'bug'?
Please check comment #6 it

array (
'file' => '/home/xxx/public_html/mysite/modules/menu/menu.admin.inc',
'line' => 72,
'function' => 'l',
'args' =>
array (
0 => 'Submit Content',
1 => 'node/19',
2 => false,
),
it returns node/19
means there is bug in node/19

MatthijsG’s picture

Tnx for the reply. I already solved it (see #13). There where some strange characters in the node-title.

kristen pol’s picture

StatusFileSize
new535 bytes

I have seen this error when using a theme with a breadcrumb and a user that does not have access to the page in question. To reproduce:

1) use bluemarine (or other theme with breadcrumb showing)

2) create a user that does not have access to administer blocks (e.g. cannot view /admin/build/block page)

3) login as that user and go directly to /admin/build/block page (type in url)... you should see error:

Fatal error: Unsupported operand types in
C:\apache-htdocs\htdocs_vhost-classic\includes\common.inc on line 1542

Note that if you click around for awhile and go back to that page, you won't see the error anymore.

I have been able to fix this problem with a patch to _menu_translate function in the menu.inc file. For performance reasons, they do not call the _menu_item_localize function if the user doesn't have access to the page. But, in that case, the menu item does not get the 'localized_options' array initialized and then it breaks the url() function. This patch fills in an empty array if the _menu_item_localize function is not called.

I have only used this patch for 6.10 but if menu.inc did not change in 6.11 and 6.12 then the patch will work for those versions as well.

JerryH’s picture

For me it was node-comment.tpl.php line 14 ish.

The l() call was :

print l($node->title, $_GET['q'], NULL, NULL, "comment-$node->nid") . ' ' . theme('mark', $node->new);

Which is invalid for D6 : http://api.drupal.org/api/function/l/6

So I updated it to :

print l($node->title, $_GET['q'], array( NULL, NULL, "comment-$node->nid")) . ' ' . theme('mark', $node->new);

debug_print_backtrace() is your friend ;)

RedTop’s picture

I have the same problem:
http://drupal.org/node/739158#comment-2768442


I did the backtrace but unfortunately my PHP-skills aren't ... well, are non-existent. :P


Pointers towards a solution are most welcome. :(

[edit]
This fix did the trick for me:
http://drupal.org/node/228435#comment-782632

sun’s picture

Title: Fatal error: Unsupported operand types in /home/xxx/public_html/drupal6/includes/common.inc on line 1551 » Fatal error: Unsupported operand types in includes/common.inc on line 1551 (caused by menu.admin.inc)
Version: 6.11 » 6.x-dev
Priority: Normal » Critical
Status: Active » Needs review
Issue tags: -common.inc
StatusFileSize
new917 bytes

Steps to reproduce:

1) Enable Contact module.
2) Enable its default "Contact" menu link and move it into Primary links.
3) Visit admin/build/menu-customize/primary-links
4) Fatal error.

Attached patch fixes the bug.

Fatal errors are critical.

I'm not able to reproduce this issue in D7/D8, so leaving at 6.x-dev.

Marked #1358422: Empty localized_options array item causes "Unsupported operand types" problem in includes/common.inc as duplicate of this issue.

cspiker’s picture

The source of the problem for me was similar to #7 above. I had three entries in the menu_links table where the serialized string length was one too many.

I made the fix directly to the serialized data before seeing the patch in #19 so, unfortunately, I wasn't able to test it.

sun’s picture

Version: 6.x-dev » 7.x-dev
Issue tags: +Needs backport to D6
StatusFileSize
new384 bytes

Attached patch contains the actually required fix.

drupal.org and the rest of the net is apparently littered with bug reports and support requests about this WSOD.

tedbow’s picture

chanderbhushan’s picture

Issue summary: View changes

Updated issue summary.

chanderbhushan’s picture

Problem/Motivation:-
After upgrading drupal 6 , clicking on edit primary or secondary links leads to Fatal error Unsupported operand types in includes/common.inc on line 1551 (caused by menu.admin.inc)

Steps to reproduce the problem:-
To reproduce the problem refer to #11 and #16
#19

Proposed resolution
http://justinhileman.info/article/unsupported-operand-types-in-drupal-6x/
https://drupal.org/node/228435#comment-782632
#7
#17

Remaining tasks

Patch needs to be reviewed#21

Related Issues
http://drupal.org/node/739158#comment-2768442

chanderbhushan’s picture

Issue summary: View changes

Updated issue summary.

chanderbhushan’s picture

Issue summary: View changes

Updated issue summary.

rivimey’s picture

Code very similar to that fixed in Sun's changes above (#21) is present unaltered in D8.HEAD at the moment. I will therefore try to demonstrate whether that also means the bug is present in D8:

    // For performance, don't localize a link the user can't access.
    if ($item['access']) {
      _menu_item_localize($item, $map, TRUE);
    }
rivimey’s picture

Re #21 : Have you been able to reproduce the fatal error when editing primary link issue on D7?

I have spun up a D7.Head site and enabled Contact module and its menu and can edit the menu's position using the table at admin/structure/menu/manage/navigation without any issues I can see.

In D8.Head the Contact module is enabled by default, as is the Contact menu item, but it's in a menu (Footer) on it's own. I added a new menu item using the GUI to Footer and then moved contact around using the table at admin/structure/menu/manage/footer, making it a child of the new item, then back again to 1st level, up and down the list. It appears to be ok and no adverse affects were noted.

It would appear this issue (connected to menu primary links) is D6 only from these tests.

Just in case it matters (as localisation was mentioned) this was on a default English setup.

rivimey’s picture

Version: 7.x-dev » 6.x-dev
Issue summary: View changes
Issue tags: -Needs backport to D6 +LONDON_2013_DECEMBER

Moved back to release 6.x-dev and removed D6 backport tag as cannot repro on D7 (or D8). If repro possible on D7 or 8 please provide method.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.

Paul B’s picture

Version: 6.x-dev » 7.56
Status: Closed (outdated) » Active
Issue tags: -Needs issue summary update, -LONDON_2013_DECEMBER

I just ran into this in 7.56. The options column of a menu_links item had become empty for some reason.

Since unserialize("") returns FALSE, this will cause the error.

Version: 7.56 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

stephencamilo’s picture

Status: Active » Closed (won't fix)
hestenet’s picture

Status: Closed (won't fix) » Active

Reset issue status.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.