Skip to:
Content

bbPress.org

Changeset 6583


Ignore:
Timestamp:
06/19/2017 04:29:43 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Better 404 handling:

  • Introduce bbp_is_404 query var, and set this in places where the default 404 condition needs to be overridden
  • Introduce bbp_set_200() for cases where a default of 404 needs to be set to a 200
  • Introduce bbp_get_wp_query() helper for getting the $wp_query global
  • Update bbp_set_404() to accept a $query parameter to make passing the query around easier
  • Update child-ids queries to use the last_changed cache to reduce the amount of cache churn when cleaning

Fixes #3047. See #1973.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/ajax.php

    r6581 r6583  
    7676
    7777        // Everything is 200 OK.
    78         status_header( 200 );
     78        bbp_set_200();
    7979
    8080        // Perform custom bbPress ajax
  • trunk/src/includes/common/functions.php

    r6573 r6583  
    9393 */
    9494function bbp_get_paged() {
    95         global $wp_query;
     95        $wp_query = bbp_get_wp_query();
    9696
    9797        // Check the query var
    … …  
    15671567
    15681568        $query = new WP_Query( array(
    1569                 'fields'      => 'ids',
    1570                 'post_parent' => $parent_id,
    1571                 'post_status' => $post_status,
    1572                 'post_type'   => $post_type,
     1569                'fields'           => 'ids',
     1570                'suppress_filters' => true,
     1571                'post_parent'      => $parent_id,
     1572                'post_status'      => $post_status,
     1573                'post_type'        => $post_type,
     1574                'posts_per_page'   => -1,
    15731575
    15741576                // Maybe change these later
    1575                 'posts_per_page'         => -1,
    15761577                'update_post_term_cache' => false,
    15771578                'update_post_meta_cache' => false,
    15781579                'ignore_sticky_posts'    => true,
    1579                 'no_found_rows'          => true
     1580                'no_found_rows'          => true,
     1581                'nopaging'               => true
    15801582        ) );
    15811583        $child_ids = ! empty( $query->posts ) ? $query->posts : array();
    … …  
    16031605        }
    16041606
    1605         // The ID of the cached query
    1606         $cache_id  = 'bbp_parent_all_' . $parent_id . '_type_' . $post_type . '_child_ids';
     1607        // Check cache key
     1608        $key          = md5( serialize( array( 'parent_id' => $parent_id, 'post_type' => $post_type ) ) );
     1609        $last_changed = wp_cache_get_last_changed( 'bbpress_posts' );
     1610        $cache_key    = "bbp_child_ids:{$key}:{$last_changed}";
    16071611
    16081612        // Check for cache and set if needed
    1609         $child_ids = wp_cache_get( $cache_id, 'bbpress_posts' );
     1613        $child_ids = wp_cache_get( $cache_key, 'bbpress_posts' );
    16101614        if ( false === $child_ids ) {
    16111615                $post_status = array( bbp_get_public_status_id() );
    … …  
    16451649
    16461650                // Always cache the results
    1647                 wp_cache_set( $cache_id, $child_ids, 'bbpress_posts' );
     1651                wp_cache_set( $cache_key, $child_ids, 'bbpress_posts' );
    16481652        }
    16491653
    … …  
    20162020 *
    20172021 * @since 2.0.0 bbPress (r3051)
    2018  *
    2019  * @global WP_Query $wp_query
    2020  */
    2021 function bbp_set_404() {
    2022         global $wp_query;
    2023 
    2024         if ( ! isset( $wp_query ) ) {
    2025                 _doing_it_wrong( __FUNCTION__, esc_html__( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '3.1' );
    2026                 return false;
    2027         }
    2028 
    2029         $wp_query->set_404();
    2030 }
    2031 
    2032 /**
    2033  * Maybe avoid default 404 handling for some bbPress pages
     2022 * @since 2.6.0 bbPress (r6583) Use status_header() & nocache_headers()
     2023 *
     2024 * @param WP_Query $query  The query being checked
     2025 *
     2026 * @return bool Always returns true
     2027 */
     2028function bbp_set_404( $query = null ) {
     2029
     2030        // Global fallback
     2031        if ( empty( $query ) ) {
     2032                $query = bbp_get_wp_query();
     2033        }
     2034
     2035        // Setup environment
     2036        $query->set_404();
     2037
     2038        // Setup request
     2039        status_header( 404 );
     2040        nocache_headers();
     2041}
     2042
     2043/**
     2044 * Sets the 200 status header.
     2045 *
     2046 * @since 2.6.0 bbPress (r6583)
     2047 */
     2048function bbp_set_200() {
     2049        status_header( 200 );
     2050}
     2051
     2052/**
     2053 * Maybe handle the default 404 handling for some bbPress conditions
     2054 *
     2055 * Some conditions (like private/hidden forums and edits) have their own checks
     2056 * on `bbp_template_redirect` and are not currently 404s.
    20342057 *
    20352058 * @since 2.6.0 bbPress (r6555)
     2059 *
     2060 * @param bool $override Whether to override the default handler
     2061 * @param WP_Query $wp_query The posts query being referenced
     2062 *
     2063 * @return bool False to leave alone, true to override
    20362064 */
    20372065function bbp_pre_handle_404( $override = false, $wp_query = false ) {
     2066
     2067        // Handle a bbPress 404 condition
     2068        if ( isset( $wp_query->bbp_is_404 ) ) {
     2069
     2070                // Either force a 404 when 200, or a 200 when 404
     2071                $override = ( true === $wp_query->bbp_is_404 )
     2072                        ? bbp_set_404( $wp_query )
     2073                        : bbp_set_200();
     2074        }
     2075
    20382076        return $override;
    20392077}
     2078
     2079/**
     2080 * Maybe pre-assign the posts that are returned from a WP_Query.
     2081 *
     2082 * This effectively short-circuits the default query for posts, which is
     2083 * currently only used to avoid calling the main query when it's not necessary.
     2084 *
     2085 * @since 2.6.0 bbPress (r6580)
     2086 *
     2087 * @param mixed $posts Default null. Array of posts (possibly empty)
     2088 * @param WP_Query $wp_query
     2089 *
     2090 * @return mixed Null if no override. Array if overridden.
     2091 */
     2092function bbp_posts_pre_query( $posts = null, $wp_query = false ) {
     2093
     2094        // Custom 404 handler is set, so set posts to empty array to avoid 2 queries
     2095        if ( isset( $wp_query->bbp_is_404 ) ) {
     2096                $posts = array();
     2097        }
     2098
     2099        // Return, maybe overridden
     2100        return $posts;
     2101}
  • trunk/src/includes/core/abstraction.php

    r6573 r6583  
    4949        // Filter & return
    5050        return apply_filters( 'bbp_get_global_object', $retval, $name, $type, $default );
     51}
     52
     53/**
     54 * Get the `$wp_query` global without needing to declare it everywhere
     55 *
     56 * @since 2.6.0 bbPress (r6582)
     57 *
     58 * @return WP_Roles
     59 */
     60function bbp_get_wp_query() {
     61        return bbp_get_global_object( 'wp_query', 'WP_Query' );
    5162}
    5263
  • trunk/src/includes/core/cache.php

    r6573 r6583  
    167167        clean_object_term_cache( $post->ID, $post->post_type );
    168168
    169         // Loop through query types and clean caches
    170         foreach ( $post_types as $post_type ) {
    171                 $key = 'bbp_parent_all_' . $post->ID . '_type_' . $post_type . '_child_ids';
    172                 wp_cache_delete( $key, 'bbpress_posts' );
    173         }
     169        // Bump the last_changed cache
     170        wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' );
    174171
    175172        /**
  • trunk/src/includes/core/filters.php

    r6554 r6583  
    6161add_filter( 'the_title', 'bbp_get_reply_title_fallback', 2, 2 );
    6262
    63 // Avoid 404ing
    64 add_filter( 'pre_handle_404', 'bbp_pre_handle_404', 10, 2 );
     63// Avoid queries & 404s
     64add_filter( 'pre_handle_404',  'bbp_pre_handle_404',  10, 2 );
     65add_action( 'posts_pre_query', 'bbp_posts_pre_query', 10, 2 );
    6566
    6667/**
  • trunk/src/includes/core/template-functions.php

    r6573 r6583  
    532532                // 404 and bail if user does not have a profile
    533533                if ( empty( $the_user->ID ) || ! bbp_user_has_profile( $the_user->ID ) ) {
    534                         $posts_query->set_404();
     534                        $posts_query->bbp_is_404 = true;
    535535                        return;
    536536                }
    … …  
    593593                }
    594594
     595                // Make sure 404 is not set
     596                $posts_query->is_404  = false;
     597
     598                // Correct is_home variable
     599                $posts_query->is_home = false;
     600
    595601                // Looking at a single user
    596602                $posts_query->bbp_is_single_user = true;
    597603
    598                 // Make sure 404 is not set
    599                 $posts_query->is_404  = false;
    600 
    601                 // Correct is_home variable
    602                 $posts_query->is_home = false;
     604                // User found so don't 404 yet
     605                $posts_query->bbp_is_404 = false;
    603606
    604607                // User is looking at their own profile
    … …  
    621624                // Bail if view args is false (view isn't registered)
    622625                if ( false === $view_args ) {
    623                         $posts_query->set_404();
     626                        $posts_query->bbp_is_404 = true;
    624627                        return;
    625628                }
    … …  
    630633                // We are in a custom topic view
    631634                $posts_query->bbp_is_view = true;
     635
     636                // No 404 because views are all (currently) public
     637                $posts_query->bbp_is_404 = false;
    632638
    633639        // Search Page
    … …  
    646652                $posts_query->bbp_is_search = true;
    647653
     654                // No 404 because search is always public
     655                $posts_query->bbp_is_404 = false;
     656
    648657        // Forum/Topic/Reply Edit Page
    649658        } elseif ( ! empty( $is_edit ) ) {
    … …  
    654663                // Check which post_type we are editing, if any
    655664                if ( ! empty( $post_type ) ) {
    656                         switch( $post_type ) {
     665                        switch ( $post_type ) {
    657666
    658667                                // We are editing a forum
    659668                                case bbp_get_forum_post_type() :
    660                                         $posts_query->bbp_is_forum_edit = true;
    661                                         $posts_query->bbp_is_edit       = true;
     669                                        $posts_query->bbp_is_forum_edit  = true;
     670                                        $posts_query->bbp_is_edit        = true;
     671                                        $posts_query->bbp_is_404         = false;
    662672                                        break;
    663673
    664674                                // We are editing a topic
    665675                                case bbp_get_topic_post_type() :
    666                                         $posts_query->bbp_is_topic_edit = true;
    667                                         $posts_query->bbp_is_edit       = true;
     676                                        $posts_query->bbp_is_topic_edit  = true;
     677                                        $posts_query->bbp_is_edit        = true;
     678                                        $posts_query->bbp_is_404         = false;
    668679                                        break;
    669680
    670681                                // We are editing a reply
    671682                                case bbp_get_reply_post_type() :
    672                                         $posts_query->bbp_is_reply_edit = true;
    673                                         $posts_query->bbp_is_edit       = true;
     683                                        $posts_query->bbp_is_reply_edit  = true;
     684                                        $posts_query->bbp_is_edit        = true;
     685                                        $posts_query->bbp_is_404         = false;
    674686                                        break;
    675687                        }
    … …  
    679691                        $posts_query->bbp_is_topic_tag_edit = true;
    680692                        $posts_query->bbp_is_edit           = true;
     693                        $posts_query->bbp_is_404            = false;
    681694                }
    682695
  • trunk/src/includes/core/theme-compat.php

    r6573 r6583  
    395395                        'is_single'             => false,
    396396                        'is_archive'            => false,
    397                         'is_tax'                => false,
     397                        'is_tax'                => false
    398398                ), 'theme_compat_reset_post' );
    399399        } else {
    … …  
    428428                        'is_single'             => false,
    429429                        'is_archive'            => false,
    430                         'is_tax'                => false,
     430                        'is_tax'                => false
    431431                ), 'theme_compat_reset_post' );
    432432        }
    … …  
    458458        // Clean up the dummy post
    459459        unset( $dummy );
    460 
    461         /**
    462          * Force the header back to 200 status if not a deliberate 404
    463          *
    464          * @see https://bbpress.trac.wordpress.org/ticket/1973
    465          */
    466         if ( ! $wp_query->is_404() ) {
    467                 status_header( 200 );
    468         }
    469460
    470461        // If we are resetting a post, we are in theme compat
  • trunk/src/includes/extend/buddypress/groups.php

    r6573 r6583  
    816816         */
    817817        public function display_forums( $offset = 0 ) {
    818                 global $wp_query;
    819818
    820819                // Allow actions immediately before group forum output
    … …  
    928927                                                add_filter( 'bbp_get_topic_types', array( $this, 'unset_super_sticky' ), 10, 1 );
    929928
     929                                                // Get the main query object
     930                                                $wp_query = bbp_get_wp_query();
     931
    930932                                                // Set the edit switches
    931933                                                $wp_query->bbp_is_edit       = true;
    … …  
    994996
    995997                                        if ( bp_action_variable( $offset + 2 ) === bbp_get_edit_rewrite_id() ) :
     998
     999                                                // Get the main query object
     1000                                                $wp_query = bbp_get_wp_query();
    9961001
    9971002                                                // Set the edit switches
  • trunk/src/includes/extend/buddypress/members.php

    r6573 r6583  
    209209                }
    210210
    211                 global $wp_query;
     211                // Get the main query object
     212                $wp_query = bbp_get_wp_query();
    212213
    213214                // 'favorites' action
  • trunk/src/includes/forums/functions.php

    r6573 r6583  
    963963        // Query for private forums
    964964        $private_forums = new WP_Query( array(
     965                'fields'           => 'ids',
    965966                'suppress_filters' => true,
    966                 'nopaging'         => true,
    967                 'no_found_rows'    => true,
    968967                'post_type'        => bbp_get_forum_post_type(),
    969968                'post_status'      => bbp_get_private_status_id(),
    970                 'fields'           => 'ids'
     969                'posts_per_page'   => -1,
     970
     971                // Performance
     972                'ignore_sticky_posts'    => true,
     973                'no_found_rows'          => true,
     974                'nopaging'               => true,
     975                'update_post_term_cache' => false,
     976                'update_post_meta_cache' => false
    971977        ) );
    972978
    973979        // Query for hidden forums
    974980        $hidden_forums = new WP_Query( array(
     981                'fields'           => 'ids',
    975982                'suppress_filters' => true,
    976                 'nopaging'         => true,
    977                 'no_found_rows'    => true,
    978983                'post_type'        => bbp_get_forum_post_type(),
    979984                'post_status'      => bbp_get_hidden_status_id(),
    980                 'fields'           => 'ids'
     985                'posts_per_page'   => -1,
     986
     987                // Performance
     988                'ignore_sticky_posts'    => true,
     989                'no_found_rows'          => true,
     990                'nopaging'               => true,
     991                'update_post_term_cache' => false,
     992                'update_post_meta_cache' => false
    981993        ) );
    982994
    … …  
    16501662                if ( empty( $topic_count ) ) {
    16511663                        $query = new WP_Query( array(
    1652                                 'fields'      => 'ids',
    1653                                 'post_parent' => $forum_id,
    1654                                 'post_status' => array( bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id() ),
    1655                                 'post_type'   => bbp_get_topic_post_type(),
    1656 
    1657                                 // Maybe change these later
    1658                                 'posts_per_page'         => -1,
     1664                                'fields'           => 'ids',
     1665                                'suppress_filters' => true,
     1666                                'post_parent'      => $forum_id,
     1667                                'post_status'      => array( bbp_get_trash_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id() ),
     1668                                'post_type'        => bbp_get_topic_post_type(),
     1669                                'posts_per_page'   => -1,
     1670
     1671                                // Performance
    16591672                                'update_post_term_cache' => false,
    16601673                                'update_post_meta_cache' => false,
    16611674                                'ignore_sticky_posts'    => true,
    1662                                 'no_found_rows'          => true
     1675                                'no_found_rows'          => true,
     1676                                'nopaging'               => true
    16631677                        ) );
    16641678                        $topic_count = $query->post_count;
    … …  
    17061720        if ( ! empty( $topic_ids ) ) {
    17071721                $query = new WP_Query( array(
    1708                         'fields'          => 'ids',
    1709                         'post_parent__in' => $topic_ids,
    1710                         'post_status'     => bbp_get_public_status_id(),
    1711                         'post_type'       => bbp_get_reply_post_type(),
    1712 
    1713                         // Maybe change these later
    1714                         'posts_per_page'         => -1,
     1722                        'fields'           => 'ids',
     1723                        'suppress_filters' => true,
     1724                        'post_parent__in'  => $topic_ids,
     1725                        'post_status'      => bbp_get_public_status_id(),
     1726                        'post_type'        => bbp_get_reply_post_type(),
     1727                        'posts_per_page'   => -1,
     1728
     1729                        // Performance
    17151730                        'update_post_term_cache' => false,
    17161731                        'update_post_meta_cache' => false,
    17171732                        'ignore_sticky_posts'    => true,
    1718                         'no_found_rows'          => true
     1733                        'no_found_rows'          => true,
     1734                        'nopaging'               => true
    17191735                ) );
    17201736                $reply_count = ! empty( $query->posts ) ? count( $query->posts ) : 0;
    … …  
    21062122
    21072123        $query = new WP_Query( array(
    2108                 'fields'          => 'ids',
    2109                 'post_parent__in' => $topic_ids,
    2110                 'post_status'     => bbp_get_public_status_id(),
    2111                 'post_type'       => bbp_get_reply_post_type(),
    2112                 'orderby'         => array(
     2124                'fields'           => 'ids',
     2125                'suppress_filters' => true,
     2126                'post_parent__in'  => $topic_ids,
     2127                'post_status'      => bbp_get_public_status_id(),
     2128                'post_type'        => bbp_get_reply_post_type(),
     2129                'posts_per_page'   => 1,
     2130                'orderby'          => array(
    21132131                        'post_date' => 'DESC',
    21142132                        'ID'        => 'DESC'
    21152133                ),
    21162134
    2117                 // Maybe change these later
    2118                 'posts_per_page'         => 1,
     2135                // Performance
    21192136                'update_post_term_cache' => false,
    21202137                'update_post_meta_cache' => false,
    21212138                'ignore_sticky_posts'    => true,
    2122                 'no_found_rows'          => true
     2139                'no_found_rows'          => true,
     2140                'nopaging'               => true
    21232141        ) );
    21242142        $reply_id = array_shift( $query->posts );
    … …  
    21442162        }
    21452163
    2146         global $wp_query;
    2147 
    2148         // Define local variable
     2164        // Define local variables
    21492165        $forum_id = 0;
     2166        $wp_query = bbp_get_wp_query();
    21502167
    21512168        // Check post type
    … …  
    21702187        // If forum is explicitly hidden and user not capable, set 404
    21712188        if ( ! empty( $forum_id ) && bbp_is_forum_hidden( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) {
    2172                 bbp_set_404();
     2189                bbp_set_404( $wp_query );
    21732190        }
    21742191}
    … …  
    21872204        }
    21882205
    2189         global $wp_query;
    2190 
    2191         // Define local variable
     2206        // Define local variables
    21922207        $forum_id = 0;
     2208        $wp_query = bbp_get_wp_query();
    21932209
    21942210        // Check post type
    … …  
    22142230        // If forum is explicitly hidden and user not capable, set 404
    22152231        if ( ! empty( $forum_id ) && bbp_is_forum_private( $forum_id ) && ! current_user_can( 'read_forum', $forum_id ) ) {
    2216                 bbp_set_404();
     2232                bbp_set_404( $wp_query );
    22172233        }
    22182234}
    … …  
    22572273        // Note that we get all post statuses here
    22582274        $topics = new WP_Query( array(
     2275                'fields'           => 'id=>parent',
    22592276                'suppress_filters' => true,
     2277
     2278                // What and how
    22602279                'post_type'        => bbp_get_topic_post_type(),
    22612280                'post_parent'      => $forum_id,
    22622281                'post_status'      => array_keys( get_post_stati() ),
    22632282                'posts_per_page'   => -1,
    2264                 'nopaging'         => true,
    2265                 'no_found_rows'    => true,
    2266                 'fields'           => 'id=>parent'
     2283
     2284                // Performance
     2285                'ignore_sticky_posts'    => true,
     2286                'no_found_rows'          => true,
     2287                'nopaging'               => true,
     2288                'update_post_term_cache' => false,
     2289                'update_post_meta_cache' => false
    22672290        ) );
    22682291
    … …  
    23052328        );
    23062329
    2307         // Forum is being trashed, so its topics and replies are trashed too
     2330        // Forum is being trashed, so its topics (and replies) are trashed too
    23082331        $topics = new WP_Query( array(
     2332                'fields'           => 'id=>parent',
    23092333                'suppress_filters' => true,
    23102334                'post_type'        => bbp_get_topic_post_type(),
    … …  
    23122336                'post_status'      => $post_stati,
    23132337                'posts_per_page'   => -1,
    2314                 'nopaging'         => true,
    2315                 'no_found_rows'    => true,
    2316                 'fields'           => 'id=>parent'
     2338
     2339                // Performance
     2340                'ignore_sticky_posts'    => true,
     2341                'no_found_rows'          => true,
     2342                'nopaging'               => true,
     2343                'update_post_term_cache' => false,
     2344                'update_post_meta_cache' => false
    23172345        ) );
    23182346
  • trunk/src/includes/forums/template.php

    r6582 r6583  
    202202        function bbp_get_forum_id( $forum_id = 0 ) {
    203203                $bbp      = bbpress();
    204                 $wp_query = bbp_get_global_object( 'wp_query', 'WP_Query' );
     204                $wp_query = bbp_get_wp_query();
    205205
    206206                // Easy empty checking
  • trunk/src/includes/replies/template.php

    r6582 r6583  
    328328        function bbp_get_reply_id( $reply_id = 0 ) {
    329329                $bbp      = bbpress();
    330                 $wp_query = bbp_get_global_object( 'wp_query', 'WP_Query' );
     330                $wp_query = bbp_get_wp_query();
    331331
    332332                // Easy empty checking
  • trunk/src/includes/topics/template.php

    r6582 r6583  
    442442        function bbp_get_topic_id( $topic_id = 0 ) {
    443443                $bbp      = bbpress();
    444                 $wp_query = bbp_get_global_object( 'wp_query', 'WP_Query' );
     444                $wp_query = bbp_get_wp_query();
    445445
    446446                // Easy empty checking
  • trunk/tests/phpunit/testcases/core/cache.php

    r6053 r6583  
    88
    99        /**
     10         * @group jjj
    1011         * @covers ::bbp_clean_post_cache
    1112         */
    … …  
    1415                // Get the topic post type.
    1516                $tpt = bbp_get_topic_post_type();
     17                $rpt = bbp_get_topic_post_type();
    1618
    1719                // Set up a forum with 1 topic and 1 reply to that topic.
    … …  
    3335                // Make sure we've cached some data.
    3436                bbp_get_all_child_ids( $f, $tpt );
    35                 bbp_get_all_child_ids( $t, $tpt );
     37                bbp_get_all_child_ids( $t, $rpt );
    3638
    37                 $this->assertEquals( array( $t ), wp_cache_get( "bbp_parent_all_{$f}_type_{$tpt}_child_ids", 'bbpress_posts' ) );
    38                 $this->assertEquals( array( $r ), wp_cache_get( "bbp_parent_all_{$t}_type_{$tpt}_child_ids", 'bbpress_posts' ) );
     39                // Setup
     40                $f_key        = md5( serialize( array( 'parent_id' => $f, 'post_type' => $tpt ) ) );
     41                $t_key        = md5( serialize( array( 'parent_id' => $t, 'post_type' => $rpt ) ) );
     42                $last_changed = wp_cache_get_last_changed( 'bbpress_posts' );
     43               
     44                // Keys
     45                $f_key = "bbp_child_ids:{$f_key}:{$last_changed}";
     46                $t_key = "bbp_child_ids:{$t_key}:{$last_changed}";
     47
     48                $this->assertEquals( array( $t ), wp_cache_get( $f_key, 'bbpress_posts' ) );
     49                $this->assertEquals( array( $r ), wp_cache_get( $t_key, 'bbpress_posts' ) );
    3950
    4051                // Clean the cache.
    4152                bbp_clean_post_cache( $r );
    4253
    43                 $this->assertEquals( false, wp_cache_get( "bbp_parent_all_{$f}_type_{$tpt}_child_ids", 'bbpress_posts' ) );
    44                 $this->assertEquals( false, wp_cache_get( "bbp_parent_all_{$t}_type_{$tpt}_child_ids", 'bbpress_posts' ) );
     54                // Setup
     55                $last_changed = wp_cache_get_last_changed( 'bbpress_posts' );
     56               
     57                // Keys
     58                $f_key = "bbp_child_ids:{$f_key}:{$last_changed}";
     59                $t_key = "bbp_child_ids:{$t_key}:{$last_changed}";
     60
     61                $this->assertEquals( false, wp_cache_get( $f_key, 'bbpress_posts' ) );
     62                $this->assertEquals( false, wp_cache_get( $t_key, 'bbpress_posts' ) );
    4563        }
    4664}
Note: See TracChangeset for help on using the changeset viewer.