[wp-trac] [WordPress Trac] #41796: WP_Term_Query problem using object_ids and number attributes

WordPress Trac noreply at wordpress.org
Tue Sep 12 17:05:56 UTC 2017


#41796: WP_Term_Query problem using object_ids and number attributes
-------------------------------------+--------------------
 Reporter:  elvishp2006              |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  4.9
Component:  Taxonomy                 |     Version:  4.8.1
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+--------------------
Changes (by boonebgorges):

 * keywords:  has-patch => has-patch needs-testing
 * milestone:  Awaiting Review => 4.9


Comment:

 Hi @elvishp2006 - Thanks for the ticket and for the patch. I've reproduced
 the bug.

 The `DISTINCT` keyword can have big performance implications, so ideally
 we would avoid it when possible. In addition, there are cases where
 duplicate term IDs should be preserved - specifically, when
 `fields=all_with_object_id`. See
 https://core.trac.wordpress.org/browser/tags/4.8.1/src/wp-includes/class-
 wp-term-query.php?marks=747-765#L747. We use PHP to filter out duplicates
 based on this criterion.

 As such, I'd recommend a more modest approach: Only add the `DISTINCT`
 keyword when a lack of distinctness affects 'number' or 'offset', and when
 `fields != all_with_object_id`.

 Have a look at [attachment:41796.diff] and see if it makes sense to you.

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


More information about the wp-trac mailing list