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

WordPress Trac noreply at wordpress.org
Sun Feb 5 07:46:48 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 fibonaccina):

 @jnylen0 I see what you mean, thank you for providing this detailed
 background. I'm not so familiar with the codebase and I hadn't realized
 there is actually some complicated mapping of parameters happening in the
 REST API posts controller that might make the behavior different in the
 higher level API handling from WP_Query.

 It would be ideal to keep the behavior of WP_Query in sync with that of
 the API posts controller. Cases where these diverge could cause
 documentation omissions like the one you caught.

 As the changes required involve picking out the 3 outliers
 ({{{post__in}}}, {{{post_parent__in}}}, {{{post_name__in}}}) and adding
 custom handling for them, I second your position to not make this change,
 but in any case to set users' expectations correctly through
 documentation.

 I've changed the tests ( 39055_tests_current_behavior.diff ) to reflect
 the current behavior. Hopefully my comments there convey to a prospective
 reader that if the 'include' array is not sorted when provided as input,
 we do sort it in the results. The tests are all passing.

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


More information about the wp-trac mailing list