[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
Mon Feb 24 10:12:35 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             |  Resolution:
 Keywords:  needs-patch close  |     Focuses:  rest-api
-------------------------------+------------------------------
Changes (by swissspidy):

 * keywords:  needs-patch => needs-patch close


Comment:

 Custom REST API routes should return `WP_REST_Response`, not
 `WP_HTTP_Response`.

 There's also a `rest_ensure_response()` helper function which wraps the
 data we want to return into a `WP_REST_Response`, and ensures it will be
 properly returned.

 Refer to the documentation at https://developer.wordpress.org/rest-api
 /extending-the-rest-api/routes-and-endpoints/ and
 https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-
 custom-endpoints/

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


More information about the wp-trac mailing list