[wp-trac] [WordPress Trac] #39376: Pass WP_REST_Request object to registered callback for a route schema.

WordPress Trac noreply at wordpress.org
Thu Dec 22 20:36:56 UTC 2016


#39376: Pass WP_REST_Request object to registered callback for a route schema.
--------------------------+-----------------------------
 Reporter:  nerrad        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  4.7
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The documentation here (https://developer.wordpress.org/rest-api/schema
 /#resource-schema) indicates that an instance of `WP_REST_Request` is
 passed along to the registered callback for schema.

 However, as found in `\WP_REST_Server::get_data_for_route` it is clear
 that the callback recieves nothing:

 {{{
 if ( isset( $this->route_options[ $route ] ) ) {
     $options = $this->route_options[ $route ];

     if ( isset( $options['namespace'] ) ) {
         $data['namespace'] = $options['namespace'];
     }

     if ( isset( $options['schema'] ) && 'help' === $context ) {
         $data['schema'] = call_user_func( $options['schema'] );
     }
 }
 }}}

 It's very clear the documentation is in error, and I realize that the
 request instance isn't even really exposed where the callback is invoked.
 For the purpose of dynamic schema generation when there is a single schema
 callback used, it would be useful if we exposed the `$route` to the
 callback.

 If I did a patch for this is it something that would be considered?

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


More information about the wp-trac mailing list