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

Widget Block: widget_id is undefined when a widget is placed #33152

Merged
merged 2 commits into from
Jul 4, 2021

Conversation

spacedmonkey
Copy link
Member

@spacedmonkey spacedmonkey commented Jul 1, 2021

Some widgets expect for the widget_id $args to be set to render the widget without a PHP notice error. Add back the widget_id and widget_name params to call to the_widget.

See original core code when widget_id and widget_name are populated.

https://github.com/WordPress/wordpress-develop/blob/bdf7dd6299e4453f9d7438de0a0e138d950ec0bf/src/wp-includes/widgets.php#L737-L748

Trac ticket: https://core.trac.wordpress.org/ticket/53548

How has this been tested?

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

Fixes #33056

@spacedmonkey spacedmonkey added the [Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets label Jul 1, 2021
@spacedmonkey spacedmonkey self-assigned this Jul 1, 2021
@talldan talldan requested a review from kevin940726 July 2, 2021 02:26
Copy link
Member

@kevin940726 kevin940726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and it fixes the issue. Not sure about the code though since i'm not familiar with PHP but it looks good to me.

@Mamaduka Mamaduka added the [Type] Bug An existing feature does not function as intended label Jul 2, 2021
@adamziel
Copy link
Contributor

adamziel commented Jul 2, 2021

@spacedmonkey PHP linter has some complaints, would you address those please?

@spacedmonkey
Copy link
Member Author

@adamziel Done

@spacedmonkey spacedmonkey requested a review from adamziel July 2, 2021 14:02
Copy link
Contributor

@desrosj desrosj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a reasonable backwards compatibility change.

If we want to steer developers away from using these, we should add some _doing_it_wrong() notices in core instead of triggering PHP notices.

@spacedmonkey spacedmonkey added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 4, 2021
@spacedmonkey spacedmonkey merged commit cc70361 into WordPress:trunk Jul 4, 2021
@github-actions github-actions bot added this to the Gutenberg 11.1 milestone Jul 4, 2021
youknowriad pushed a commit that referenced this pull request Jul 5, 2021
@youknowriad youknowriad removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jul 5, 2021
youknowriad pushed a commit that referenced this pull request Jul 6, 2021
youknowriad pushed a commit that referenced this pull request Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Legacy Widget Affects the Legacy Widget Block - used for displaying Classic Widgets [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP Notice error in milestone widget
6 participants