fix: restore date-type meta generation (missing Chronos import)#209
Merged
Conversation
The `meta_type_date` provider referenced `Chronos` without importing it, so PHP resolved the unqualified name against the current namespace and fataled with "Class FakerPress\Provider\Chronos not found" the moment any post was generated with a date-type meta rule. A secondary "Undefined property: stdClass::$terms" warning surfaced in WP_Post::tax_input when the config row had no `terms` or `taxonomies` key, because the array-to-stdClass cast does not synthesize missing properties under PHP 8.x. Both defects landed when the providers were ported to Chronos and only hit users who supplied date meta rules — the rest of the meta types kept working because they never touch Chronos. Tests: - WP_MetaTest covers `meta_type_date` directly and via Faker::format, catching the missing import the next time the file is refactored. - WP_PostTest converts PHP warnings to exceptions while exercising `tax_input` with sparse configs, locking in the property normalization. - PostsEndpointTest gains an end-to-end repro of the user's stack trace. Refs: https://wordpress.org/support/topic/fatal-error-when-using-date-option-in-meta-field-rules/
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
use FakerPress\ThirdParty\Cake\Chronos\Chronos;toWP_Meta.php, fixing a fatal that hit anyone using adate-type meta rule.\$settings->taxonomies/\$settings->termsto arrays insideWP_Post::tax_inputso the array→stdClass cast does not emit "Undefined property" warnings on sparse configs (visible in the same stack trace under PHP 8.x).WP_MetaTest,WP_PostTest) and an end-to-end repro inPostsEndpointTestso the next refactor catches this immediately.Refs wp.org support thread: https://wordpress.org/support/topic/fatal-error-when-using-date-option-in-meta-field-rules/
Why this slipped through
Chronoswas added toWP_Post,WP_User, andWP_Commentbut theuseline was forgotten inWP_Meta. PHP resolved the unqualifiedChronosagainst the file's namespace, fataling withClass "FakerPress\Provider\Chronos" not found. Thetax_inputwarning never crashed locally on older PHP but trips error displays under PHP 8.x withdisplay_errorson.There was no test that called
meta_type_date, which is why the regression shipped.Test plan
slic run wpunit— 69 tests, 228 assertions, all green.wp-admin/admin.php?page=fakerpress-posts, add a Meta rule with type "Date", min/max set, click Generate; confirm a post is created and the meta value is a valid datetime string. Confirmdebug.logshows no warnings or fatals.composer lint:phpagainst the touched source files — no new violations introduced.