#15023 closed enhancement (wontfix)
wpdb Filters
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.1 |
| Component: | Plugins | Keywords: | |
| Focuses: | Cc: |
Description
Plugins wishing to hook into wpdb would benefit from having a few additional filters added. Right now, the only filter running is on query, which absolutely requires use of complex regex or a mysql parser to figure out what's going on.
Furthermore, I believe adding filters to the following functions would be useful for adding additional database support apart from MySQL without much code rewriting.
Existing Filter:
- wpdb::query 'query' (normal apply_filters) [Filter the query and rewrite if necessary]
New / Updated Filters:
(note, new filters use _exec at the end to differentiate from format original filter uses for 'query')
- wpdb::query 'query' (use apply_filters_ref_array and pass through &$this) [Filter the query and rewrite if necessary]
- wpdb::query 'query_exec' (use apply_filters_ref_array and pass through &$this) [Same as 'query' except it allows for a plugin to intercept the function and perform it's operations through other DB functions vs forcing mysql_query]
- wpdb::_insert_replace_helper 'insert_replace_exec' (use apply_filters_ref_array and pass through &$this) [Allows for a plugin to intercept the function and perform it's operations through other DB functions vs forcing mysql_query] {This function is used by wpdb::insert and wpdb::replace}
- wpdb::update 'update_exec' (use apply_filters_ref_array and pass through &$this) [Allows for a plugin to intercept the function and perform it's operations through other DB functions vs forcing mysql_query]
Attachments (1)
Change History (7)
#1
follow-up:
↓ 4
@
16 years ago
Wouldn't it be more effective to extend wpdb if you need such deep integration at the database level?
#2
@
16 years ago
Yes, that would also be possible. But perhaps some of the adjustments here have merit, if not intercepting then perhaps filtering the values in wpdb::_insert_replace_helper and wpdb::update?
#3
@
16 years ago
Also, the adjustment to the wpdb::query 'query' filter would also pass &$this, which would be beneficial too.
#4
in reply to:
↑ 1
@
16 years ago
Replying to nacin:
Wouldn't it be more effective to extend wpdb if you need such deep integration at the database level?
I agree. Regular plugins shouldn't be messing with this. Don't really see the point of the existing filter either.
Initial Patch including the new / updated filters