Code Duplication    Length = 23-23 lines in 2 locations

class.jetpack.php 1 location

@@ 1649-1671 (lines=23) @@
1646
			//@todo retry on failure
1647
1648
			//try to choose a new master if we're demoting the current one
1649
			if ( $user_id == $master_user_id && 'administrator' != $role ) {
1650
				$query = new WP_User_Query(
1651
					array(
1652
						'fields'  => array( 'id' ),
1653
						'role'    => 'administrator',
1654
						'orderby' => 'id',
1655
						'exclude' => array( $master_user_id ),
1656
					)
1657
				);
1658
				$new_master = false;
1659
				foreach ( $query->results as $result ) {
1660
					$uid = absint( $result->id );
1661
					if ( $uid && Jetpack::is_user_connected( $uid ) ) {
1662
						$new_master = $uid;
1663
						break;
1664
					}
1665
				}
1666
1667
				if ( $new_master ) {
1668
					Jetpack_Options::update_option( 'master_user', $new_master );
1669
				}
1670
				// else disconnect..?
1671
			}
1672
		}
1673
	}
1674

sync/class.jetpack-sync-users.php 1 location

@@ 39-61 (lines=23) @@
36
//@todo retry on failure
37
38
//try to choose a new master if we're demoting the current one
39
			if ( $user_id == $master_user_id && 'administrator' != $role ) {
40
				$query      = new WP_User_Query(
41
					array(
42
						'fields'  => array( 'id' ),
43
						'role'    => 'administrator',
44
						'orderby' => 'id',
45
						'exclude' => array( $master_user_id ),
46
					)
47
				);
48
				$new_master = false;
49
				foreach ( $query->results as $result ) {
50
					$uid = absint( $result->id );
51
					if ( $uid && Jetpack::is_user_connected( $uid ) ) {
52
						$new_master = $uid;
53
						break;
54
					}
55
				}
56
57
				if ( $new_master ) {
58
					Jetpack_Options::update_option( 'master_user', $new_master );
59
				}
60
// else disconnect..?
61
			}
62
		}
63
	}
64
}