WordPress.org

Make WordPress Core

Changeset 13758


Ignore:
Timestamp:
03/18/10 21:55:25 (4 years ago)
Author:
westi
Message:

Make use of apply_filters_ref_array() when running the query. Fixes #9886 props scribu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r13733 r13758  
    18071807            } 
    18081808        } 
    1809         $search = apply_filters('posts_search', $search, $this); 
     1809        $search = apply_filters_ref_array('posts_search', array( $search, &$this ) ); 
    18101810 
    18111811        // Category stuff 
     
    22442244        // manipulations to them are reflected in the paging by day queries. 
    22452245        if ( !$q['suppress_filters'] ) { 
    2246             $where = apply_filters('posts_where', $where); 
    2247             $join = apply_filters('posts_join', $join); 
     2246            $where = apply_filters_ref_array('posts_where', array( $where, &$this ) ); 
     2247            $join = apply_filters_ref_array('posts_join', array( $join, &$this ) ); 
    22482248        } 
    22492249 
     
    22792279 
    22802280            if ( !$q['suppress_filters'] ) { 
    2281                 $cjoin = apply_filters('comment_feed_join', $cjoin); 
    2282                 $cwhere = apply_filters('comment_feed_where', $cwhere); 
    2283                 $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); 
    2284                 $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC'); 
    2285                 $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
     2281                $cjoin = apply_filters_ref_array('comment_feed_join', array( $cjoin, &$this ) ); 
     2282                $cwhere = apply_filters_ref_array('comment_feed_where', array( $cwhere, &$this ) ); 
     2283                $cgroupby = apply_filters_ref_array('comment_feed_groupby', array( $cgroupby, &$this ) ); 
     2284                $corderby = apply_filters_ref_array('comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) ); 
     2285                $climits = apply_filters_ref_array('comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) ); 
    22862286            } 
    22872287            $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 
     
    23092309        // manipulate paging queries should use these hooks. 
    23102310        if ( !$q['suppress_filters'] ) { 
    2311             $where = apply_filters('posts_where_paged', $where); 
    2312             $groupby = apply_filters('posts_groupby', $groupby); 
    2313             $join = apply_filters('posts_join_paged', $join); 
    2314             $orderby = apply_filters('posts_orderby', $orderby); 
    2315             $distinct = apply_filters('posts_distinct', $distinct); 
    2316             $limits = apply_filters( 'post_limits', $limits ); 
    2317  
    2318             $fields = apply_filters('posts_fields', $fields); 
     2311            $where      = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); 
     2312            $groupby    = apply_filters_ref_array( 'posts_groupby',     array( $groupby, &$this ) ); 
     2313            $join       = apply_filters_ref_array( 'posts_join_paged',  array( $join, &$this ) ); 
     2314            $orderby    = apply_filters_ref_array( 'posts_orderby',     array( $orderby, &$this ) ); 
     2315            $distinct   = apply_filters_ref_array( 'posts_distinct',    array( $distinct, &$this ) ); 
     2316            $limits     = apply_filters_ref_array( 'post_limits',       array( $limits, &$this ) ); 
     2317            $fields     = apply_filters_ref_array( 'posts_fields',      array( $fields, &$this ) ); 
    23192318        } 
    23202319 
     
    23242323        // Filter again for the benefit of caching plugins.  Regular plugins should use the hooks above. 
    23252324        if ( !$q['suppress_filters'] ) { 
    2326             $where = apply_filters('posts_where_request', $where); 
    2327             $groupby = apply_filters('posts_groupby_request', $groupby); 
    2328             $join = apply_filters('posts_join_request', $join); 
    2329             $orderby = apply_filters('posts_orderby_request', $orderby); 
    2330             $distinct = apply_filters('posts_distinct_request', $distinct); 
    2331             $fields = apply_filters('posts_fields_request', $fields); 
    2332             $limits = apply_filters( 'post_limits_request', $limits ); 
     2325            $where      = apply_filters_ref_array( 'posts_where_request',   array( $where, &$this ) ); 
     2326            $groupby    = apply_filters_ref_array( 'posts_groupby_request',     array( $groupby, &$this ) ); 
     2327            $join       = apply_filters_ref_array( 'posts_join_request',    array( $join, &$this ) ); 
     2328            $orderby    = apply_filters_ref_array( 'posts_orderby_request',     array( $orderby, &$this ) ); 
     2329            $distinct   = apply_filters_ref_array( 'posts_distinct_request',    array( $distinct, &$this ) ); 
     2330            $fields     = apply_filters_ref_array( 'posts_fields_request',      array( $fields, &$this ) ); 
     2331            $limits     = apply_filters_ref_array( 'post_limits_request',       array( $limits, &$this ) ); 
    23332332        } 
    23342333 
     
    23432342        $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; 
    23442343        if ( !$q['suppress_filters'] ) 
    2345             $this->request = apply_filters('posts_request', $this->request); 
     2344            $this->request = apply_filters_ref_array('posts_request', array( $this->request, &$this ) ); 
    23462345 
    23472346        $this->posts = $wpdb->get_results($this->request); 
    23482347        // Raw results filter.  Prior to status checks. 
    23492348        if ( !$q['suppress_filters'] ) 
    2350             $this->posts = apply_filters('posts_results', $this->posts); 
     2349            $this->posts = apply_filters_ref_array('posts_results', array( $this->posts, &$this ) ); 
    23512350 
    23522351        if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { 
    2353             $cjoin = apply_filters('comment_feed_join', ''); 
    2354             $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'"); 
    2355             $cgroupby = apply_filters('comment_feed_groupby', ''); 
     2352            $cjoin = apply_filters_ref_array('comment_feed_join', array( '', &$this ) ); 
     2353            $cwhere = apply_filters_ref_array('comment_feed_where', array( "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this ) ); 
     2354            $cgroupby = apply_filters_ref_array('comment_feed_groupby', array( '', &$this ) ); 
    23562355            $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 
    2357             $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC'); 
     2356            $corderby = apply_filters_ref_array('comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) ); 
    23582357            $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; 
    2359             $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
     2358            $climits = apply_filters_ref_array('comment_feed_limits', array( 'LIMIT ' . get_option('posts_per_rss'), &$this ) ); 
    23602359            $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"; 
    23612360            $this->comments = $wpdb->get_results($comments_request); 
     
    23642363 
    23652364        if ( !$q['no_found_rows'] && !empty($limits) ) { 
    2366             $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); 
     2365            $found_posts_query = apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ); 
    23672366            $this->found_posts = $wpdb->get_var( $found_posts_query ); 
    2368             $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); 
     2367            $this->found_posts = apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 
    23692368            $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); 
    23702369        } 
     
    23992398 
    24002399            if ( $this->is_preview && current_user_can( $edit_cap, $this->posts[0]->ID ) ) 
    2401                 $this->posts[0] = apply_filters('the_preview', $this->posts[0]); 
     2400                $this->posts[0] = apply_filters_ref_array('the_preview', array( $this->posts[0], &$this )); 
    24022401        } 
    24032402 
     
    24482447 
    24492448        if ( !$q['suppress_filters'] ) 
    2450             $this->posts = apply_filters('the_posts', $this->posts); 
     2449            $this->posts = apply_filters_ref_array('the_posts', array( $this->posts, &$this ) ); 
    24512450 
    24522451        $this->post_count = count($this->posts); 
Note: See TracChangeset for help on using the changeset viewer.