Fatal error in post-hierarchical-terms.php for unregistered taxonomy name #26851
Labels
[Block] Post Terms
Affects the Post Terms Block
[Type] Bug
An existing feature does not function as intended
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:
core/post-hierarchical-terms
block with an unknown taxonomy name.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):
Desktop (please complete the following information):
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.
The text was updated successfully, but these errors were encountered: