[wp-trac] [WordPress Trac] #34659: Whitelist for validation functions which only accept one argument

WordPress Trac noreply at wordpress.org
Wed Nov 11 14:24:16 UTC 2015


#34659: Whitelist for validation functions which only accept one argument
-----------------------------+-----------------------
 Reporter:  danielbachhuber  |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  4.4
Component:  REST API         |    Version:
 Severity:  normal           |   Keywords:  has-patch
  Focuses:                   |
-----------------------------+-----------------------
 `WP_REST_Request` supports a `validate_callback` for arguments. When it
 calls the `validate_callback`, it passes additional contextual arguments:

 {{{
 $valid_check = call_user_func( $arg['validate_callback'], $param, $this,
 $key );
 }}}

 However, some validation functions like `is_numeric` only support one
 argument:

 {{{
 1) Tests_REST_Request::test_validate_callback_only_pass_value
 is_numeric() expects exactly 1 parameter, 3 given
 }}}

 I propose we add a filterable whitelist of validation functions that
 should only be passed one argument.

 We may want to do the same for sanitization callbacks.

 Originally:
 * https://github.com/WP-API/WP-API/issues/1585
 * https://github.com/WP-API/WP-API/issues/1520

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34659>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list