clean_blog_cache

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

WordPress Version: 6.3

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param WP_Site|int $blog The site object or ID to be cleared from cache.
 */
function clean_blog_cache($blog)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (empty($blog)) {
        return;
    }
    $blog_id = $blog;
    $blog = get_site($blog_id);
    if (!$blog) {
        if (!is_numeric($blog_id)) {
            return;
        }
        // Make sure a WP_Site object exists even when the site has been deleted.
        $blog = new WP_Site((object) array('blog_id' => $blog_id, 'domain' => null, 'path' => null));
    }
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'sites');
    wp_cache_delete($blog_id, 'site-details');
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
    wp_cache_delete($blog_id, 'blog_meta');
    /**
     * Fires immediately after a site has been removed from the object cache.
     *
     * @since 4.6.0
     *
     * @param string  $id              Site ID as a numeric string.
     * @param WP_Site $blog            Site object.
     * @param string  $domain_path_key md5 hash of domain and path.
     */
    do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
    wp_cache_set_sites_last_changed();
    /**
     * Fires after the blog details cache is cleared.
     *
     * @since 3.4.0
     * @deprecated 4.9.0 Use {@see 'clean_site_cache'} instead.
     *
     * @param int $blog_id Blog ID.
     */
    do_action_deprecated('refresh_blog_details', array($blog_id), '4.9.0', 'clean_site_cache');
}

WordPress Version: 5.9

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param WP_Site|int $blog The site object or ID to be cleared from cache.
 */
function clean_blog_cache($blog)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (empty($blog)) {
        return;
    }
    $blog_id = $blog;
    $blog = get_site($blog_id);
    if (!$blog) {
        if (!is_numeric($blog_id)) {
            return;
        }
        // Make sure a WP_Site object exists even when the site has been deleted.
        $blog = new WP_Site((object) array('blog_id' => $blog_id, 'domain' => null, 'path' => null));
    }
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'sites');
    wp_cache_delete($blog_id, 'site-details');
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
    wp_cache_delete($blog_id, 'blog_meta');
    /**
     * Fires immediately after a site has been removed from the object cache.
     *
     * @since 4.6.0
     *
     * @param string  $id              Site ID as a numeric string.
     * @param WP_Site $blog            Site object.
     * @param string  $domain_path_key md5 hash of domain and path.
     */
    do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
    wp_cache_set('last_changed', microtime(), 'sites');
    /**
     * Fires after the blog details cache is cleared.
     *
     * @since 3.4.0
     * @deprecated 4.9.0 Use {@see 'clean_site_cache'} instead.
     *
     * @param int $blog_id Blog ID.
     */
    do_action_deprecated('refresh_blog_details', array($blog_id), '4.9.0', 'clean_site_cache');
}

WordPress Version: 5.4

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param WP_Site|int $blog The site object or ID to be cleared from cache.
 */
function clean_blog_cache($blog)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (empty($blog)) {
        return;
    }
    $blog_id = $blog;
    $blog = get_site($blog_id);
    if (!$blog) {
        if (!is_numeric($blog_id)) {
            return;
        }
        // Make sure a WP_Site object exists even when the site has been deleted.
        $blog = new WP_Site((object) array('blog_id' => $blog_id, 'domain' => null, 'path' => null));
    }
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'sites');
    wp_cache_delete($blog_id, 'site-details');
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
    wp_cache_delete($blog_id, 'blog_meta');
    /**
     * Fires immediately after a site has been removed from the object cache.
     *
     * @since 4.6.0
     *
     * @param int     $id              Blog ID.
     * @param WP_Site $blog            Site object.
     * @param string  $domain_path_key md5 hash of domain and path.
     */
    do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
    wp_cache_set('last_changed', microtime(), 'sites');
    /**
     * Fires after the blog details cache is cleared.
     *
     * @since 3.4.0
     * @deprecated 4.9.0 Use {@see 'clean_site_cache'} instead.
     *
     * @param int $blog_id Blog ID.
     */
    do_action_deprecated('refresh_blog_details', array($blog_id), '4.9.0', 'clean_site_cache');
}

WordPress Version: 5.1

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param WP_Site|int $blog The site object or ID to be cleared from cache.
 */
function clean_blog_cache($blog)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (empty($blog)) {
        return;
    }
    $blog_id = $blog;
    $blog = get_site($blog_id);
    if (!$blog) {
        if (!is_numeric($blog_id)) {
            return;
        }
        // Make sure a WP_Site object exists even when the site has been deleted.
        $blog = new WP_Site((object) array('blog_id' => $blog_id, 'domain' => null, 'path' => null));
    }
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'sites');
    wp_cache_delete($blog_id, 'site-details');
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
    wp_cache_delete('current_blog_' . $blog->domain, 'site-options');
    wp_cache_delete('current_blog_' . $blog->domain . $blog->path, 'site-options');
    wp_cache_delete($blog_id, 'blog_meta');
    /**
     * Fires immediately after a site has been removed from the object cache.
     *
     * @since 4.6.0
     *
     * @param int     $id              Blog ID.
     * @param WP_Site $blog            Site object.
     * @param string  $domain_path_key md5 hash of domain and path.
     */
    do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
    wp_cache_set('last_changed', microtime(), 'sites');
    /**
     * Fires after the blog details cache is cleared.
     *
     * @since 3.4.0
     * @deprecated 4.9.0 Use clean_site_cache
     *
     * @param int $blog_id Blog ID.
     */
    do_action_deprecated('refresh_blog_details', array($blog_id), '4.9.0', 'clean_site_cache');
}

