joppuyo / disable-media-pages

WordPress plugin to disable "attachment" pages automatically created for WordPress media
https://wordpress.org/plugins/disable-media-pages/
GNU General Public License v2.0
19 stars 2 forks source link

Add validate callback to ID argument in endpoint #2

Closed tnottu closed 3 years ago

tnottu commented 3 years ago

I got these warnings in the log:

PHP Warning: array_intersect_key(): Expected parameter 1 to be an array, string given in /data/wordpress/htdocs/wordpress/wp-includes/rest-api/class-wp-rest-server.php on line 1402

And later, in the stack trace:

PHP 16. array_intersect_key('id', array ('title' => 0, 'description' => 1, 'default' => 2, 'type' => 3, 'format' => 4, 'enum' => 5, 'items' => 6, 'properties' => 7, 'additionalProperties' => 8, 'patternProperties' => 9, 'minProperties' => 10, 'maxProperties' => 11, 'minimum' => 12, 'maximum' => 13, 'exclusiveMinimum' => 14, 'exclusiveMaximum' => 15, 'multipleOf' => 16, 'minLength' => 17, 'maxLength' => 18, 'pattern' => 19, 'minItems' => 20, 'maxItems' => 21, 'uniqueItems' => 22, 'anyOf' => 23, 'oneOf' => 24)) /data/wordpress/htdocs/wordpress/wp-includes/rest-api/class-wp-rest-server.php:1402

So it seemed to me that there's something wrong with the id argument in the process endpoint.

Based on the docs it seems that the argument items should have a key and a value. An empty array as value for the id key (['id' => []]) would apparently work as well, but might as well add a validation.

joppuyo commented 3 years ago

Thanks, I had this same WordPress 5.6 issue with another plugin and this seems to be the correct fix.

I'll merge this and create a new release today.