Make WordPress Core

Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#25284 closed enhancement (fixed)

Support tax queries using term_taxonomy_id without specifying a taxonomy

Reported by: helen's profile helen Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch needs-unit-tests
Focuses: Cc:


Taxonomy queries using term_taxonomy_id don't actually check to see if the terms exist in the specified taxonomy. So long as an existing taxonomy is used, it allows you to query across multiple taxonomies in one segment of the query. We should officially support not specifying a taxonomy if using term_taxonomy_id as the field, and do the magic to make include_children work.

Attachments (2)

25284.diff (4.9 KB) - added by helen 11 years ago.
25284.2.diff (4.7 KB) - added by helen 10 years ago.

Download all attachments as: .zip

Change History (8)

#1 @helen
11 years ago

Working on patch, including unit tests to make sure crazy things being done don't break in the future.

11 years ago

10 years ago

#3 @helen
10 years ago

  • Keywords has-patch needs-testing added

Having now worked on this and thought about it some more, I don't think include_children should work without taxonomy specified so long as we have shared terms. It's backward, and if you're taking the time to get the term_taxonomy_id, you should get the children that you want while you're at it.

Patch includes the start of some unit tests. They need to be fleshed out to encompass all possible scenarios, and can probably be written better. Still new to that part.

#4 @wonderboymusic
10 years ago

  • Keywords needs-unit-tests added; needs-testing removed
  • Milestone changed from Awaiting Review to 4.0

@helen and I chatted about this - want to look at this during our Taxonomy work in 4.0

#5 @wonderboymusic
10 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28562:

When adding queries to tax_query: if the query's field is term_taxonomy_id, don't require taxonomy to be specified. In WP_Tax_Query::transform_query(), $query['taxonomy'] is never checked for the 'term_taxonomy_id' case because 'term_taxonomy_id' is the primary key being looked up.

Adds unit tests.

Props helen.
Fixes #25284.

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.

10 years ago

Note: See TracTickets for help on using tickets.