WordPress Version: 4.9

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param WP_Site|int $blog The site object or ID to be cleared from cache.
 */
function clean_blog_cache($blog)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    if (empty($blog)) {
        return;
    }
    $blog_id = $blog;
    $blog = get_site($blog_id);
    if (!$blog) {
        if (!is_numeric($blog_id)) {
            return;
        }
        // Make sure a WP_Site object exists even when the site has been deleted.
        $blog = new WP_Site((object) array('blog_id' => $blog_id, 'domain' => null, 'path' => null));
    }
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'sites');
    wp_cache_delete($blog_id, 'site-details');
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
    wp_cache_delete('current_blog_' . $blog->domain, 'site-options');
    wp_cache_delete('current_blog_' . $blog->domain . $blog->path, 'site-options');
    /**
     * Fires immediately after a site has been removed from the object cache.
     *
     * @since 4.6.0
     *
     * @param int     $id              Blog ID.
     * @param WP_Site $blog            Site object.
     * @param string  $domain_path_key md5 hash of domain and path.
     */
    do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
    wp_cache_set('last_changed', microtime(), 'sites');
    /**
     * Fires after the blog details cache is cleared.
     *
     * @since 3.4.0
     * @deprecated 4.9.0 Use clean_site_cache
     *
     * @param int $blog_id Blog ID.
     */
    do_action_deprecated('refresh_blog_details', array($blog_id), '4.9.0', 'clean_site_cache');
}

WordPress Version: 4.8

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @global bool $_wp_suspend_cache_invalidation
 *
 * @param WP_Site $blog The site object to be cleared from cache.
 */
function clean_blog_cache($blog)
{
    global $_wp_suspend_cache_invalidation;
    if (!empty($_wp_suspend_cache_invalidation)) {
        return;
    }
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'sites');
    wp_cache_delete($blog_id, 'site-details');
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
    wp_cache_delete('current_blog_' . $blog->domain, 'site-options');
    wp_cache_delete('current_blog_' . $blog->domain . $blog->path, 'site-options');
    /**
     * Fires immediately after a site has been removed from the object cache.
     *
     * @since 4.6.0
     *
     * @param int     $id              Blog ID.
     * @param WP_Site $blog            Site object.
     * @param string  $domain_path_key md5 hash of domain and path.
     */
    do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
    wp_cache_set('last_changed', microtime(), 'sites');
}

WordPress Version: 4.7

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @param WP_Site $blog The site object to be cleared from cache.
 */
function clean_blog_cache($blog)
{
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'sites');
    wp_cache_delete($blog_id, 'site-details');
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete('current_blog_' . $blog->domain, 'site-options');
    wp_cache_delete('current_blog_' . $blog->domain . $blog->path, 'site-options');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
    /**
     * Fires immediately after a site has been removed from the object cache.
     *
     * @since 4.6.0
     *
     * @param int     $id              Blog ID.
     * @param WP_Site $blog            Site object.
     * @param string  $domain_path_key md5 hash of domain and path.
     */
    do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
    wp_cache_set('last_changed', microtime(), 'sites');
}

WordPress Version: 4.6

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @param WP_Site $blog The blog details as returned from get_blog_details()
 */
function clean_blog_cache($blog)
{
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'sites');
    wp_cache_delete($blog_id, 'site-details');
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete('current_blog_' . $blog->domain, 'site-options');
    wp_cache_delete('current_blog_' . $blog->domain . $blog->path, 'site-options');
    wp_cache_delete('get_id_from_blogname_' . trim($blog->path, '/'), 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
    /**
     * Fires immediately after a site has been removed from the object cache.
     *
     * @since 4.6.0
     *
     * @param int     $id              Blog ID.
     * @param WP_Site $blog            Site object.
     * @param string  $domain_path_key md5 hash of domain and path.
     */
    do_action('clean_site_cache', $blog_id, $blog, $domain_path_key);
    wp_cache_set('last_changed', microtime(), 'sites');
}

WordPress Version: 4.5

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @param WP_Site $blog The blog details as returned from get_blog_details()
 */
function clean_blog_cache($blog)
{
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'sites');
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete('current_blog_' . $blog->domain, 'site-options');
    wp_cache_delete('current_blog_' . $blog->domain . $blog->path, 'site-options');
    wp_cache_delete('get_id_from_blogname_' . trim($blog->path, '/'), 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
}

WordPress Version: 3.7

/**
 * Clean the blog cache
 *
 * @since 3.5.0
 *
 * @param stdClass $blog The blog details as returned from get_blog_details()
 */
function clean_blog_cache($blog)
{
    $blog_id = $blog->blog_id;
    $domain_path_key = md5($blog->domain . $blog->path);
    wp_cache_delete($blog_id, 'blog-details');
    wp_cache_delete($blog_id . 'short', 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-lookup');
    wp_cache_delete('current_blog_' . $blog->domain, 'site-options');
    wp_cache_delete('current_blog_' . $blog->domain . $blog->path, 'site-options');
    wp_cache_delete('get_id_from_blogname_' . trim($blog->path, '/'), 'blog-details');
    wp_cache_delete($domain_path_key, 'blog-id-cache');
}