[wp-trac] [WordPress Trac] #46222: Wrong Header Links in REST API

WordPress Trac noreply at wordpress.org
Sat Feb 9 23:40:40 UTC 2019


#46222: Wrong Header Links in REST API
--------------------------+-----------------------------
 Reporter:  Flyer29       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When consuming a link in the REST API leading to a collection and when
 using a parameter which can have multiple values, the header links for
 rel="next" etc... are all wrong and can not be consumed to load the next
 page.

 As a really simple example: When calling http://localhost:8080/wp-
 json/wp/v2/posts?status=publish, the header link of the response contains
 Link: <http://localhost:8080/wp-
 json/wp/v2/posts?status%5B0%5D=publish&page=2>; rel="next". This should be
 http://localhost:8080/wp-json/wp/v2/posts?status=publish&page=2

 In this case, in WP_REST_Posts_Controller, the function get_items
 calculates a $base to be used later in the header using add_query_arg and
 $request_params. The values of the corresponding key can be arrays (like
 for status), and should be imploded with "," before being added with
 add_query_arg.

 This bug occurs not only for the posts controller, but for all controllers
 returning a collection and being able to accept multiple values separated
 with a "," for a parameter.

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


More information about the wp-trac mailing list