Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opting out of the widgets-block-editor theme support crashes the editor serverside #30305

Closed
draganescu opened this issue Mar 26, 2021 · 0 comments · Fixed by #30318
Closed
Assignees
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Package] Edit Widgets /packages/edit-widgets [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@draganescu
Copy link
Contributor

Since merging #29649 we introduced a show_instance_in_rest property to widgets to determine their visibility for the Legacy Widget Block and other consumers.

Because core widgets don't yet have this property we have a function gutenberg_set_show_instance_in_rest_on_core_widgets which as the name says adds this property and sets it to true.

However part of the core widgets we also consider WP_Widget_Block which does not get registered if widgets-block-editor theme support is removed. This results in a fatal error:

Warning: Creating default object from empty value in /lib/widgets.php on line 317
wp-includes/class-wp-hook.php:292 gutenberg_set_show_instance_in_rest_on_core_widgets(), wp-includes/class-wp-hook.php:316 apply_filters(''), wp-includes/plugin.php:484 do_action(Array), wp-includes/widgets.php:1801 do_action('widgets_init'), wp-includes/class-wp-hook.php:292 wp_widgets_init(), wp-includes/class-wp-hook.php:316 apply_filters(''), wp-includes/plugin.php:484 do_action(Array), wp-settings.php:553 do_action('init'), wp-config.php:7 require('wp-settings.php'), wp-load.php:37 require_once('wp-config.php'), wp-admin/admin.php:34 require_once('wp-load.php'), wp-admin/post-new.php:10 require_once('wp-admin/admin.php')]

A solution (via @fullofcaffeine) is to check if the widget is registered before we try to set its properties. Since unregister_widget exists we should check this anyway until that function is merged and we don't need to loop through all core widgets anymore.

@draganescu draganescu added [Type] Bug An existing feature does not function as intended [Feature] Widgets Screen The block-based screen that replaced widgets.php. [Package] Edit Widgets /packages/edit-widgets labels Mar 26, 2021
@draganescu draganescu changed the title Opting out of the widgets-block-editor theme support Opting out of the widgets-block-editor theme support crashes the editor serverside Mar 26, 2021
@ockham ockham added this to the Gutenberg 10.3 milestone Mar 26, 2021
@noisysocks noisysocks self-assigned this Mar 28, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Mar 28, 2021
@gziolo gziolo removed this from the Gutenberg 10.3 milestone Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Widgets Screen The block-based screen that replaced widgets.php. [Package] Edit Widgets /packages/edit-widgets [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants