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

Latest Posts Widget Block throwing PHP warning #12119

Closed
ianbelanger79 opened this issue Nov 20, 2018 · 1 comment
Closed

Latest Posts Widget Block throwing PHP warning #12119

ianbelanger79 opened this issue Nov 20, 2018 · 1 comment
Labels
[Block] Latest Posts Affects the Latest Posts Block [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Milestone

Comments

@ianbelanger79
Copy link
Contributor

When the Latest Posts Widget Block is used, I am seeing a PHP warning in the editor for each instance of the block:

Notice: Undefined index: categories in /srv/www/wordpress-develop/public_html/build/wp-content/plugins/gutenberg/packages/block-library/src/latest-posts/index.php on line 22

This same error will also show on the frontend, if the Category of the block is set to "All".

To Reproduce

  1. Create a post
  2. Add the Latest Posts Widget Block
  3. Set the category to "All"
  4. See warning

Expected behavior
There shouldn't be any warnings

Screenshots
latest-posts-block-undefined

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version 70.0.3538.102

Additional context

  • Most recent version of GB Master, with all commits as of writing this
  • GB Nightly build https://builds.danielbachhuber.com/gutenberg-nightly.zipdoes not throw any warnings
@ianbelanger79 ianbelanger79 added [Type] Bug An existing feature does not function as intended [Block] Latest Posts Affects the Latest Posts Block labels Nov 20, 2018
@designsimply designsimply added the Needs Testing Needs further testing to be confirmed. label Nov 20, 2018
@dd32
Copy link
Member

dd32 commented Nov 21, 2018

Duplicated with WordPress 4.9.8 + Gutenberg 4.5.

4.9.8 has this as $attributes:

wp-content/plugins/gutenberg/packages/block-library/src/latest-posts/index.php:16:
array (size=6)
  'postsToShow' => int 5
  'displayPostDate' => boolean false
  'postLayout' => string 'list' (length=4)
  'columns' => int 3
  'order' => string 'desc' (length=4)
  'orderBy' => string 'date' (length=4)

Where as 5.0 $attributes has this:

wp-includes/blocks/latest-posts.php:16:
array (size=9)
  'categories' => null
  'className' => null
  'postsToShow' => int 5
  'displayPostDate' => boolean true
  'postLayout' => string 'list' (length=4)
  'columns' => int 3
  'align' => null
  'order' => string 'desc' (length=4)
  'orderBy' => string 'date' (length=4)

@pento pento added [Type] Regression Related to a regression in the latest release and removed Needs Testing Needs further testing to be confirmed. labels Nov 21, 2018
@pento pento modified the milestones: 4.6, WordPress 5.0 Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Latest Posts Affects the Latest Posts Block [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

No branches or pull requests

4 participants