Opened 14 years ago
Closed 10 years ago
#19094 closed enhancement (wontfix)
Add wp_get_object_terms filters.
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2.1 |
Component: | Taxonomy | Keywords: | has-patch 2nd-opinion |
Focuses: | Cc: |
Description
I wasted whole day looking for some filter I could use for changing the select query of wp_get_object_terms.
Please add filter like terms_clauses but for wp_get_object_terms (or use the same filter), because terms_clauses is NOT called when there are terms selected for the object. For example. When you select categories for post.
Attachments (1)
Change History (9)
#1
@
14 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Type changed from feature request to enhancement
#3
in reply to:
↑ 2
@
14 years ago
Replying to Zatsugami:
Hmm, it may be a stupid question, but can I apply this to be a patch?
If so, how?
#5
@
14 years ago
- Keywords 2nd-opinion added; needs-patch removed
Ok, so are you sure this filter can't be added to a higher-level function?
#6
@
14 years ago
In my case I needed to join mysql table, so probably there is no other way to do it.
There is posts_clauses, terms_clauses (as I mentioned, it is not called when getting objects terms), but there is no object_terms_clauses or any other filters.
I could use filter 'wp_get_object_terms' which is called at the end of this function, but what you get there is an array of terms, so I would need to loop through them, get the ids of terms and do other query. Anyway, so much unnecessary work would be done.
Also, there would be a small inconsistency in this patch in regards to pieces names in object_terms_clauses array. The 'select' piece in other filters is called 'fields';
But there would be more work to do with the code to make the names the same. But this can be done if you prefer consistency.
#8
@
10 years ago
- Milestone Future Release deleted
- Resolution set to wontfix
- Status changed from new to closed
Thanks for the ticket, Zatsugami, and sorry for the delay in response.
Filtering SQL clauses is something we're loath to do except when absolutely necessary, as it makes it very difficult for us to make future changes to the queries involved without breaking backward compatibility. As you note, in your case it's possible to use the 'wp_get_object_terms' array to do what you need, and I'd guess that the same is true for the majority of potential use cases, which suggests that the SQL filter is unnecessary.
I'm glad to be overruled in the case of overwhelming evidence to the contrary, but for the time being, I'm going to mark this one wontfix.
Ok, I've done it myself. It should work.
Basically copy-paste of posts_clauses.
It's somewhere around line 1897 wp-inlcudes/taxonomy.php
Hmm, it may be a stupid question, but can I apply this to be a patch?
If so, how?