Skip to content

Commit 37559f1

Browse files
REST API: Skip property-dependency arrays in recursive schema keyword stripping.
Add wp_is_numeric_array() guard to the dependencies handler so property-dependency arrays (numeric arrays of strings) are explicitly skipped rather than relying on array_diff_key being a no-op.
1 parent 9d11adc commit 37559f1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-list-controller.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,11 @@ private function strip_internal_schema_keywords( array $schema ): array {
245245

246246
// Sub-schema maps: keys are user-defined, values are sub-schemas.
247247
// Note: 'dependencies' values can also be property-dependency arrays
248-
// (numeric arrays of strings), which is_array() will pass through
249-
// harmlessly since array_diff_key won't match any denylist keys.
248+
// (numeric arrays of strings) which are skipped via wp_is_numeric_array().
250249
foreach ( array( 'properties', 'patternProperties', 'definitions', 'dependencies' ) as $keyword ) {
251250
if ( isset( $schema[ $keyword ] ) && is_array( $schema[ $keyword ] ) ) {
252251
foreach ( $schema[ $keyword ] as $key => $child_schema ) {
253-
if ( is_array( $child_schema ) ) {
252+
if ( is_array( $child_schema ) && ! wp_is_numeric_array( $child_schema ) ) {
254253
$schema[ $keyword ][ $key ] = $this->strip_internal_schema_keywords( $child_schema );
255254
}
256255
}

0 commit comments

Comments
 (0)