Changeset 48555 for trunk/src/wp-includes/rest-api.php
- Timestamp:
- 07/21/2020 09:20:22 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r48526 r48555 2053 2053 } 2054 2054 2055 $is_array_type = 'array' === $type || ( is_array( $type ) && in_array( 'array', $type, true ) ); 2056 $is_object_type = 'object' === $type || ( is_array( $type ) && in_array( 'object', $type, true ) ); 2057 2058 if ( $is_array_type && $is_object_type ) { 2059 if ( rest_is_array( $data ) ) { 2060 $is_object_type = false; 2061 } else { 2062 $is_array_type = false; 2063 } 2064 } 2065 2066 $has_additional_properties = $is_object_type && isset( $schema['additionalProperties'] ) && is_array( $schema['additionalProperties'] ); 2067 2055 2068 foreach ( $data as $key => $value ) { 2056 2069 $check = array(); 2057 2070 2058 if ( 'array' === $type || ( is_array( $type ) && in_array( 'array', $type, true ) )) {2071 if ( $is_array_type ) { 2059 2072 $check = isset( $schema['items'] ) ? $schema['items'] : array(); 2060 } elseif ( 'object' === $type || ( is_array( $type ) && in_array( 'object', $type, true ) )) {2073 } elseif ( $is_object_type ) { 2061 2074 if ( isset( $schema['properties'][ $key ] ) ) { 2062 2075 $check = $schema['properties'][ $key ]; 2063 } elseif ( isset( $schema['additionalProperties'] ) && is_array( $schema['additionalProperties'] )) {2076 } elseif ( $has_additional_properties ) { 2064 2077 $check = $schema['additionalProperties']; 2065 2078 } … … 2071 2084 2072 2085 if ( ! in_array( $context, $check['context'], true ) ) { 2086 if ( $is_array_type ) { 2087 // All array items share schema, so there's no need to check each one. 2088 $data = array(); 2089 break; 2090 } 2091 2073 2092 if ( is_object( $data ) ) { 2074 2093 unset( $data->$key );
Note: See TracChangeset
for help on using the changeset viewer.