[wp-trac] [WordPress Trac] #39055: REST API: order is ignored when orderby is set to include

WordPress Trac noreply at wordpress.org
Tue Feb 7 19:45:21 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                                        |
-------------------------------------------------+-------------------------

Comment (by jnylen0):

 Hi @fibonaccina - in doing a more detailed review of
 [attachment:39055_tests_current_behavior.diff] I found a couple more
 problems:

 - The new tests live in `tests/phpunit/tests/query/search.php` which tests
 the search parameters specifically, but a better place is
 `query/results.php`.  Note this file also has plenty of fixtures already.
 - The new tests pass `include` and `orderby => include` to WP_Query.
 However, this should be `post__in` - `include` is only meaningful in the
 WP REST API, as part of the remapping done there to make parameter names
 more user-friendly
 ([https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-includes/rest-
 api/endpoints/class-wp-rest-posts-controller.php?marks=180#L170 ref]).

 So, we need to change all instances of `include` to `post__in` in your new
 test cases, revise the logic so that they pass, and move them to
 `query/results.php`.

 There are also some spacing issues in your patch:

  - Should be `array( 1, 2, 3 )` instead of `array ( 1, 2, 3 )`
  - Should be `foreach ( ... )` instead of `foreach( ... )`
  - Multiline arrays should be indented with one tab, rather than matching
 the level of indentation of the opening `(`

 See the [https://make.wordpress.org/core/handbook/best-practices/coding-
 standards/php/ PHP coding standards], in particular the sections on
 [https://make.wordpress.org/core/handbook/best-practices/coding-
 standards/php/#indentation indentation] and
 [https://make.wordpress.org/core/handbook/best-practices/coding-
 standards/php/#space-usage spacing].

 I'm happy to either review an updated patch, or to make these revisions
 myself, as you prefer.

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


More information about the wp-trac mailing list