Code Duplication    Length = 27-27 lines in 2 locations

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

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