Don't include perm as part of cache key if perm is not used in the query.
git-svn-id: https://develop.svn.wordpress.org/trunk@7752 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
75c46d544c
commit
06200c33f4
@ -827,13 +827,11 @@ function wp_count_posts( $type = 'post', $perm = '' ) {
|
||||
$user = wp_get_current_user();
|
||||
|
||||
$cache_key = $type;
|
||||
if ( !empty($perm) )
|
||||
$cache_key .= '_' . $perm;
|
||||
|
||||
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
|
||||
if ( 'readable' == $perm && is_user_logged_in() ) {
|
||||
if ( !current_user_can("read_private_{$type}s") ) {
|
||||
$cache_key .= '_' . $user->ID;
|
||||
$cache_key .= '_' . $perm . '_' . $user->ID;
|
||||
$query .= " AND (post_status != 'private' OR ( post_author = '$user->ID' AND post_status = 'private' ))";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user