wp/wp-includes/class-wp-network.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- a/wp/wp-includes/class-wp-network.php	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/class-wp-network.php	Tue Dec 15 13:49:49 2020 +0100
@@ -101,16 +101,20 @@
 
 		$_network = wp_cache_get( $network_id, 'networks' );
 
-		if ( ! $_network ) {
+		if ( false === $_network ) {
 			$_network = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->site} WHERE id = %d LIMIT 1", $network_id ) );
 
 			if ( empty( $_network ) || is_wp_error( $_network ) ) {
-				return false;
+				$_network = -1;
 			}
 
 			wp_cache_add( $network_id, $_network, 'networks' );
 		}
 
+		if ( is_numeric( $_network ) ) {
+			return false;
+		}
+
 		return new WP_Network( $_network );
 	}
 
@@ -231,15 +235,15 @@
 			return (int) $this->blog_id;
 		}
 
-		if ( ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) && $this->domain === DOMAIN_CURRENT_SITE && $this->path === PATH_CURRENT_SITE )
-			|| ( defined( 'SITE_ID_CURRENT_SITE' ) && $this->id == SITE_ID_CURRENT_SITE ) ) {
+		if ( ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) && DOMAIN_CURRENT_SITE === $this->domain && PATH_CURRENT_SITE === $this->path )
+			|| ( defined( 'SITE_ID_CURRENT_SITE' ) && SITE_ID_CURRENT_SITE == $this->id ) ) {
 			if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) {
 				$this->blog_id = (string) BLOG_ID_CURRENT_SITE;
 
 				return (int) $this->blog_id;
 			}
 
-			if ( defined( 'BLOGID_CURRENT_SITE' ) ) { // deprecated.
+			if ( defined( 'BLOGID_CURRENT_SITE' ) ) { // Deprecated.
 				$this->blog_id = (string) BLOGID_CURRENT_SITE;
 
 				return (int) $this->blog_id;
@@ -403,7 +407,8 @@
 		 *
 		 * @since 3.9.0
 		 *
-		 * @param null|bool|WP_Network $network  Network value to return by path.
+		 * @param null|bool|WP_Network $network  Network value to return by path. Default null
+		 *                                       to continue retrieving the network.
 		 * @param string               $domain   The requested domain.
 		 * @param string               $path     The requested path, in full.
 		 * @param int|null             $segments The suggested number of paths to consult.
@@ -457,7 +462,7 @@
 					break;
 				}
 			}
-			if ( $network->path === '/' ) {
+			if ( '/' === $network->path ) {
 				$found = true;
 				break;
 			}