diff --git a/src/wp-includes/abilities.php b/src/wp-includes/abilities.php index c71eeb158a304..0320df3b9f38a 100644 --- a/src/wp-includes/abilities.php +++ b/src/wp-includes/abilities.php @@ -220,7 +220,6 @@ function wp_register_core_abilities(): void { 'db_server_info' => array( 'type' => 'string', 'description' => __( 'The database server vendor and version string reported by the driver.' ), - 'examples' => array( '8.0.34', '10.11.6-MariaDB' ), ), 'wp_version' => array( 'type' => 'string', diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-list-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-list-controller.php index 4f59d908de2c5..6dfc54003863e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-list-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-list-controller.php @@ -194,6 +194,27 @@ public function get_item_permissions_check( $request ) { return current_user_can( 'read' ); } + /** + * Normalizes schema empty object defaults. + * + * Converts empty array defaults to objects when the schema type is 'object' + * to ensure proper JSON serialization as {} instead of []. + * + * @since 6.9.0 + * + * @param array $schema The schema array. + * @return array The normalized schema. + */ + private function normalize_schema_empty_object_defaults( array $schema ): array { + if ( isset( $schema['type'] ) && 'object' === $schema['type'] && isset( $schema['default'] ) ) { + $default = $schema['default']; + if ( is_array( $default ) && empty( $default ) ) { + $schema['default'] = (object) $default; + } + } + return $schema; + } + /** * Prepares an ability for response. * @@ -209,8 +230,8 @@ public function prepare_item_for_response( $ability, $request ) { 'label' => $ability->get_label(), 'description' => $ability->get_description(), 'category' => $ability->get_category(), - 'input_schema' => $ability->get_input_schema(), - 'output_schema' => $ability->get_output_schema(), + 'input_schema' => $this->normalize_schema_empty_object_defaults( $ability->get_input_schema() ), + 'output_schema' => $this->normalize_schema_empty_object_defaults( $ability->get_output_schema() ), 'meta' => $ability->get_meta(), );