Skip to content

[BUGS-6934] Gracefully handle archive pages with multiple post types#252

Merged
jazzsequence merged 10 commits intodevelopfrom
get_query_var-is-array
Oct 13, 2023
Merged

[BUGS-6934] Gracefully handle archive pages with multiple post types#252
jazzsequence merged 10 commits intodevelopfrom
get_query_var-is-array

Conversation

@jazzsequence
Copy link
Contributor

@jazzsequence jazzsequence commented Oct 10, 2023

This PR resolves the issue where archive pages with multiple post types throws a PHP array to string conversion warning.

get_query_var can return an array or a string, depending on the query. Previously we were assuming get_query_var( 'post_type' ) would only ever return a string. Most of the time this would be true, but there are cases where it is not.

This PR adds tests against this scenario and adds handling that runs a is_array check on get_query_var( 'post_type' ) and if it is an array, emits surrogate keys for each post type.

this PR also creates a new Factory that extends the base WP Unit Test factory to avoid dynamically creating it and throwing PHP 8 deprecation warnings.

@jazzsequence jazzsequence requested a review from a team as a code owner October 10, 2023 22:12
@jazzsequence jazzsequence self-assigned this Oct 10, 2023
@jazzsequence jazzsequence requested a review from pwtyler October 11, 2023 14:35
@jazzsequence jazzsequence merged commit 7cfd68c into develop Oct 13, 2023
@jazzsequence jazzsequence deleted the get_query_var-is-array branch October 13, 2023 21:31
@jazzsequence jazzsequence mentioned this pull request Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants