Making WordPress.org

Changeset 3919


Ignore:
Timestamp:
09/01/2016 08:47:41 PM (8 years ago)
Author:
jmdodd
Message:

Support Forums: Improve feed performance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-performance-optimizations.php

    r3916 r3919  
    1616        // Query simplification.
    1717        add_filter( 'bbp_after_has_topics_parse_args', array( $this, 'has_topics' ) );
     18        add_filter( 'bbp_after_has_replies_parse_args', array( $this, 'has_replies' ) );
    1819        add_filter( 'bbp_register_view_no_replies', array( $this, 'no_replies' ) );
    1920    }
     
    3334     */
    3435    public function has_topics( $r ) {
     36        /**
     37         * Feeds
     38         */
     39        if ( is_feed() ) {
     40            $r['no_found_rows'] = true;
     41            add_filter( 'posts_where', array( $this, 'posts_in_last_month' ) );
     42        }
     43
    3544        /**
    3645         * Filter queries so they are not sorted by the post meta value of
     
    7079    }
    7180
     81    public function has_replies( $r ) {
     82        if ( is_feed() ) {
     83            $r['no_found_rows'] = true;
     84            add_filter( 'posts_where', array( $this, 'posts_in_last_month' ) );
     85        }
     86        return $r;
     87    }
     88
    7289    public function no_replies( $r ) {
    7390        $r['post_parent__not_in'] = array( Plugin::THEMES_FORUM_ID, Plugin::PLUGINS_FORUM_ID, Plugin::REVIEWS_FORUM_ID );
    7491        return $r;
     92    }
     93
     94    public function posts_in_last_month( $w ) {
     95        global $wpdb;
     96
     97        $bound_id = $this->get_bound_id( '1 MONTH' );
     98        $w .= $wpdb->prepare( " AND ( $wpdb->posts.ID >= %d )", $bound_id );
     99        return $w;
    75100    }
    76101
Note: See TracChangeset for help on using the changeset viewer.