gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Post Tags - link color gives PHP error if post untagged

Open Sandstromer opened this issue 5 years ago • 0 comments

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

Notice: Trying to access array offset on value of type null in C:\xampp\apps\wordpress\htdocs\wp-content\plugins\gutenberg\lib\block-supports\elements.php on line 47

Notice: Undefined offset: 0 in C:\xampp\apps\wordpress\htdocs\wp-content\plugins\gutenberg\lib\block-supports\elements.php on line 59

Notice: Trying to access array offset on value of type null in C:\xampp\apps\wordpress\htdocs\wp-content\plugins\gutenberg\lib\block-supports\elements.php on line 59

Looks like trying to add the wp-elements-xxxxx class to a non-existant Post Tag block.

I think the error would also surface for the Post Categories block, if it wasn't for the fact that when a post is uncategorized, the Post Categories block is rendered as 'Uncategorized'.

Step-by-step reproduction instructions

  1. In Site Editor add the Post Tags block to a template such as index.html
  2. Select a link color for the Post Tags block
  3. View front end and notice the error when any of the posts are untagged.

Screenshots, screen recording, code snippet

post-tags-link-color-editor

post-tags-link-color-front-php-error

post-tags-link-color-front-class-output

Environment info

WP 5.8.1 Gutenberg 11.7 Theme TT1-Blocks

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Sandstromer avatar Oct 19 '21 15:10 Sandstromer