bobbingwide / fizzie

Fizzie theme - a Full Site Editing theme using Gutenberg blocks
9 stars 1 forks source link

Explain the Warning: array_key_exists() messages displayed on search results #19

Closed bobbingwide closed 2 years ago

bobbingwide commented 3 years ago

Warning: array_key_exists() expects parameter 2 to be array, null given in C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\lib\block-supports\align.php on line 48

Warning: array_key_exists() expects parameter 2 to be array, null given in C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\lib\block-supports\colors.php on line 73

Warning: array_key_exists() expects parameter 2 to be array, null given in C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\lib\block-supports\colors.php on line 108

Warning: array_key_exists() expects parameter 2 to be array, null given in C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\lib\block-supports\colors.php on line 125

Warning: array_key_exists() expects parameter 2 to be array, null given in C:\apache\htdocs\wordpress\wp-content\plugins\gutenberg-wordpress-source\lib\block-supports\custom-classname.php on line 46

bobbingwide commented 3 years ago

Explanation

User error.

These messages were produced because the wp:template-part block tag was badly formed.

<!-- wp:template-part {"slug":"archive-query", "theme":"fizzie", "tagName": "section", "className": "archive" /-->

In this example the right curly brace is missing.

When this happens the template part name ( slug ) isn't known.

The message displayed is:

Template Part Not Found: PostId: Theme:div

In fact, only one attribute value is set. It's the tagName, which has a value of div... different from the value that I tried to pass.

Immediate fix

Correct the block.

Possible improvement

bobbingwide commented 3 years ago

Another way to make the block fail is to have the closing curly brace too early.

<!-- wp:template-part {"slug":"footer-menu","theme":"fizzie"}, "className":"footer-menu" /-->

This was a problem in the singular.html template.

bobbingwide commented 3 years ago

Another way is: forget the quotes and use an equals separator instead of colon

<!-- wp:template-part {"slug":"metadates", "theme":"fizzie", className="metadates" } /-->
bobbingwide commented 2 years ago

Closing this issue as wontfix. The messages have been explained and more examples of adly formed template parts have been documented.