Guard Instant Results facets against invalid taxonomy values #4255
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
This PR prevents a fatal error in Instant Results taxonomy facets when the
ep_facet_include_taxonomiesfilter returns unexpected values (e.g., a taxonomy slug string such asinternal_tagsrather than aWP_Taxonomyobject).InstantResults::get_facets()currently assumes each filtered taxonomy entry is aWP_Taxonomyobject and passes it directly toget_taxonomy_labels(). If a third-party integration appends a slug string, WordPress core fatals when it tries to treat a string as an object (e.g.,Attempt to assign property "labels" on stringinwp-includes/taxonomy.php).This change adds a defensive guard in the taxonomy facets loop:
get_taxonomy( $slug )WP_Taxonomy, skip itThis prevents wp-admin lockouts while preserving existing behavior for correctly shaped data.
Closes #4254
How to test the Change
internal_tagsas a string viaep_facet_include_taxonomies)./wp-admin//wp-admin/admin.php?page=elasticpressVerified on: WordPress 6.9; PHP 8.4.
Changelog Entry
Credits
Props @laraib15
Checklist: