We have Bean entities with no view modes selected in the Custom display settings. When visiting the Panelizer configuration page (/admin/structure/panelizer), it throws the following error messages:

Notice: Undefined index: bean_name in PanelizerEntityDefault->get_available_view_modes() (line 757 of /sites/all/modules/panelizer/plugins/entity/PanelizerEntityDefault.class.php).
Warning: Invalid argument supplied for foreach() in PanelizerEntityDefault->settings_form() (line 2991 of sites/all/modules/panelizer/plugins/entity/PanelizerEntityDefault.class.php).

The problem is the code used to build an array of view modes located in the get_available_view_modes function in PanelizerEntityDefault.class.php. The code should check if the bundle has view modes set, and if there are none, return an empty array instead.

Please review the attached patch. Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ron_s created an issue. See original summary.

DamienMcKenna’s picture

Status: Needs review » Needs work

I think the correct approach would be to make sure the array key is set, so if the function is called more than once it isn't going through the interior loop multiple times.

david.hughes’s picture

Status: Needs work » Needs review
FileSize
755 bytes

I ran into this today on our project. Created a patch as per DamienMcKenna's suggestion, please let me know of any further suggestions.

ron_s’s picture

Status: Needs review » Reviewed & tested by the community

Makes sense to me.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: » #2787147: Plan for Panelizer 7.x-3.5 release

Thank you both!

Status: Fixed » Closed (fixed)

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