Index: src/wp-includes/class-wp-user.php
===================================================================
--- src/wp-includes/class-wp-user.php	(revision 38641)
+++ src/wp-includes/class-wp-user.php	(working copy)
@@ -480,6 +480,18 @@
 	 * @return array List of all capabilities for the user.
 	 */
 	public function get_role_caps() {
+		$switch_site = false;
+		if ( is_multisite() && $this->db->get_blog_prefix() . 'capabilities' !== $this->cap_key ) {
+			$base_prefix = $this->db->get_blog_prefix( 1 );
+			if ( $base_prefix . 'capabilities' === $this->cap_key ) {
+				$switch_site = 1;
+			} else {
+				$switch_site = absint( substr( $this->cap_key, strlen( $base_prefix ), - strlen( '_capabilities' ) ) );
+			}
+
+			switch_to_blog( $switch_site );
+		}
+
 		$wp_roles = wp_roles();
 
 		//Filter out caps that are not role names and assign to $this->roles
@@ -494,6 +506,10 @@
 		}
 		$this->allcaps = array_merge( (array) $this->allcaps, (array) $this->caps );
 
+		if ( $switch_site ) {
+			restore_current_blog();
+		}
+
 		return $this->allcaps;
 	}
 
