digitoimistodude / air-light

💨 WordPress starter theme - designed to be minimal, ultra-lightweight (< 20 kB) and easy for all kinds of WordPress projects. 7+years/1000+hours of development and still updating daily! We prefer the original WordPress way of doing things so no strange templating languages or frameworks here.
https://airwptheme.com
MIT License
929 stars 139 forks source link

Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, string given #176

Closed grandeljay closed 7 months ago

grandeljay commented 1 year ago

Despite your advice not to use air-light as a parent theme I have, which has worked great for me until now. I am using PHP 8.0 and have WPML installed.

When I attempt to edit a post/page I get the following error:

PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #2 must be of type array, string given in /path/to/wordpress/wp-content/themes/air-light/inc/hooks/gutenberg.php:28
Stack trace:
#0 /path/to/wordpress/wp-content/themes/air-light/inc/hooks/gutenberg.php(28): array_merge()
#1 /path/to/wordpress/wp-includes/class-wp-hook.php(308): Air_Light\allowed_block_types()
#2 /path/to/wordpress/wp-includes/plugin.php(205): WP_Hook->apply_filters()
#3 /path/to/wordpress/wp-includes/block-editor.php(126): apply_filters()
#4 /path/to/wordpress/wp-includes/block-editor.php(393): get_allowed_block_types()
#5 /path/to/wordpress/wp-admin/edit-form-blocks.php(284): get_block_editor_settings()
#6 /path/to/wordpress/wp-admin/post.php(187): require('...')
#7 {main}
  thrown in /path/to/wordpress/wp-content/themes/air-light/inc/hooks/gutenberg.php on line 28

In case you can't reproduce this, any ideas?

michaelbourne commented 1 year ago

Currently the theme fails to check if THEME_SETTINGS['allowed_blocks'][ $editor_context->post->post_type ] is an array. I'm guessing you don't have an array set for the post type you're trying to edit, but a string (like 'all', which shouldnt be set on a post type level)

grandeljay commented 1 year ago

Does this mean its a user error or a theme error? Should I not set all within the theme settings for allowed blocks? Or would it make more sense for the theme to check if allowed_blocks is a string (all) or array?