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

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

Merged
merged 10 commits into from Oct 13, 2023

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
tests/phpunit/test-emitter.php Outdated Show resolved Hide resolved
tests/phpunit/test-emitter.php Outdated Show resolved Hide resolved
tests/phpunit/test-emitter.php Outdated Show resolved Hide resolved
@jazzsequence jazzsequence merged commit 7cfd68c into develop Oct 13, 2023
7 checks passed
@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.

None yet

2 participants