[wp-trac] [WordPress Trac] #15042: plugin.php functions (filters) should be available to all pluggable components (wpdb, object cache)

WordPress Trac wp-trac at lists.automattic.com
Thu Oct 7 03:00:37 UTC 2010


#15042: plugin.php functions (filters) should be available to all pluggable
components (wpdb, object cache)
--------------------------+-------------------------------------------------
 Reporter:  andy          |       Owner:                
     Type:  defect (bug)  |      Status:  new           
 Priority:  normal        |   Milestone:  3.1           
Component:  Plugins       |     Version:                
 Severity:  normal        |    Keywords:  filter, plugin
--------------------------+-------------------------------------------------
Changes (by andy):

  * type:  enhancement => defect (bug)


Comment:

 Replying to [comment:2 jacobsantos]:
 > Question: How would one actually hook into these functions? No plugins
 would be loaded, because the DB will not have access to load those plugins
 yet. Is the assumption that a future feature will be added that autoloads
 for these requirements?

 I want to use the 'query' filter and I want to be sure that every query is
 passed through my filter. However, the 'query' filter is only applied
 conditionally because apply_filters is not necessarily available when the
 first query is run.

 There are typically several queries executed before plugins are loaded.
 Thus, if I want all queries to pass through my filter I must add my filter
 prior to the first query. Thus I must add my filter during the database
 configuration phase. This is impossible because the entire database
 inclusion phase is completed prior to the inclusion of plugin.php.

 Strictly speaking, I can hack globals to add a filter any time I want. I
 don't like doing this, but I've done it. However, if I need to execute a
 query during the database configuration phase, my filters will not be
 applied because the 'query' filter is conditional upon the existence of a
 function in plugin.php.

 While these are certainly edge and corner cases, they are not unrealistic.
 I created this ticket because HyperDB needs a query filter that never lets
 a query escape the filter. A new system is not needed; what is needed is
 add_filter and apply_filters. True story.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15042#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list