| @@ -61,8 +61,30 @@ | ||
| 61 | 61 | */ |
| 62 | 62 | protected $capability = 'manage_options'; |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | + * An empty JSON Schema `properties` map. | |
| 66 | + * | |
| 67 | + * A schema that takes no arguments still has to say so, and the shape it | |
| 68 | + * says it in matters twice over: | |
| 69 | + * | |
| 70 | + * - `[]` JSON-encodes as `[]`. JSON Schema requires an object there, and | |
| 71 | + * strict MCP clients reject the array form (#476). | |
| 72 | + * - `(object) []` encodes as `{}` but is not array-accessible, and | |
| 73 | + * `rest_validate_object_value_from_schema()` indexes into the map — | |
| 74 | + * `isset( $args['properties'][ $key ] )`. On PHP 8 that is a fatal | |
| 75 | + * `Error`, so a single unexpected input key turns a clean 400 into a 500. | |
| 76 | + * | |
| 77 | + * `ArrayObject` is the shape that satisfies both: it JSON-encodes as `{}` | |
| 78 | + * and still answers array access, so core validation runs as it always did. | |
| 79 | + * | |
| 80 | + * @return \ArrayObject<string, mixed> Empty properties map. | |
| 81 | + */ | |
| 82 | + protected static function empty_properties() { | |
| 83 | + return new \ArrayObject(); | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 65 | 87 | * Get the JSON Schema for ability input. |
| 66 | 88 | * |
| 67 | 89 | * @return array<string, mixed> |
| 68 | 90 | */ |