Code Duplication    Length = 23-23 lines in 2 locations

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
}

class.jetpack.php 1 location

@@ 1449-1471 (lines=23) @@
1446
			//@todo retry on failure
1447
1448
			//try to choose a new master if we're demoting the current one
1449
			if ( $user_id == $master_user_id && 'administrator' != $role ) {
1450
				$query = new WP_User_Query(
1451
					array(
1452
						'fields'  => array( 'id' ),
1453
						'role'    => 'administrator',
1454
						'orderby' => 'id',
1455
						'exclude' => array( $master_user_id ),
1456
					)
1457
				);
1458
				$new_master = false;
1459
				foreach ( $query->results as $result ) {
1460
					$uid = absint( $result->id );
1461
					if ( $uid && Jetpack::is_user_connected( $uid ) ) {
1462
						$new_master = $uid;
1463
						break;
1464
					}
1465
				}
1466
1467
				if ( $new_master ) {
1468
					Jetpack_Options::update_option( 'master_user', $new_master );
1469
				}
1470
				// else disconnect..?
1471
			}
1472
		}
1473
	}
1474