Index: wp-includes/class-wp-user.php
===================================================================
--- wp-includes/class-wp-user.php	(revision 51452)
+++ wp-includes/class-wp-user.php	(working copy)
@@ -529,30 +529,33 @@ class WP_User {
 	}

 	/**
 	 * Add role to user.
 	 *
 	 * Updates the user's meta data option with capabilities and roles.
 	 *
 	 * @since 2.0.0
 	 *
 	 * @param string $role Role name.
 	 */
 	public function add_role( $role ) {
 		if ( empty( $role ) ) {
 			return;
 		}
+		if ( in_array( $role, $this->roles, true ) ) {
+			return;
+		}

 		$this->caps[ $role ] = true;
 		update_user_meta( $this->ID, $this->cap_key, $this->caps );
 		$this->get_role_caps();
 		$this->update_user_level_from_caps();

 		/**
 		 * Fires immediately after the user has been given a new role.
 		 *
 		 * @since 4.3.0
 		 *
 		 * @param int    $user_id The user ID.
 		 * @param string $role    The new role.
 		 */
 		do_action( 'add_user_role', $this->ID, $role );
@@ -604,30 +607,44 @@ class WP_User {
 		foreach ( (array) $this->roles as $oldrole ) {
 			unset( $this->caps[ $oldrole ] );
 		}

 		$old_roles = $this->roles;
 		if ( ! empty( $role ) ) {
 			$this->caps[ $role ] = true;
 			$this->roles         = array( $role => true );
 		} else {
 			$this->roles = false;
 		}
 		update_user_meta( $this->ID, $this->cap_key, $this->caps );
 		$this->get_role_caps();
 		$this->update_user_level_from_caps();

+		foreach ( (array) $old_roles as $old_role ) {
+			if ( ! $old_role || $old_role === $role ) {
+				continue;
+			}
+
+			/** This action is documented in wp-includes/class-wp-user.php */
+			do_action( 'remove_user_role', $this->ID, $old_role );
+		}
+
+		if ( $role && ! in_array( $role, (array) $old_roles, true ) ) {
+			/** This action is documented in wp-includes/class-wp-user.php */
+			do_action( 'add_user_role', $this->ID, $old_role );
+		}
+
 		/**
 		 * Fires after the user's role has changed.
 		 *
 		 * @since 2.9.0
 		 * @since 3.6.0 Added $old_roles to include an array of the user's previous roles.
 		 *
 		 * @param int      $user_id   The user ID.
 		 * @param string   $role      The new role.
 		 * @param string[] $old_roles An array of the user's previous roles.
 		 */
 		do_action( 'set_user_role', $this->ID, $role, $old_roles );
 	}

 	/**
 	 * Choose the maximum level the user has.
