Make WordPress Core


Ignore:
Timestamp:
04/16/2008 11:45:39 PM (18 years ago)
Author:
ryan
Message:

Cache comment count and use count API in menu.php

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r7690 r7714  
    452452    global $wpdb;
    453453
     454    $count = wp_cache_get('comments', 'counts');
     455
     456    if ( false !== $count )
     457        return $count;
     458
    454459    $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} GROUP BY comment_approved", ARRAY_A );
    455460
     
    465470    }
    466471
    467     return (object) $stats;
     472    $stats = (object) $stats;
     473    wp_cache_set('comments', $stats, 'counts');
     474
     475    return $stats;
    468476}
    469477
Note: See TracChangeset for help on using the changeset viewer.