Code Duplication    Length = 27-27 lines in 2 locations

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

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