Hi,
I may have stumbled upon this same problem (in a Multi-Site installation, but I think this could be a problem in all installations) and I may have an explanation (given, it’s the same problem, anyway):
If the shortcode widget is first installed without being ever used, the wordpress widget engine will try to access the stored widgets (which would normally be an empty array), but gets a “false” instead, which leads to warnings on the widget page, as well as in the customizer.
To illustrate, in the file wp-includes/widgets.php:1159, the variable $sidebars_widgets will contain the following (note that ‘front-page-widget’ is a theme specific widget area, I added via a register_sidebar in the functions.php):
array (
'wp_inactive_widgets' =>
array (
),
'sidebar-1' =>
array (
),
'sidebar-2' =>
array (
),
'sidebar-3' =>
array (
),
'front-page-widget' =>
array (
),
'widgets_for_shortcodes' => false,
)
Subsequently, I receive the following PHP-Warnings on the widget page:
PHP Warning: array_merge(): Argument #6 is not an array in <path_to_wp>/wp-includes/widgets.php on line 1159
PHP Warning: array_diff(): Argument #2 is not an array in <path_to_wp>/wordpress/wp-includes/widgets.php on line 1160
PHP Warning: Invalid argument supplied for foreach() in <path_to_wp>/wp-includes/widgets.php on line 1162
PHP Warning: array_merge(): Argument #1 is not an array in <path_to_wp>/wp-includes/widgets.php on line 1170
And in the customizer for the file wp-includes/class-wp-customize-widgets.php:
PHP Warning: array_intersect(): Argument #1 is not an array in <path_to_wp>/wp-includes/class-wp-customize-widgets.php on line 1343
PHP Warning: array_values() expects parameter 1 to be array, null given in <path_to_wp>/wp-includes/class-wp-customize-widgets.php on line 1343
After adding a random widget to the Shortcode-Widget-Area and removing it, the corresponding array field is an empty array, as expected, and the warnings all disappear:
array (
'wp_inactive_widgets' =>
array (
),
'sidebar-1' =>
array (
),
'sidebar-2' =>
array (
),
'sidebar-3' =>
array (
),
'front-page-widget' =>
array (
),
'widgets_for_shortcodes' =>
array (
),
)
So, the problem seems to either be, that the new widget area is not properly registered as such, leading to a false (maybe, because it tries to fetch a nonexisting entry in the options-table, which does not neccessarily exist), or because the WP-widget-engine is not sufficiently hardened against unexpected entries (false, instead of array()).
PS: I simply had to add and remove a widget to the shortcode widget area on any sub-blog in my multi-site installation to have it work on all the sub-blogs. Not sure why though…
-
This reply was modified 7 years, 4 months ago by
Fiech.
-
This reply was modified 7 years, 4 months ago by
Fiech.