Don't include perm as part of cache key if perm is not used in the query.

git-svn-id: http://svn.automattic.com/wordpress/trunk@7752 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-04-20 21:26:10 +00:00
parent 5ecd57c4de
commit 5889755c66
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' ))";
}
}