[wp-trac] [WordPress Trac] #49495: Undefined method WP_HTTP_Response::set_matched_route() called by dispatch() in WP_REST_Server class

WordPress Trac noreply at wordpress.org
Sun Feb 23 10:16:03 UTC 2020


#49495: Undefined method WP_HTTP_Response::set_matched_route() called by dispatch()
in WP_REST_Server class
--------------------------+-----------------------------
 Reporter:  ali11007      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  5.3.2
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:  rest-api      |
--------------------------+-----------------------------
 When registering new route for REST API using register_rest_route() and
 returning a WP_HTTP_Response object in defined callback, a fatal error
 occurs.

 Steps to recreate error:
 In a plugin: write this code:
 {{{#!php
 <?php
 add_action('rest_api_init', 'foo');
 function foo()
 {
   register_rest_route( 'namespace', '/route', array(
     'methods' => 'GET',
     'callback' => 'bar'
   ));
 }
 function bar($req)
 {
   return new \WP_HTTP_Response();
 }
 }}}
 the error is:

 {{{
 Fatal error: Uncaught Error:
 Call to undefined method WP_HTTP_Response::set_matched_route()
 in /path/to/wordpress/wp-includes/rest-api/class-wp-rest-server.php:978
 }}}

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


More information about the wp-trac mailing list