Skip to content

Commit 55c25bd

Browse files
add proper one off input validation
1 parent 1697a9c commit 55c25bd

1 file changed

Lines changed: 34 additions & 14 deletions

File tree

src/wp-includes/abilities/class-wp-settings-abilities.php

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,24 +197,44 @@ private static function register_get_settings(): void {
197197
'description' => __( 'Returns registered WordPress settings grouped by their registration group. Returns key-value pairs per setting.' ),
198198
'category' => 'site',
199199
'input_schema' => array(
200-
'type' => 'object',
201-
'properties' => array(
202-
'group' => array(
203-
'type' => 'string',
204-
'description' => __( 'Filter settings by group name. If omitted, returns all groups. Cannot be used with slugs.' ),
205-
'enum' => self::$available_groups,
200+
'default' => (object) array(),
201+
'oneOf' => array(
202+
// Branch 1: No filter (empty object).
203+
array(
204+
'type' => 'object',
205+
'additionalProperties' => false,
206+
'maxProperties' => 0,
207+
),
208+
// Branch 2: Filter by group only.
209+
array(
210+
'type' => 'object',
211+
'properties' => array(
212+
'group' => array(
213+
'type' => 'string',
214+
'description' => __( 'Filter settings by group name.' ),
215+
'enum' => self::$available_groups,
216+
),
217+
),
218+
'required' => array( 'group' ),
219+
'additionalProperties' => false,
206220
),
207-
'slugs' => array(
208-
'type' => 'array',
209-
'description' => __( 'Filter settings by specific setting slugs. If omitted, returns all settings. Cannot be used with group.' ),
210-
'items' => array(
211-
'type' => 'string',
212-
'enum' => self::$available_slugs,
221+
// Branch 3: Filter by slugs only.
222+
array(
223+
'type' => 'object',
224+
'properties' => array(
225+
'slugs' => array(
226+
'type' => 'array',
227+
'description' => __( 'Filter settings by specific setting slugs.' ),
228+
'items' => array(
229+
'type' => 'string',
230+
'enum' => self::$available_slugs,
231+
),
232+
),
213233
),
234+
'required' => array( 'slugs' ),
235+
'additionalProperties' => false,
214236
),
215237
),
216-
'additionalProperties' => false,
217-
'default' => array(),
218238
),
219239
'output_schema' => self::$output_schema,
220240
'execute_callback' => array( __CLASS__, 'execute_get_settings' ),

0 commit comments

Comments
 (0)