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

@@ 1378-1400 (lines=23) @@
1375
			//@todo retry on failure
1376
1377
			//try to choose a new master if we're demoting the current one
1378
			if ( $user_id == $master_user_id && 'administrator' != $role ) {
1379
				$query = new WP_User_Query(
1380
					array(
1381
						'fields'  => array( 'id' ),
1382
						'role'    => 'administrator',
1383
						'orderby' => 'id',
1384
						'exclude' => array( $master_user_id ),
1385
					)
1386
				);
1387
				$new_master = false;
1388
				foreach ( $query->results as $result ) {
1389
					$uid = absint( $result->id );
1390
					if ( $uid && Jetpack::is_user_connected( $uid ) ) {
1391
						$new_master = $uid;
1392
						break;
1393
					}
1394
				}
1395
1396
				if ( $new_master ) {
1397
					Jetpack_Options::update_option( 'master_user', $new_master );
1398
				}
1399
				// else disconnect..?
1400
			}
1401
		}
1402
	}
1403