Opened 14 years ago
Closed 10 years ago
#15250 closed enhancement (wontfix)
Filtering get_tax_sql for advanced queries
Reported by: | sc0ttkclark | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1 |
Component: | Query | Keywords: | has-patch |
Focuses: | Cc: |
Description
Currently in the code for 3.1 (trunk) there are no filters running on the new function get_tax_sql which would be useful for plugins to perform more complex MySQL functionality on specific columns.
I suggest adding a filter ;)
Attachments (7)
Change History (37)
#5
@
14 years ago
Added patch that includes the new filter in query.php (not within get_tax_sql function itself due to the lack of information the function is given like no access to $this)
#6
@
14 years ago
Since get_tax_sql() is a method of WP_Object_Query, which is the parent class, you do have access to $this.
#8
@
14 years ago
If it has access to $this, then that would be fine within the function. It was just a misunderstanding on my side.
#9
@
14 years ago
- Keywords has-patch added
context.15250.patch applies the 'get_tax_sql' filter, passing a context too.
I'm still concerned about what would happen if we decide we also need to alter the JOIN clause, for example.
#11
@
14 years ago
Hm... well now with [16414] the terms are first transformed into term_taxonomy_ids, which I guess would need additional handling.
#12
@
14 years ago
Perhaps we should see how things go in 3.1 before exposing the guts of get_tax_sql().
#14
@
14 years ago
Why would we push this to another 3.x release if it's dependent on code that could change in 3.1, can't we just patch / implement once those dependencies are set in stone?
#16
@
14 years ago
Dependencies would be whatever happens to get_tax_sql that @ryan brought up concerns with.
#17
@
14 years ago
I think what ryan was trying to say is that we should wait to see how people use get_tax_sql() after 3.1 is released, before adding the filter.
#18
@
14 years ago
I see that, but I also believe that losing out on implementing a filter out the gate means waiting a whole new dev cycle to be able to do things with core. The proposed filter applies to many needs by giving quite a bit of information to a function that wishes to extend the SQL generated by the function.
#19
@
14 years ago
Please take another look at the code inside get_tax_sql(). It's quite different from what you made the patch against.
If you can give me an example that can efficiently leverage the filter you're proposing, i.e. without wasting queries made by _transform_terms(), I will commit it.
#22
@
12 years ago
- Keywords has-patch dev-feedback added
Refreshed this patch with the latest code from 3.5 trunk
#23
@
12 years ago
Using apply_filters_ref_array() is not necessary anymore, since we dropped support for PHP 4. Can just use apply_filters().
#25
@
10 years ago
- Focuses docs added
- Keywords needs-docs added; dev-feedback removed
- Milestone changed from Future Release to 4.0
Refreshed - I am less in love with this one, but needs filter docs, nonetheless. We can at least make a decision one way or another.
This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.
10 years ago
#29
@
10 years ago
- Milestone changed from 4.0 to Future Release
Pretty late for this one for 4.0, would prefer for this to really get tested and soak. No consensus either.
#30
@
10 years ago
- Milestone Future Release deleted
- Resolution set to wontfix
- Status changed from assigned to closed
I'm strongly against adding filters directly to SQL queries. It's terrible for future backward compatibility, and it's an invitation for plugins to do things that end up causing conflicts with other plugins. (If we could remove the filters in Date and Meta queries without breaking existing plugins, I would.) The changes to WP_Tax_Query in WP 4.1 make it so that pretty much any kind of tax query can be expressed in the syntax of the class, reducing the need for this filter; and anyone who *really* needs to filter SQL for some reason can still use filters like 'posts_where' in WP_Query
.
In the absence of a compelling use case, I'm going to say wontfix.
At the moment, it appears this function has disappeared from trunk for whatever reason. It's no longer in /wp-includes/classes.php so I'll keep an eye out for where it's being moved to before patching.