[wp-trac] [WordPress Trac] #39055: REST API: order is ignored when orderby is set to include
WordPress Trac
noreply at wordpress.org
Sun Jan 29 08:09:54 UTC 2017
#39055: REST API: order is ignored when orderby is set to include
-------------------------------------------------+-------------------------
Reporter: joshlevinson | Owner: jnylen0
Type: enhancement | Status: accepted
Priority: normal | Milestone: 4.8
Component: Query | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests needs- | Focuses:
refresh |
-------------------------------------------------+-------------------------
Changes (by jnylen0):
* keywords: has-patch => has-patch has-unit-tests needs-refresh
* owner: => jnylen0
* status: new => accepted
Comment:
@fibonaccina thanks for writing tests. I agree with your description of
the intended behavior. I would make a few minor changes to your unit
tests in [attachment:39055_tests.diff]:
- Create the post objects in `wpSetUpBeforeClass` and delete them in
`wpTearDownAfterClass`. This avoids boilerplate in the code and overhead
when running the test suite.
- Remove the `@ticket` annotations. `git blame` serves this same purpose
just fine. (Do we have it documented somewhere to use these?)
- Some whitespace issues: `array( 1, 2, 3 )` instead of `array (1, 2, 3)`;
align array blocks on the `=>` using spaces.
Another direction we could take these test cases is #39079, which avoids
creating carefully arranged test objects in favor of testing the SQL
clauses generated by `WP_Query`.
Finally it looks like our `WP_Query`
[https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
sort order documentation] needs some work, because it says that the
default order is `DESC`, which is not currently the case if using
`include` (internally `post__in`).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39055#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list