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

Background support: Backport fix for undefined array key #54850

Conversation

andrewserong
Copy link
Contributor

What?

Backport WordPress/wordpress-develop#5326

Check that $block['attrs'] is set and is an array before assigning to $block_attributes in the Background image block support.

Why?

As raised in https://core.trac.wordpress.org/ticket/59468 it is possible for this array key not to exist, so this check makes for safe accessing of the block attributes.

How?

Check that the attrs value is set and is an array before using it.

Testing Instructions

Smoke testing:

  1. Add a couple of Group blocks to a post or page
  2. Set one of the Group blocks to have a background image
  3. Ensure the background image is displayed correctly on the site frontend

@andrewserong andrewserong added [Block] Group Affects the Group Block (and row, stack and grid variants) [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core labels Sep 27, 2023
@andrewserong andrewserong self-assigned this Sep 27, 2023
@github-actions
Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/block-supports/background.php

Copy link
Contributor

@tellthemachines tellthemachines left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, LGTM!

@andrewserong andrewserong enabled auto-merge (squash) September 27, 2023 05:43
@andrewserong andrewserong merged commit dfb5420 into trunk Sep 27, 2023
55 checks passed
@andrewserong andrewserong deleted the fix/potentially-undefined-block-attrs-in-background-image-support branch September 27, 2023 06:11
@github-actions github-actions bot added this to the Gutenberg 16.8 milestone Sep 27, 2023
@getdave
Copy link
Contributor

getdave commented Jan 22, 2024

✅ I updated the PHP Sync Tracking Issue for WP 6.5 to note this PR does not require a backport for WP 6.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport from WordPress Core Pull request that needs to be backported to a Gutenberg release from WordPress Core [Block] Group Affects the Group Block (and row, stack and grid variants) [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants