Make WordPress Core

Changeset 8766


Ignore:
Timestamp:
08/28/2008 10:30:27 PM (16 years ago)
Author:
ryan
Message:

Suppress query filters when called from get_posts(). see #7326 #7547

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r8732 r8766  
    454454        'exclude' => '', 'meta_key' => '',
    455455        'meta_value' =>'', 'post_type' => 'post',
    456         'post_parent' => 0
     456        'post_parent' => 0, 'suppress_filters' => true
    457457    );
    458458
  • trunk/wp-includes/query.php

    r8754 r8766  
    838838            $q['caller_get_posts'] = false;
    839839
     840        if ( !isset($q['suppress_filters']) )
     841            $q['suppress_filters'] = false;
     842
    840843        if ( !isset($q['post_type']) ) {
    841844            if ( $this->is_search )
     
    13731376        // Apply filters on where and join prior to paging so that any
    13741377        // manipulations to them are reflected in the paging by day queries.
    1375         $where = apply_filters('posts_where', $where);
    1376         $join = apply_filters('posts_join', $join);
     1378        if ( !$q['suppress_filters'] ) {
     1379            $where = apply_filters('posts_where', $where);
     1380            $join = apply_filters('posts_join', $join);
     1381        }
    13771382
    13781383        // Paging
     
    14061411            }
    14071412
    1408             $cjoin = apply_filters('comment_feed_join', $cjoin);
    1409             $cwhere = apply_filters('comment_feed_where', $cwhere);
    1410             $cgroupby = apply_filters('comment_feed_groupby', $cgroupby);
     1413            if ( !$q['suppress_filters'] ) {
     1414                $cjoin = apply_filters('comment_feed_join', $cjoin);
     1415                $cwhere = apply_filters('comment_feed_where', $cwhere);
     1416                $cgroupby = apply_filters('comment_feed_groupby', $cgroupby);
     1417            }
    14111418
    14121419            $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss'));
     
    14281435        // Apply post-paging filters on where and join.  Only plugins that
    14291436        // manipulate paging queries should use these hooks.
    1430 
    1431         $where = apply_filters('posts_where_paged', $where);
    1432         $groupby = apply_filters('posts_groupby', $groupby);
    1433         $join = apply_filters('posts_join_paged', $join);
    1434         $orderby = apply_filters('posts_orderby', $q['orderby']);
    1435         $distinct = apply_filters('posts_distinct', $distinct);
    1436         $fields = apply_filters('posts_fields', "$wpdb->posts.*");
    1437         $limits = apply_filters( 'post_limits', $limits );
     1437        if ( !$q['suppress_filters'] ) {
     1438            $where = apply_filters('posts_where_paged', $where);
     1439            $groupby = apply_filters('posts_groupby', $groupby);
     1440            $join = apply_filters('posts_join_paged', $join);
     1441            $orderby = apply_filters('posts_orderby', $q['orderby']);
     1442            $distinct = apply_filters('posts_distinct', $distinct);
     1443            $fields = apply_filters('posts_fields', "$wpdb->posts.*");
     1444            $limits = apply_filters( 'post_limits', $limits );
     1445        }
    14381446
    14391447        // Announce current selection parameters.  For use by caching plugins.
     
    14411449
    14421450        // Filter again for the benefit of caching plugins.  Regular plugins should use the hooks above.
    1443         $where = apply_filters('posts_where_request', $where);
    1444         $groupby = apply_filters('posts_groupby_request', $groupby);
    1445         $join = apply_filters('posts_join_request', $join);
    1446         $orderby = apply_filters('posts_orderby_request', $orderby);
    1447         $distinct = apply_filters('posts_distinct_request', $distinct);
    1448         $fields = apply_filters('posts_fields_request', $fields);
    1449         $limits = apply_filters( 'post_limits_request', $limits );
     1451        if ( !$q['suppress_filters'] ) {
     1452            $where = apply_filters('posts_where_request', $where);
     1453            $groupby = apply_filters('posts_groupby_request', $groupby);
     1454            $join = apply_filters('posts_join_request', $join);
     1455            $orderby = apply_filters('posts_orderby_request', $orderby);
     1456            $distinct = apply_filters('posts_distinct_request', $distinct);
     1457            $fields = apply_filters('posts_fields_request', $fields);
     1458            $limits = apply_filters( 'post_limits_request', $limits );
     1459        }
    14501460
    14511461        if ( ! empty($groupby) )
     
    14581468
    14591469        $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
    1460         $this->request = apply_filters('posts_request', $request);
     1470        if ( !$q['suppress_filters'] )
     1471            $this->request = apply_filters('posts_request', $request);
    14611472
    14621473        $this->posts = $wpdb->get_results($this->request);
    14631474        // Raw results filter.  Prior to status checks.
    1464         $this->posts = apply_filters('posts_results', $this->posts);
     1475        if ( !$q['suppress_filters'] )
     1476            $this->posts = apply_filters('posts_results', $this->posts);
    14651477
    14661478        if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
     
    15441556        }
    15451557
    1546         $this->posts = apply_filters('the_posts', $this->posts);
     1558        if ( !$q['suppress_filters'] )
     1559            $this->posts = apply_filters('the_posts', $this->posts);
    15471560
    15481561        update_post_caches($this->posts);
Note: See TracChangeset for help on using the changeset viewer.