Index: src/wp-admin/includes/class-wp-ms-sites-list-table.php
===================================================================
--- src/wp-admin/includes/class-wp-ms-sites-list-table.php	(revision 40512)
+++ src/wp-admin/includes/class-wp-ms-sites-list-table.php	(working copy)
@@ -330,7 +330,7 @@
 		</strong>
 		<?php
 		if ( 'list' !== $mode ) {
-			switch_to_blog( $blog['blog_id'] );
+			switch_to_blog( get_site( $blog['blog_id'] ) );
 			echo '<p>';
 			printf(
 				/* translators: 1: site name, 2: site tagline. */
Index: src/wp-admin/includes/ms.php
===================================================================
--- src/wp-admin/includes/ms.php	(revision 40512)
+++ src/wp-admin/includes/ms.php	(working copy)
@@ -231,7 +231,7 @@
 
 	if ( ! empty( $blogs ) ) {
 		foreach ( $blogs as $blog ) {
-			switch_to_blog( $blog->userblog_id );
+			switch_to_blog( get_site( $blog ) );
 			remove_user_from_blog( $id, $blog->userblog_id );
 
 			$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
Index: src/wp-admin/network/site-themes.php
===================================================================
--- src/wp-admin/network/site-themes.php	(revision 40512)
+++ src/wp-admin/network/site-themes.php	(working copy)
@@ -69,7 +69,7 @@
 $is_main_site = is_main_site( $id );
 
 if ( $action ) {
-	switch_to_blog( $id );
+	switch_to_blog( $details );
 	$allowed_themes = get_option( 'allowedthemes' );
 
 	switch ( $action ) {
Index: src/wp-admin/network/site-users.php
===================================================================
--- src/wp-admin/network/site-users.php	(revision 40512)
+++ src/wp-admin/network/site-users.php	(working copy)
@@ -61,7 +61,7 @@
 
 $is_main_site = is_main_site( $id );
 
-switch_to_blog( $id );
+switch_to_blog( $details );
 
 $action = $wp_list_table->current_action();
 
Index: src/wp-includes/admin-bar.php
===================================================================
--- src/wp-includes/admin-bar.php	(revision 40512)
+++ src/wp-includes/admin-bar.php	(working copy)
@@ -508,7 +508,7 @@
 	) );
 
 	foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
-		switch_to_blog( $blog->userblog_id );
+		switch_to_blog( get_site( $blog ) );
 
 		$blavatar = '<div class="blavatar"></div>';
 
Index: src/wp-includes/class-wp-site.php
===================================================================
--- src/wp-includes/class-wp-site.php	(revision 40512)
+++ src/wp-includes/class-wp-site.php	(working copy)
@@ -334,7 +334,7 @@
 
 		if ( false === $details ) {
 
-			switch_to_blog( $this->blog_id );
+			switch_to_blog( $this );
 			// Create a raw copy of the object for backwards compatibility with the filter below.
 			$details = new stdClass();
 			foreach ( get_object_vars( $this ) as $key => $value ) {
Index: src/wp-includes/class-wp-xmlrpc-server.php
===================================================================
--- src/wp-includes/class-wp-xmlrpc-server.php	(revision 40512)
+++ src/wp-includes/class-wp-xmlrpc-server.php	(working copy)
@@ -632,8 +632,8 @@
 				continue;
 
 			$blog_id = $blog->userblog_id;
-
-			switch_to_blog( $blog_id );
+			$site = get_site( $blog );
+			switch_to_blog( $site );
 
 			$is_admin = current_user_can( 'manage_options' );
 			$is_primary = ( (int) $blog_id === $primary_blog_id );
Index: src/wp-includes/ms-blogs.php
===================================================================
--- src/wp-includes/ms-blogs.php	(revision 40512)
+++ src/wp-includes/ms-blogs.php	(working copy)
@@ -229,7 +229,7 @@
 		return $details;
 	}
 
-	switch_to_blog( $blog_id );
+	switch_to_blog( $details );
 	$details->blogname   = get_option( 'blogname' );
 	$details->siteurl    = get_option( 'siteurl' );
 	$details->post_count = get_option( 'post_count' );
@@ -788,7 +788,7 @@
  * @global string          $table_prefix
  * @global WP_Object_Cache $wp_object_cache
  *
- * @param int  $new_blog   The id of the blog you want to switch to. Default: current blog
+ * @param WP_Site|int  $new_blog   The id of the blog you want to switch to. Default: current blog
  * @param bool $deprecated Deprecated argument
  * @return true Always returns True.
  */
@@ -796,8 +796,12 @@
 	global $wpdb, $wp_roles;
 
 	$blog_id = get_current_blog_id();
+	$site_object = false;
 	if ( empty( $new_blog ) ) {
 		$new_blog = $blog_id;
+	} else if ( $new_blog instanceof WP_Site ) {
+		$site_object = $new_blog;
+		$new_blog = $site_object->blog_id;
 	}
 
 	$GLOBALS['_wp_switched_stack'][] = $blog_id;
@@ -815,8 +819,9 @@
 		 *
 		 * @param int $new_blog New blog ID.
 		 * @param int $new_blog Blog ID.
+		 * @param WP_Site $site_object Optional Site object.
 		 */
-		do_action( 'switch_blog', $new_blog, $new_blog );
+		do_action( 'switch_blog', $new_blog, $new_blog, $site_object );
 		$GLOBALS['switched'] = true;
 		return true;
 	}
@@ -855,7 +860,7 @@
 	}
 
 	/** This filter is documented in wp-includes/ms-blogs.php */
-	do_action( 'switch_blog', $new_blog, $prev_blog_id );
+	do_action( 'switch_blog', $new_blog, $prev_blog_id, $site_object );
 	$GLOBALS['switched'] = true;
 
 	return true;
@@ -888,7 +893,7 @@
 
 	if ( $blog_id == $blog ) {
 		/** This filter is documented in wp-includes/ms-blogs.php */
-		do_action( 'switch_blog', $blog, $blog );
+		do_action( 'switch_blog', $blog, $blog, false );
 		// If we still have items in the switched stack, consider ourselves still 'switched'
 		$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
 		return true;
@@ -929,7 +934,7 @@
 	}
 
 	/** This filter is documented in wp-includes/ms-blogs.php */
-	do_action( 'switch_blog', $blog, $prev_blog_id );
+	do_action( 'switch_blog', $blog, $prev_blog_id, false );
 
 	// If we still have items in the switched stack, consider ourselves still 'switched'
 	$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
Index: src/wp-includes/ms-functions.php
===================================================================
--- src/wp-includes/ms-functions.php	(revision 40512)
+++ src/wp-includes/ms-functions.php	(working copy)
@@ -1170,7 +1170,7 @@
 	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
 		return new WP_Error('insert_blog', __('Could not create site.'));
 
-	switch_to_blog($blog_id);
+	switch_to_blog( get_site( $blog_id ) );
 	install_blog($blog_id, $title);
 	wp_install_defaults($user_id);
 
