get_blog_details

The timeline below displays how wordpress function get_blog_details has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Retrieves the details for a blog from the blogs table and blog options.
 *
 * @since MU (3.0.0)
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  Defaults to the current blog ID.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (str_starts_with($fields['domain'], 'www.')) {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (str_starts_with($fields['domain'], 'www.')) {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = $get_all ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if (-1 == $details) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if (-1 == $details) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    $switched_blog = false;
    if (get_current_blog_id() !== $blog_id) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters a blog's details.
     *
     * @since MU (3.0.0)
     * @deprecated 4.7.0 Use {@see 'site_details'} instead.
     *
     * @param WP_Site $details The blog details.
     */
    $details = apply_filters_deprecated('blog_details', array($details), '4.7.0', 'site_details');
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 6.2

/**
 * Retrieves the details for a blog from the blogs table and blog options.
 *
 * @since MU (3.0.0)
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  Defaults to the current blog ID.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if ('www.' === substr($fields['domain'], 0, 4)) {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if ('www.' === substr($fields['domain'], 0, 4)) {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = $get_all ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if (-1 == $details) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if (-1 == $details) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    $switched_blog = false;
    if (get_current_blog_id() !== $blog_id) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters a blog's details.
     *
     * @since MU (3.0.0)
     * @deprecated 4.7.0 Use {@see 'site_details'} instead.
     *
     * @param WP_Site $details The blog details.
     */
    $details = apply_filters_deprecated('blog_details', array($details), '4.7.0', 'site_details');
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 5.6

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU (3.0.0)
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if ('www.' === substr($fields['domain'], 0, 4)) {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if ('www.' === substr($fields['domain'], 0, 4)) {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = $get_all ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if (-1 == $details) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if (-1 == $details) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    $switched_blog = false;
    if (get_current_blog_id() !== $blog_id) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters a blog's details.
     *
     * @since MU (3.0.0)
     * @deprecated 4.7.0 Use {@see 'site_details'} instead.
     *
     * @param WP_Site $details The blog details.
     */
    $details = apply_filters_deprecated('blog_details', array($details), '4.7.0', 'site_details');
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 5.5

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU (3.0.0)
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if ('www.' === substr($fields['domain'], 0, 4)) {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if ('www.' === substr($fields['domain'], 0, 4)) {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = $get_all ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if (-1 == $details) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if (-1 == $details) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    $switched_blog = false;
    if (get_current_blog_id() !== $blog_id) {
        switch_to_blog($blog_id);
        $switched_blog = true;
    }
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    if ($switched_blog) {
        restore_current_blog();
    }
    /**
     * Filters a blog's details.
     *
     * @since MU (3.0.0)
     * @deprecated 4.7.0 Use {@see 'site_details'} instead.
     *
     * @param object $details The blog details.
     */
    $details = apply_filters_deprecated('blog_details', array($details), '4.7.0', 'site_details');
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 5.4

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU (3.0.0)
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = $get_all ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if (-1 == $details) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if (-1 == $details) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    restore_current_blog();
    /**
     * Filters a blog's details.
     *
     * @since MU (3.0.0)
     * @deprecated 4.7.0 Use {@see 'site_details'} instead.
     *
     * @param object $details The blog details.
     */
    $details = apply_filters_deprecated('blog_details', array($details), '4.7.0', 'site_details');
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 5.1

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU (3.0.0)
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = $get_all ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if (-1 == $details) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if (-1 == $details) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    restore_current_blog();
    /**
     * Filters a blog's details.
     *
     * @since MU (3.0.0)
     * @deprecated 4.7.0 Use site_details
     *
     * @param object $details The blog details.
     */
    $details = apply_filters_deprecated('blog_details', array($details), '4.7.0', 'site_details');
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 4.9

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU (3.0.0)
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = ($get_all == true) ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if ($details == -1) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if ($details == -1) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    restore_current_blog();
    /**
     * Filters a blog's details.
     *
     * @since MU (3.0.0)
     * @deprecated 4.7.0 Use site_details
     *
     * @param object $details The blog details.
     */
    $details = apply_filters_deprecated('blog_details', array($details), '4.7.0', 'site_details');
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 4.7

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = ($get_all == true) ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if ($details == -1) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if ($details == -1) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    restore_current_blog();
    /**
     * Filters a blog's details.
     *
     * @since MU
     * @deprecated 4.7.0 Use site_details
     *
     * @param object $details The blog details.
     */
    $details = apply_filters_deprecated('blog_details', array($details), '4.7.0', 'site_details');
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 4.6

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = ($get_all == true) ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if ($details == -1) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if ($details == -1) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    restore_current_blog();
    /**
     * Filters a blog's details.
     *
     * @since MU
     *
     * @param object $details The blog details.
     */
    $details = apply_filters('blog_details', $details);
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 4.5

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return WP_Site|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = ($get_all == true) ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if ($details == -1) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if ($details == -1) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = WP_Site::get_instance($blog_id);
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$details instanceof WP_Site) {
        $details = new WP_Site($details);
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    restore_current_blog();
    /**
     * Filter a blog's details.
     *
     * @since MU
     *
     * @param object $details The blog details.
     */
    $details = apply_filters('blog_details', $details);
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 4.4

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return object|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = ($get_all == true) ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if ($details == -1) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if ($details == -1) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d /* get_blog_details */", $blog_id));
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    $details->home = get_option('home');
    restore_current_blog();
    /**
     * Filter a blog's details.
     *
     * @since MU
     *
     * @param object $details The blog details.
     */
    $details = apply_filters('blog_details', $details);
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 4.3

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU
 *
 * @global wpdb $wpdb
 *
 * @param int|string|array $fields  Optional. A blog ID, a blog slug, or an array of fields to query against.
 *                                  If not specified the current blog ID is used.
 * @param bool             $get_all Whether to retrieve all details or only the details in the blogs table.
 *                                  Default is true.
 * @return object|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = ($get_all == true) ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if ($details == -1) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if ($details == -1) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d /* get_blog_details */", $blog_id));
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    restore_current_blog();
    /**
     * Filter a blog's details.
     *
     * @since MU
     *
     * @param object $details The blog details.
     */
    $details = apply_filters('blog_details', $details);
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 4.2

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU
 *
 * @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against. Optional. If not specified the current blog ID is used.
 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
 * @return object|false Blog details on success. False on failure.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = ($get_all == true) ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if ($details == -1) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if ($details == -1) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d /* get_blog_details */", $blog_id));
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    restore_current_blog();
    /**
     * Filter a blog's details.
     *
     * @since MU
     *
     * @param object $details The blog details.
     */
    $details = apply_filters('blog_details', $details);
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 3.8

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU
 *
 * @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against. Optional. If not specified the current blog ID is used.
 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
 * @return object Blog details.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = ($get_all == true) ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if ($details == -1) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if ($details == -1) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d /* get_blog_details */", $blog_id));
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    restore_current_blog();
    /**
     * Filter a blog's details.
     *
     * @since MU
     *
     * @param object $details The blog details.
     */
    $details = apply_filters('blog_details', $details);
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}

WordPress Version: 3.7

/**
 * Retrieve the details for a blog from the blogs table and blog options.
 *
 * @since MU
 *
 * @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against. Optional. If not specified the current blog ID is used.
 * @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
 * @return object Blog details.
 */
function get_blog_details($fields = null, $get_all = true)
{
    global $wpdb;
    if (is_array($fields)) {
        if (isset($fields['blog_id'])) {
            $blog_id = $fields['blog_id'];
        } elseif (isset($fields['domain']) && isset($fields['path'])) {
            $key = md5($fields['domain'] . $fields['path']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) AND path = %s ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain'], $fields['path']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $fields['domain'], $fields['path']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } elseif (isset($fields['domain']) && is_subdomain_install()) {
            $key = md5($fields['domain']);
            $blog = wp_cache_get($key, 'blog-lookup');
            if (false !== $blog) {
                return $blog;
            }
            if (substr($fields['domain'], 0, 4) == 'www.') {
                $nowww = substr($fields['domain'], 4);
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain IN (%s,%s) ORDER BY CHAR_LENGTH(domain) DESC", $nowww, $fields['domain']));
            } else {
                $blog = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE domain = %s", $fields['domain']));
            }
            if ($blog) {
                wp_cache_set($blog->blog_id . 'short', $blog, 'blog-details');
                $blog_id = $blog->blog_id;
            } else {
                return false;
            }
        } else {
            return false;
        }
    } else if (!$fields) {
        $blog_id = get_current_blog_id();
    } elseif (!is_numeric($fields)) {
        $blog_id = get_id_from_blogname($fields);
    } else {
        $blog_id = $fields;
    }
    $blog_id = (int) $blog_id;
    $all = ($get_all == true) ? '' : 'short';
    $details = wp_cache_get($blog_id . $all, 'blog-details');
    if ($details) {
        if (!is_object($details)) {
            if ($details == -1) {
                return false;
            } else {
                // Clear old pre-serialized objects. Cache clients do better with that.
                wp_cache_delete($blog_id . $all, 'blog-details');
                unset($details);
            }
        } else {
            return $details;
        }
    }
    // Try the other cache.
    if ($get_all) {
        $details = wp_cache_get($blog_id . 'short', 'blog-details');
    } else {
        $details = wp_cache_get($blog_id, 'blog-details');
        // If short was requested and full cache is set, we can return.
        if ($details) {
            if (!is_object($details)) {
                if ($details == -1) {
                    return false;
                } else {
                    // Clear old pre-serialized objects. Cache clients do better with that.
                    wp_cache_delete($blog_id, 'blog-details');
                    unset($details);
                }
            } else {
                return $details;
            }
        }
    }
    if (empty($details)) {
        $details = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d /* get_blog_details */", $blog_id));
        if (!$details) {
            // Set the full cache.
            wp_cache_set($blog_id, -1, 'blog-details');
            return false;
        }
    }
    if (!$get_all) {
        wp_cache_set($blog_id . $all, $details, 'blog-details');
        return $details;
    }
    switch_to_blog($blog_id);
    $details->blogname = get_option('blogname');
    $details->siteurl = get_option('siteurl');
    $details->post_count = get_option('post_count');
    restore_current_blog();
    $details = apply_filters('blog_details', $details);
    wp_cache_set($blog_id . $all, $details, 'blog-details');
    $key = md5($details->domain . $details->path);
    wp_cache_set($key, $details, 'blog-lookup');
    return $details;
}