Repository navigation
Conversation
… property helpers. See #66770.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
rest_find_matching_pattern_property_schema()documents@param string $property, andrest_validate_json_schema_pattern()documents@param string $patternand@param string $value. Each can come from an array key, and PHP stores a numeric key such as"123"as the integer123. REST requests decode JSON bodies into arrays, so a numeric property name orpatternPropertieskey reaches these functions as an integer.Trac ticket: https://core.trac.wordpress.org/ticket/66770
What changes
@param string|int $propertyinrest_find_matching_pattern_property_schema().@param string|int $patternand@param string|int $valueinrest_validate_json_schema_pattern().Tests_REST_API_RestFindMatchingPatternPropertySchema: the pattern'123'(an integer key) matches the propertya123. The function's integer property name case is already covered there.Testing
var_dump( array_keys( json_decode( '{"123":1}', true ) ) );printsint(123).vendor/bin/phpunit --filter '^Tests_REST_API_RestFindMatchingPatternPropertySchema::': OK (8 tests, 8 assertions). With a temporaryif ( ! is_string( $pattern ) ) { return false; }inrest_validate_json_schema_pattern(), only the new data set fails.gettype()in both functions, the existing tests inTests_JSON_Schema,Tests_REST_API,WP_Test_REST_Schema_Validation,WP_Test_REST_Schema_Sanitization,Tests_Abilities_API_WpRegisterCoreAbilitiesandTests_REST_Serverpass integer property names fromrest_validate_object_value_from_schema()(30 calls),wp_prepare_json_value_for_client()(2) andrest_filter_response_by_context()(1).phpstan.neon.dist) reports nothing onrest-api.php.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code and Codex
Used for: Investigation, code, tests, local testing and PR wording. I reviewed the reasoning, the code and the test results, and I take responsibility for the contribution.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.