Code Duplication    Length = 25-25 lines in 2 locations

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

@@ 279-303 (lines=25) @@
276
	// try to send actions until we run out of things to send,
277
	// or have to wait more than 15s before sending again,
278
	// or we hit a lock or some other sending issue
279
	static function do_cron_sync() {
280
		if ( ! self::sync_allowed() ) {
281
			return;
282
		}
283
284
		self::initialize_sender();
285
286
		$time_limit = Jetpack_Sync_Settings::get_setting( 'cron_sync_time_limit' );
287
		$start_time = time();
288
289
		do {
290
			$next_sync_time = self::$sender->get_next_sync_time( 'sync' );
291
292
			if ( $next_sync_time ) {
293
				$delay = $next_sync_time - time() + 1;
294
				if ( $delay > 15 ) {
295
					break;
296
				} elseif ( $delay > 0 ) {
297
					sleep( $delay );
298
				}
299
			}
300
301
			$result = self::$sender->do_sync();
302
		} while ( $result && ( $start_time + $time_limit ) > time() );
303
	}
304
305
	static function do_cron_full_sync() {
306
		if ( ! self::sync_allowed() ) {
@@ 305-329 (lines=25) @@
302
		} while ( $result && ( $start_time + $time_limit ) > time() );
303
	}
304
305
	static function do_cron_full_sync() {
306
		if ( ! self::sync_allowed() ) {
307
			return;
308
		}
309
310
		self::initialize_sender();
311
312
		$time_limit = Jetpack_Sync_Settings::get_setting( 'cron_sync_time_limit' );
313
		$start_time = time();
314
315
		do {
316
			$next_sync_time = self::$sender->get_next_sync_time( 'full_sync' );
317
318
			if ( $next_sync_time ) {
319
				$delay = $next_sync_time - time() + 1;
320
				if ( $delay > 15 ) {
321
					break;
322
				} elseif ( $delay > 0 ) {
323
					sleep( $delay );
324
				}
325
			}
326
327
			$result = self::$sender->do_full_sync();
328
		} while ( $result && ( $start_time + $time_limit ) > time() );
329
	}
330
331
	static function initialize_listener() {
332
		require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php';