Code Duplication    Length = 27-27 lines in 2 locations

sync/class.jetpack-sync-actions.php 2 locations

@@ 257-283 (lines=27) @@
254
	// try to send actions until we run out of things to send,
255
	// or have to wait more than 15s before sending again,
256
	// or we hit a lock or some other sending issue
257
	static function do_cron_sync() {
258
		if ( ! self::sync_allowed() ) {
259
			return;
260
		}
261
262
		self::initialize_sender();
263
264
		// remove shutdown hook - no need to sync twice
265
		if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) {
266
			remove_action( 'shutdown', array( self::$sender, 'do_sync' ) );
267
		}
268
269
		do {
270
			$next_sync_time = self::$sender->get_next_sync_time( 'sync' );
271
272
			if ( $next_sync_time ) {
273
				$delay = $next_sync_time - time() + 1;
274
				if ( $delay > 15 ) {
275
					break;
276
				} elseif ( $delay > 0 ) {
277
					sleep( $delay );
278
				}
279
			}
280
281
			$result = self::$sender->do_sync();
282
		} while ( $result );
283
	}
284
285
	static function do_cron_full_sync() {
286
		if ( ! self::sync_allowed() ) {
@@ 285-311 (lines=27) @@
282
		} while ( $result );
283
	}
284
285
	static function do_cron_full_sync() {
286
		if ( ! self::sync_allowed() ) {
287
			return;
288
		}
289
290
		self::initialize_sender();
291
292
		// remove shutdown hook - no need to sync twice
293
		if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) {
294
			remove_action( 'shutdown', array( self::$sender, 'do_sync' ) );
295
		}
296
297
		do {
298
			$next_sync_time = self::$sender->get_next_sync_time( 'full_sync' );
299
300
			if ( $next_sync_time ) {
301
				$delay = $next_sync_time - time() + 1;
302
				if ( $delay > 15 ) {
303
					break;
304
				} elseif ( $delay > 0 ) {
305
					sleep( $delay );
306
				}
307
			}
308
309
			$result = self::$sender->do_full_sync();
310
		} while ( $result );
311
	}
312
313
	static function initialize_listener() {
314
		require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php';