Every time the Drupal cache is cleared, hook_menu_alter is invoked.

Inside function view_mode_page_menu_alter() on line 149 the code follow code which causes a PHP warning:

// if this view mode is not in use, we shouldn't use it
    if (!in_array($view_mode, $view_modes[$entity_type]) && $view_mode != 'default') {
      $missing_view_modes[] = $page;
      continue;
    }

Presumably, $view_modes[$entity_type] is null at times, which causes the following warning to be displayed:
in_array() expects parameter 2 to be array, null given view_mode_page.module:149

I'm noticing this when clearing cache via Drush, however even without Drush the warning will be written into the watchdog log.

The code still functions as intended, since the resulting expression is still false, but it would be nice to get rid of the warning.

Comments

justindodge’s picture

Issue summary: View changes

  • 8cd402d committed on 7.x-2.x
    #2406805: Fix assumption that an entity type has a view mode.
    
rballou’s picture

Status: Active » Needs review

I've added a potential fix to the dev branch, so check it out and let me know if it fixes it. Thanks!

justindodge’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for your quick response rballou. The fix resolves the issue I reported and the code looks good to me.

rballou’s picture

Status: Reviewed & tested by the community » Fixed

Applied to 7.x-2.4 (just created). Thanks!

Status: Fixed » Closed (fixed)

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