mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Multisite: Improve performance by caching not found lookups for sites and networks.
With this change, the result of a site or network lookup by ID will be cached even if the ID does not exist. When a new site or network is created, the cache for the respective new ID is cleared. Props mnelson4, nielsdeblaauw. Fixes #42251. git-svn-id: https://develop.svn.wordpress.org/trunk@45910 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -162,16 +162,20 @@ final class WP_Site {
|
||||
|
||||
$_site = wp_cache_get( $site_id, 'sites' );
|
||||
|
||||
if ( ! $_site ) {
|
||||
if ( false === $_site ) {
|
||||
$_site = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d LIMIT 1", $site_id ) );
|
||||
|
||||
if ( empty( $_site ) || is_wp_error( $_site ) ) {
|
||||
return false;
|
||||
$_site = -1;
|
||||
}
|
||||
|
||||
wp_cache_add( $site_id, $_site, 'sites' );
|
||||
}
|
||||
|
||||
if ( is_numeric( $_site ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return new WP_Site( $_site );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user