-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix unset array key warning in block-bindings.php #66337
Conversation
This has been throwing an error for several weeks on one of my sites Simplest fix is to just bail early if it's unset PHP Warning: Undefined array key "show_in_rest" in /var/www/wp-content/plugins/gutenberg/lib/compat/wordpress-6.7/block-bindings.php on line 70
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @benharri! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't been able to reproduce, even registering a meta field without show_in_rest
, but I agree that an early bailout seems reasonable.
I guess that if we don't include an early bailout it could potentially fail in the next conditionals.
Here's a stack trace from my case. It does seem to be buddypresss. From Query Monitor:
Applying this fixes this warning |
This is an early bailout with |
But it still modifies the I'd personally replicate what was done here. We already have the check for the label, so I'd add the one checking if is set. I haven't tested it, but I assume everything should work as expected. |
|
I wasn't referring to // Don't update schema when a setting isn't exposed via REST API.
if ( ! isset( $args['show_in_rest'] ) ) {
return $args;
} |
all set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @benharri!
* Fix unset array key warning in block-bindings.php This has been throwing an error for several weeks on one of my sites Simplest fix is to just bail early if it's unset PHP Warning: Undefined array key "show_in_rest" in /var/www/wp-content/plugins/gutenberg/lib/compat/wordpress-6.7/block-bindings.php on line 70 * Update block-bindings.php Co-authored-by: benharri <[email protected]> Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: Mamaduka <[email protected]>
This has been throwing an error for several weeks on one of my sites
Simplest fix is to just bail early if it's unset
PHP Warning: Undefined array key "show_in_rest" in /var/www/wp-content/plugins/gutenberg/lib/compat/wordpress-6.7/block-bindings.php on line 70
What?
Fix undefined array key warning
Why?
My error logs have been filling up
How?
Bail early if it's unset.
Testing Instructions
I'm not 100% sure which custom post type this is throwing from, but I'm leaning towards buddypress.
Testing Instructions for Keyboard
No more warning thrown from block-bindings.php
Screenshots or screencast
n/a