[wp-trac] [WordPress Trac] #45753: REST API: Allow header not set when OPTIONS request is made to a route that contains URL params

WordPress Trac noreply at wordpress.org
Tue Mar 19 01:22:58 UTC 2019


#45753: REST API: Allow header not set when OPTIONS request is made to a route that
contains URL params
-------------------------------------------------+-------------------------
 Reporter:  noisysocks                           |       Owner:  kadamwhite
     Type:  defect (bug)                         |      Status:  accepted
 Priority:  normal                               |   Milestone:  5.2
Component:  REST API                             |     Version:  5.0.2
 Severity:  normal                               |  Resolution:
 Keywords:  has-unit-tests has-patch needs-      |     Focuses:
  testing                                        |
-------------------------------------------------+-------------------------
Changes (by kadamwhite):

 * keywords:  needs-patch => has-unit-tests has-patch needs-testing
 * owner:  killua99 => kadamwhite
 * status:  assigned => accepted


Comment:

 Thanks for the patch, @killua99 ! I've updated it with a test for a
 logged-in user, and duplicated it to another controller as a spot-check
 that the fix is applied at the base API level and not specifically to
 posts alone.

 I noticed that our other extant tests for Allow headers (see
 `test_allow_header_sent`) were manually triggering the
 `rest_post_dispatch` filter in order to apply the desired `Allow` header.
 By adding a call to that filter to the unit tests — mirroring the behavior
 within the controller when an actual request is being dispatched — I was
 able to remove the call to `rest_send_allow_header` within
 `rest_handle_options_request`, eliminating a benign but unnecessary side-
 effect. The rest of the patch looks great as-is.

 This could use one other pair of eyes and a manual test, then I think we
 can land it!

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


More information about the wp-trac mailing list