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:
Ryan Boren 2008-04-20 21:26:10 +00:00
parent 75c46d544c
commit 06200c33f4
1 changed files with 1 additions and 3 deletions

View File

@ -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' ))";
}
}