[wp-trac] [WordPress Trac] #49028: Provide functionality to suppress $wpdb query filter

WordPress Trac noreply at wordpress.org
Thu Dec 19 16:29:11 UTC 2019


#49028: Provide functionality to suppress $wpdb query filter
-------------------------------+------------------------------
 Reporter:  aurovrata          |       Owner:  (none)
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Database           |     Version:  trunk
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by aurovrata):

 Good eve @johnbillion, thank you for looking into this.

 >What's the underlying problem here?

 I maintain a plugin which uses `$wpdb` to retrieve values from the DB and
 some users are facing issues with the values retrieved being construed by
 a filter in one of thee plugins/theme they use which alters the query.

 >Removing the ability to filter the query altogether just reduces the
 extensibility of WordPress.

 no that's not what I am suggesting, if you read my initial ticket I am
 suggesting a similar functionality as the 'suppress_filters' parameter
 that is passed to the `get_posts` function.

 This would allow me to fire a `$wpdb` query and suppress the 'query'
 filter, just for that specific query.

 So here is a scenario I am suggesting,

 {{{#!php
 $wpdb->suppress_filters = true;
 $wpdb->get_col($wpdb->prep(<sql query>));
 }}}

 in the wp-includes/wp-db.php file where the $wpdb class resides,

 {{{#!php
 if(!$this->suppress_filters){
   $query = apply_filters( 'query', $query );
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49028#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list