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

Fatal error in post-hierarchical-terms.php for unregistered taxonomy name #26851

Closed
bobbingwide opened this issue Nov 10, 2020 · 0 comments · Fixed by #26854
Closed

Fatal error in post-hierarchical-terms.php for unregistered taxonomy name #26851

bobbingwide opened this issue Nov 10, 2020 · 0 comments · Fixed by #26854
Labels
[Block] Post Terms Affects the Post Terms Block [Type] Bug An existing feature does not function as intended

Comments

@bobbingwide
Copy link
Contributor

bobbingwide commented Nov 10, 2020

Describe the bug
When the core/post-hierarchical-terms block is invoked with a taxonomy name that's not registered a Fatal error is issued.
This is due to the logic trying to process a WP_error.

To reproduce
Steps to reproduce the behavior:

  1. Create a template containing the core/post-hierarchical-terms block with an unknown taxonomy name.
 <!-- wp:post-hierarchical-terms {"term":"26851"} /-->
  1. Attempt to view content using this template.
  2. See two Notices and a Fatal error

Notice: Trying to get property 'term_id' of non-object in C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\build\block-library\blocks\post-hierarchical-terms.php on line 32

Notice: Trying to get property 'name' of non-object in C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\build\block-library\blocks\post-hierarchical-terms.php on line 33

Fatal error: Uncaught Error: Object of class WP_Error could not be converted to string.

Expected behavior
Fail gracefully by returning '' when a WP_Error has been detected.

Screenshots

Editor version (please complete the following information):

  • WordPress version: [e.g: 5.3.2] 5.6-beta3
  • Does the website has Gutenberg plugin installed, or is it using the block editor that comes by default? [e.g: "gutenberg plugin", "default"] 9.3.0
  • If the Gutenberg plugin is installed, which version is it? [e.g., 7.6]

Desktop (please complete the following information):

  • OS: [e.g. iOS] Windows
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22] Version 86.0.4240.183 (Official Build) (64-bit)

Additional context

  • Originally raised as Fatal error in post-hierarchical-terms.php bobbingwide/fizzie#29

  • In my opinion the attribute should not be called term; it is the taxonomy name.

  • It is possible to create this problem using the Code editor in a post.

  • If you do so, and you quit the editor in Visual editor mode, then you may find it difficult to fix the error.

  • The problem occurs in the editor as well as the front-end.

  • You may have to resort to the classic editor.
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Terms Affects the Post Terms Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants