2

I'm trying to add a product to my commerce store, and anytime I navigate to the add a product page I get hit with the following error:

Fatal error: Unsupported operand types in C:\Users\Nick\Sites\devdesktop\psr3\modules\system\system.module on line 2134

I have googles around, and this looks like a common error with contrib or custom modules.

The error happens in this if statement:

  if (!isset($item['mlid'])) {
    $item += db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = :path AND module = 'system'", array(':path' => $item['path']))->fetchAssoc();
  }

My php isn't good enough to know what might be causing the error. How can I solve this?

1

Either $item, or the return value from the db_query() statement, are resolving as something other than an array. Drupal is expecting them both to be arrays, so you get an error when it unconditionally tries to combine them.

It's not possible to debug something like this without access to the site; I'd recommend stepping through the code with a proper debugging tool to see exactly which side of the equation is failing.

At a guess, I'd say $item is the problem. You'd expect to see more notices about undefined array indexes if it was simply that $item['path'] was missing or something like that.

One low-tech debugging approach is to temporarily disable custom/contrib modules one by one and see if you can find something responsible.

  • what's a "proper debugging tool" and where can I read up on how to use one? – nizz0k Feb 2 '16 at 15:15
  • XDebug is the usual go-to @nizz0k, I think this is the Drupal-specific documentation for it, but a google search for "drupal xdebug" brings up loads of tutorials – Clive Feb 2 '16 at 15:29
  • I'm accepting your answer because that would be the right way to do it, I posted the solution that worked for me below. – nizz0k Feb 2 '16 at 15:51
  • So, now that I ran that code, I'm finally getting this notice MESSAGENotice: Undefined index: menu-store-products in menu_tree_build() (line 524 of C:\Users\Nick\Sites\devdesktop\psr3\sites\all\modules\menu_block\menu_block.module). Which I think means that something else was failing silently before. – nizz0k Feb 6 '16 at 19:05
0

So, googling around further I saw that several people hit up against this pretty recently, and that there was some issue with the menus. The last comment on this thread Unsupported operand types system module gave me what I needed. I ran the following code

db_update('menu_links')
    ->expression('router_path', 'link_path')
    ->condition('menu_name', 'management')
    ->condition('link_path', db_like('admin/commerce') . '%', 'LIKE')
    ->where('link_path <> router_path')
    ->execute();

In the devel execute php window and it solved my problem.

  • Just as an FYI, this bug is still in core with 7.43 – nizz0k Feb 26 '16 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.