WordPress.org

Make WordPress Core

Opened 15 months ago

Last modified 9 months ago

#44630 new defect (bug)

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

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

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 15 months ago.
PHPUnit test
wp-term-query.diff (635 bytes) - added by ettoredn 15 months ago.
Patch

Download all attachments as: .zip

Change History (4)

@ettoredn
15 months ago

Patch

#1 @ettoredn
14 months ago

  • Keywords has-patch has-unit-tests added

#2 @pento
9 months ago

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