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

Prevent PHP notice from block-supports elements #35836

Merged
merged 2 commits into from
Oct 22, 2021

Conversation

carolinan
Copy link
Contributor

@carolinan carolinan commented Oct 21, 2021

Description

When using the Post Tags block and setting a link color, the front end gives PHP errors, when a post is untagged:
Notice: Undefined offset: 0 in C:\xampp\apps\wordpress\htdocs\wp-content\plugins\gutenberg\lib\block-supports\elements.php on line 47
This PR adds an early return if there is no block to add the style to.
Closes #35769

How has this been tested?

  1. Add a post tag block to a post without tags, and add a link color.
  2. Add a few other blocks with link color options.
  3. View the front and confirm that there is no PHP notice, and that the link colors display correctly.

Types of changes

Bug fix

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).

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

This looks great! Thanks, @carolinan.

lib/block-supports/elements.php Outdated Show resolved Hide resolved
Co-authored-by: George Mamadashvili <[email protected]>
@carolinan carolinan merged commit a95ac25 into trunk Oct 22, 2021
@carolinan carolinan deleted the update/block-support-elements-notice branch October 22, 2021 10:52
@github-actions github-actions bot added this to the Gutenberg 11.9 milestone Oct 22, 2021
@vcanales vcanales added the [Type] Bug An existing feature does not function as intended label Oct 27, 2021
vcanales pushed a commit that referenced this pull request Oct 27, 2021
* Prevent PHP notice from block-supports elements
Co-authored-by: George Mamadashvili <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Post Tags - link color gives PHP error if post untagged
3 participants