Code Duplication    Length = 27-27 lines in 2 locations

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

@@ 212-238 (lines=27) @@
209
	// try to send actions until we run out of things to send,
210
	// or have to wait more than 15s before sending again,
211
	// or we hit a lock or some other sending issue
212
	static function do_cron_sync() {
213
		if ( ! self::sync_allowed() ) {
214
			return;
215
		}
216
217
		self::initialize_sender();
218
219
		// remove shutdown hook - no need to sync twice
220
		if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) {
221
			remove_action( 'shutdown', array( self::$sender, 'do_sync' ) );
222
		}
223
224
		do {
225
			$next_sync_time = self::$sender->get_next_sync_time( 'sync' );
226
227
			if ( $next_sync_time ) {
228
				$delay = $next_sync_time - time() + 1;
229
				if ( $delay > 15 ) {
230
					break;
231
				} elseif ( $delay > 0 ) {
232
					sleep( $delay );
233
				}
234
			}
235
236
			$result = self::$sender->do_sync();
237
		} while ( $result );
238
	}
239
240
	static function do_cron_full_sync() {
241
		if ( ! self::sync_allowed() ) {
@@ 240-266 (lines=27) @@
237
		} while ( $result );
238
	}
239
240
	static function do_cron_full_sync() {
241
		if ( ! self::sync_allowed() ) {
242
			return;
243
		}
244
245
		self::initialize_sender();
246
247
		// remove shutdown hook - no need to sync twice
248
		if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) {
249
			remove_action( 'shutdown', array( self::$sender, 'do_sync' ) );
250
		}
251
252
		do {
253
			$next_sync_time = self::$sender->get_next_sync_time( 'full_sync' );
254
255
			if ( $next_sync_time ) {
256
				$delay = $next_sync_time - time() + 1;
257
				if ( $delay > 15 ) {
258
					break;
259
				} elseif ( $delay > 0 ) {
260
					sleep( $delay );
261
				}
262
			}
263
264
			$result = self::$sender->do_full_sync();
265
		} while ( $result );
266
	}
267
268
	static function initialize_listener() {
269
		require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php';