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

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

Closed
bobbingwide opened this issue Nov 5, 2020 · 4 comments
Assignees
Labels
question Further information is requested wontfix This will not be worked on

Comments

@bobbingwide
Copy link
Owner

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
Copy link
Owner Author

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

  • Develop some better error reporting to help the user resolve the problem.
  • It would appear that WordPress could deliver an Errors block, that can be used to display errors detected during processing.
  • When WP_DEBUG and/or other constants are true then the details could be displayed to the end user.
  • When it's not true we could just report that an error has been detected.
  • Perhaps the error should be logged.
  • This could also be used in the case where the experimental-theme.json file couldn't be parsed.

@bobbingwide
Copy link
Owner Author

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
Copy link
Owner Author

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

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

@bobbingwide bobbingwide added question Further information is requested wontfix This will not be worked on labels Jan 10, 2022
@bobbingwide bobbingwide self-assigned this Jan 10, 2022
@bobbingwide
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant