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 array key warning in block supports layout #37101

Merged
merged 1 commit into from
Dec 6, 2021

Conversation

mkaz
Copy link
Member

@mkaz mkaz commented Dec 3, 2021

Description

During testing I noticed the following warning in PHP logs:

PHP Warning:  Undefined array key "justifyContent" in /home/mkaz/src/wp/gutenberg/lib/block-supports/layout.php on line 170, referer: http://localhost:8003/wp-admin/themes.php?page=gutenberg-edit-site&postId=twentytwentytwo%2F%2Fhome&postType=wp_template

This PR adds an isset() check for the justifyContent value to suppress the warning.

How has this been tested?

  1. Using twentytwentytwo with no changes
  2. Enable debug logging / at least warning level
  3. Open site in site editor and confirm warning
  4. Apply patch, confirm warning goes away
  5. Modfiy a block using justifyContent confirm works

Types of changes

Switches a array check to isset()

@mkaz
Copy link
Member Author

mkaz commented Dec 3, 2021

FYI - Looking at WP 5.9 and it looks like this was already addressed when moved to core. So no backport necessary.

https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/block-supports/layout.php#L166

Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Thanks @mkaz !

@mkaz mkaz force-pushed the fix/justifyContent-array-key branch from 79b3e98 to 2a9d8e9 Compare December 3, 2021 21:45
@mkaz mkaz force-pushed the fix/justifyContent-array-key branch from 2a9d8e9 to 5392cb0 Compare December 6, 2021 13:48
@mkaz mkaz merged commit 1404987 into trunk Dec 6, 2021
@mkaz mkaz deleted the fix/justifyContent-array-key branch December 6, 2021 15:15
@github-actions github-actions bot added this to the Gutenberg 12.2 milestone Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants