Explicitly set last_changed to 1 instead of the result of wp_cache_set(). Avoids ambiguity and works with cache backends that return void instead of boolean.

see #23167


git-svn-id: http://core.svn.wordpress.org/trunk@23319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2013-01-22 15:46:16 +00:00
parent bd7b6a52b1
commit 48058dfb99
2 changed files with 8 additions and 4 deletions

View File

@ -250,8 +250,10 @@ class WP_Comment_Query {
// $args can be whatever, only use the args defined in defaults to compute the key // $args can be whatever, only use the args defined in defaults to compute the key
$key = md5( serialize( compact(array_keys($defaults)) ) ); $key = md5( serialize( compact(array_keys($defaults)) ) );
$last_changed = wp_cache_get( 'last_changed', 'comment' ); $last_changed = wp_cache_get( 'last_changed', 'comment' );
if ( ! $last_changed ) if ( ! $last_changed ) {
$last_changed = wp_cache_set( 'last_changed', 1, 'comment' ); wp_cache_set( 'last_changed', 1, 'comment' );
$last_changed = 1;
}
$cache_key = "get_comments:$key:$last_changed"; $cache_key = "get_comments:$key:$last_changed";
if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) if ( $cache = wp_cache_get( $cache_key, 'comment' ) )

View File

@ -3652,8 +3652,10 @@ function get_pages($args = '') {
// $args can be whatever, only use the args defined in defaults to compute the key // $args can be whatever, only use the args defined in defaults to compute the key
$key = md5( serialize( compact(array_keys($defaults)) ) ); $key = md5( serialize( compact(array_keys($defaults)) ) );
$last_changed = wp_cache_get( 'last_changed', 'posts' ); $last_changed = wp_cache_get( 'last_changed', 'posts' );
if ( ! $last_changed ) if ( ! $last_changed ) {
$last_changed = wp_cache_set( 'last_changed', 1, 'posts' ); wp_cache_set( 'last_changed', 1, 'posts' );
$last_changed = 1;
}
$cache_key = "get_pages:$key:$last_changed"; $cache_key = "get_pages:$key:$last_changed";
if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) { if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {