Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/wp-includes/class-wp-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ final class WP_Site {
* Retrieves a site from the database by its ID.
*
* @since 4.5.0
* @since 7.2.0 Non-object cache values are now treated as a cache miss.
*
* @global wpdb $wpdb WordPress database abstraction object.
*
Expand All @@ -175,7 +176,12 @@ public static function get_instance( $site_id ) {

$_site = wp_cache_get( $site_id, 'sites' );

if ( false === $_site ) {
// A cached -1 records a previous lookup that found nothing. Anything else that is not a site object is treated as a cache miss.
if (
( ! is_object( $_site ) || ! isset( $_site->blog_id ) )
&&
! is_numeric( $_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 ) ) {
Comment thread
westonruter marked this conversation as resolved.
Expand Down
Loading