WordPress.org

Make WordPress Core

Ticket #13773: get_blog_list.patch

File get_blog_list.patch, 1.4 KB (added by ocean90, 8 years ago)
  • wp-includes/ms-blogs.php

     
    542542function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
    543543        global $wpdb;
    544544
    545         $blogs = get_site_option( "blog_list" );
     545        $blogs = get_site_transient( 'blog_list' );
    546546        $update = false;
    547         if ( is_array( $blogs ) ) {
    548                 if ( ( $blogs['time'] + 60 ) < time() ) { // cache for 60 seconds.
    549                         $update = true;
    550                 }
    551         } else {
     547        if ( empty( $blogs ) || ! is_array( $blogs ) )
    552548                $update = true;
    553         }
    554549
    555550        if ( $update == true ) {
    556551                unset( $blogs );
     
    558553
    559554                foreach ( (array) $blogs as $details ) {
    560555                        $blog_list[ $details['blog_id'] ] = $details;
    561                         $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->base_prefix . $details['blog_id'] . "_posts WHERE post_status='publish' AND post_type='post'" );
     556                        $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ) . "posts WHERE post_status='publish' AND post_type='post'" );
    562557                }
    563558                unset( $blogs );
    564559                $blogs = $blog_list;
    565                 update_site_option( "blog_list", $blogs );
     560                set_site_transient( 'blog_list', $blogs, 60 ); // cache for 60 seconds.
    566561        }
    567562
    568563        if ( false == is_array( $blogs ) )