Index: src/wp-includes/user.php
===================================================================
--- src/wp-includes/user.php	(revision 50180)
+++ src/wp-includes/user.php	(working copy)
@@ -126,11 +126,11 @@
 		return $user;
 	}
 
+	if ( is_wp_error( $user ) ) {
+		return $user;
+	}
+
 	if ( empty( $username ) || empty( $password ) ) {
-		if ( is_wp_error( $user ) ) {
-			return $user;
-		}
-
 		$error = new WP_Error();
 
 		if ( empty( $username ) ) {
@@ -200,11 +200,11 @@
 		return $user;
 	}
 
+	if ( is_wp_error( $user ) ) {
+		return $user;
+	}
+
 	if ( empty( $email ) || empty( $password ) ) {
-		if ( is_wp_error( $user ) ) {
-			return $user;
-		}
-
 		$error = new WP_Error();
 
 		if ( empty( $email ) ) {
@@ -273,6 +273,10 @@
 		return $user;
 	}
 
+	if ( is_wp_error( $user ) ) {
+		return $user;
+	}
+
 	if ( empty( $username ) && empty( $password ) ) {
 		$user_id = wp_validate_auth_cookie();
 		if ( $user_id ) {
@@ -314,6 +318,10 @@
 		return $input_user;
 	}
 
+	if ( is_wp_error( $user ) ) {
+		return $input_user;
+	}
+
 	if ( ! WP_Application_Passwords::is_in_use() ) {
 		return $input_user;
 	}
