Skip to:
Content

bbPress.org

Changeset 5734


Ignore:
Timestamp:
05/12/2015 10:44:46 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Forums: Type-cast improvements to bbp_forum_query_last_reply_id().

Fixes bug where strict false comparison would cache cache condition to never occur.

Props thebrandonallen, netweb. See #2801.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/forums/functions.php

    r5732 r5734  
    20022002
    20032003    $cache_id = 'bbp_get_forum_' . $forum_id . '_reply_id';
    2004     $reply_id = (int) wp_cache_get( $cache_id, 'bbpress_posts' );
     2004    $reply_id = wp_cache_get( $cache_id, 'bbpress_posts' );
    20052005
    20062006    if ( false === $reply_id ) {
     
    20132013            $topic_ids = implode( ',', wp_parse_id_list( $topic_ids ) );
    20142014            $reply_id  = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent IN ( {$topic_ids} ) AND post_status = '%s' AND post_type = '%s' ORDER BY ID DESC LIMIT 1;", bbp_get_public_status_id(), bbp_get_reply_post_type() ) );
    2015             wp_cache_set( $cache_id, $reply_id, 'bbpress_posts' ); // May be (int) 0
    20162015        } else {
    2017             wp_cache_set( $cache_id, '0', 'bbpress_posts' );
    2018         }
    2019     }
    2020 
    2021     return (int) apply_filters( 'bbp_get_forum_last_reply_id', (int) $reply_id, $forum_id );
     2016            $reply_id = 0;
     2017        }
     2018
     2019        wp_cache_set( $cache_id, $reply_id, 'bbpress_posts' );
     2020    } else {
     2021        $reply_id = (int) $reply_id;
     2022    }
     2023
     2024    return (int) apply_filters( 'bbp_get_forum_last_reply_id', $reply_id, $forum_id );
    20222025}
    20232026
Note: See TracChangeset for help on using the changeset viewer.