While editing a node I get this error:
Notice : Undefined property: stdClass::$menu in menu_views_node_prepare() (line 396 in ...sites/all/modules/menu_views/menu_views.module)

I looked into the code and I think that the test on that line is not good :

  if (isset($node->nid) && !$node->menu['mlid']) {

should be replaced by :

  if (isset($node->nid) && !isset($node->menu['mlid'])) {

Am I right ?

Comments

markhalliwell’s picture

Not entirely, no. This is somewhat of a complex area to begin with. The menu module should construct the default menu options in menu_node_prepare(). This hook should be called before Menu Views gets a chance to implement it's own hook_node_prepare(). So I don't see how this is really possible, at all. It just doesn't make sense as Menu Views is dependent on the menu module and it should load and get called before Menu Views. So the $node->menu['mlid'] should exist and at least have a value of at least the default 0 (which means no menu item exists).

If anything, I guess a short term solution (if it's really bothering you and before I can take some real time to look at why this might be happening), would be to implement something like the following above that if statement:

  // Manually call menu's hook_node_prepare() if it doesn't exist.
  // @see: drupal.org/node/1878968
  if (empty($node->menu) {
    menu_node_prepare($node);
  }
  if (isset($node->nid) && !$node->menu['mlid']) {
  // ... code ...
markhalliwell’s picture

Status: Active » Postponed (maintainer needs more info)

Did this fix your problem or was it some configuration on your site?

markhalliwell’s picture

Title: Undefined property: stdClass::$menu in menu_views_node_prepare() (line 396 in ...sites/all/modules/menu_views/menu_views.module) » Undefined property: stdClass::$menu in menu_views_node_prepare()
Status: Postponed (maintainer needs more info) » Fixed

Fixed with release of 7.x-2.1 (http://drupal.org/node/1909888)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.