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

Fix PHP notice triggered by 'gutenberg_update_initial_settings' #60862

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

Mamaduka
Copy link
Member

@Mamaduka Mamaduka commented Apr 18, 2024

What?

Fixes #60859.

PR updates logic in the gutenberg_update_initial_settings filter callback to bail out early when the setting isn't exposed via REST API.

Testing Instructions

  1. Register a setting without show_in_rest.
  2. Load the testing site.
  3. Confirm that the following warning isn't displayed or logged - PHP Warning: Undefined array key "show_in_rest"

Example setting

add_action( 'init', function() {
	register_setting(
		'general',
		'foo_my_setting',
		array(
			'type'              => 'string',
			'label'             => 'My Setting',
			'description'       => 'This is a custom setting.',
		)
	);
} );

Testing Instructions for Keyboard

Same.

Screenshots or screencast

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended REST API Interaction Related to REST API labels Apr 18, 2024
@Mamaduka Mamaduka self-assigned this Apr 18, 2024
@Mamaduka Mamaduka requested a review from spacedmonkey as a code owner April 18, 2024 13:02
Copy link

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: leonidasmi <leonidasmilossis@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka requested a review from ntsekouras April 18, 2024 13:03
@Mamaduka Mamaduka added the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label Apr 18, 2024
@Mamaduka Mamaduka merged commit 7db8478 into trunk Apr 18, 2024
67 of 68 checks passed
@Mamaduka Mamaduka deleted the fix/register-settings-php-notice branch April 18, 2024 13:39
@github-actions github-actions bot added this to the Gutenberg 18.2 milestone Apr 18, 2024
@Mamaduka Mamaduka removed the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REST API Interaction Related to REST API [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A PHP warning is thrown whenever a plugin calls register_setting without the show_in_rest argument
1 participant