[wp-trac] [WordPress Trac] #37151: WP_Term_Query not honoring orderby meta_value_num

WordPress Trac noreply at wordpress.org
Sat Jun 25 12:12:04 UTC 2016


#37151: WP_Term_Query not honoring orderby meta_value_num
-------------------------------------+---------------------------
 Reporter:  littler.chicken          |       Owner:  boonebgorges
     Type:  defect (bug)             |      Status:  reviewing
 Priority:  normal                   |   Milestone:  4.6
Component:  Taxonomy                 |     Version:  trunk
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+---------------------------
Changes (by boonebgorges):

 * keywords:  needs-unit-tests => has-patch needs-testing


Comment:

 Hi @littler.chicken - Thanks for the report.

 > I get completely bogged down when I try to diagnose any further in the
 WP_Meta_Query class

 I was a bit bogged down too :) This is a pretty subtle issue. Briefly, the
 way that `WP_Term_Query` sanitizes the `orderby` parameter means that the
 meta query's SQL clauses must have been generated. This logic was changed
 in 4.6, which is why your previously-working code doesn't work anymore.
 It's possible to force the meta query to generate its SQL, but this
 uncovers a bug in `WP_Meta_Query`: running `get_sql()` doesn't reset the
 internal list of table aliases, which results in malformed SQL in some
 cases.

 Could you test [attachment:37151.diff] to see if it addresses your issue?

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


More information about the wp-trac mailing list