Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Conversation

@wpsmith
Copy link
Contributor

@wpsmith wpsmith commented Dec 28, 2015

get_item is passed an array as opposed to a WP_REST_Request in several places (NOTE, line numbers may change but are correct at the time of submission):

  • class-wp-rest-attachments-controller.php, line 85, 125
  • class-wp-rest-comments-controller.php, line 203, 267
  • class-wp-rest-posts-controller.php, line 235, 309
  • class-wp-rest-terms-controller.php, line 202, 260
  • class-wp-rest-users-controller.php, line 192, 258, 316

The way I see it there are 3 different possible fixes:

  1. The documentation (this PR) needs to be corrected to allow for a generic array.
  2. Each of these instances need to instantiate and use a WP_REST_Request
  3. Refactor get_item to use a helper function to maintain type integrity though I am not sure what this would look like per se.

@danielbachhuber
Copy link
Member

Hm. I think we should be instantiating and using WP_REST_Request

@joehoyle
Copy link
Member

Yeah I'd rather use a WP_REST_Request, I don't like the pattern of passing an array, we get away with this because the request object of course implements ArrayAccess, however it's a bit annoying as in my own code if done something like function get_item( WP_REST_Request $request ) which fatals if you pass it an array.

@danielbachhuber
Copy link
Member

Thanks again for bringing this to our attention, @wpsmith. I've created pull requests to address each instance you've identified.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants