Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#3 | undefined_index_in-2776173-3.patch | 755 bytes | david.hughes |
| |||
panelizer-empty_array_no_view_modes-1.patch | 856 bytes | ron_s | |
|
Comments
Comment #2
DamienMcKennaI 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.
Comment #3
david.hughesI ran into this today on our project. Created a patch as per DamienMcKenna's suggestion, please let me know of any further suggestions.
Comment #4
ron_s CreditAttribution: ron_s commentedMakes sense to me.
Comment #6
DamienMcKennaThank you both!