fix: honor selected post_types on the Posts generate endpoint#210
Merged
Conversation
The admin Posts form serializes the post-type selector as `post_types` (plural) and POSTs straight to /fakerpress/v1/posts/generate. The schema only declared the singular `post_type` (with a default of `post`), and the handler unconditionally clobbered `post_types` with whatever was in `post_type` — meaning the default `post` always won, even when the user explicitly picked Pages. Reporters saw only Posts created no matter what they selected. The schema now exposes `post_types` as the canonical parameter (accepts array or comma-separated string) while keeping `post_type` as a documented singular alias for older REST clients. The translation prefers the plural value when present and falls back to the alias only when it isn't, so the admin form, the singular alias, and array-shaped JSON payloads all land at the same module input. Tests: PostsEndpointTest gains four regressions — plural CSV, plural array, multi-type CSV, and an explicit "plural wins over singular default" check that pins the exact bug. Refs: https://wordpress.org/support/topic/doesnt-seem-to-create-pages-now/
5903a0d to
52f941f
Compare
bordoni
added a commit
that referenced
this pull request
May 22, 2026
Two wp.org regressions land in this patch release: - #209 — `WP_Meta::meta_type_date` fataled with "Class 'Chronos' not found" because the provider file never imported Chronos. Restores date-type meta generation and adds a regression test path (WP_MetaTest plus an end-to-end REST repro). - #210 — The Posts generator silently created Posts instead of the user-selected type because the admin form's plural `post_types` value was overwritten by the singular alias's default of `post`. The schema now documents `post_types` as the canonical parameter (array or CSV) with `post_type` kept as a deprecated alias. Plus a PHP 8.x undefined-property warning in `WP_Post::tax_input` and fresh wpunit coverage that pins both regressions in place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
post_types(plural) as the canonical parameter onPOST /fakerpress/v1/posts/generate, accepting either an array of slugs or a comma-separated string — matching what the admin form actually submits.post_type(singular) as a documented alias for older REST consumers, but stops letting its schema default (post) silently overwrite an explicitly-suppliedpost_typesvalue.Refs wp.org support thread: https://wordpress.org/support/topic/doesnt-seem-to-create-pages-now/
Why this slipped through
The endpoint's existing test only ever exercised
post_type(singular) — the alias the schema knew about. The admin form serializes its post-type dropdown aspost_types[]/post_types, so live users hit a code path no test covered. Because the schema also defaulted the singular alias topost, the translation block in the handler kept clobbering the plural value with that default, and every generation came out as a Post regardless of selection.Test plan
slic run wpunit— 67 tests, 249 assertions, all green (4 new tests for this regression).composer lint:phpagainst the changed file — no new violations introduced.