Make WordPress Core

Opened 6 years ago

Last modified 6 years ago

#44630 new defect (bug)

WP_Term_Query does not return all terms when 'number' and 'object_ids' are specified

Reported by: ettoredn's profile ettoredn Owned by:
Milestone: Awaiting Review Priority: normal
Severity: critical Version:
Component: Taxonomy Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

When querying for taxonomy terms assigned to certain objects, WP_Term_Query's query is LIMIT'ed if the 'number' argument is specified. This introduces a problem similar to hierarchical taxonomies where results must not be limited in order to retrieve children. In particular, the issue arises because each term_taxonomy_id, or "(term, taxonomy) couple", has more than one relationship in wp_term_relationships thus more than 1 row could be returned for the same term_taxonomy_id.

It is worth to notice that in order to replicate the problem in the attached test, the 'order' argument must be set to DESC which is the opposite of WP_Term_Query's default.

Attachments (2)

wp-term-query_number_objectids_test.diff (1.1 KB) - added by ettoredn 6 years ago.
PHPUnit test
wp-term-query.diff (635 bytes) - added by ettoredn 6 years ago.
Patch

Download all attachments as: .zip

Change History (4)

@ettoredn
6 years ago

Patch

#1 @ettoredn
6 years ago

  • Keywords has-patch has-unit-tests added

#2 @pento
6 years ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.