Code Duplication    Length = 27-27 lines in 2 locations

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

@@ 222-248 (lines=27) @@
219
	// try to send actions until we run out of things to send,
220
	// or have to wait more than 15s before sending again,
221
	// or we hit a lock or some other sending issue
222
	static function do_cron_sync() {
223
		if ( ! self::sync_allowed() ) {
224
			return;
225
		}
226
227
		self::initialize_sender();
228
229
		do {
230
			$next_sync_time = self::$sender->get_next_sync_time( 'sync' );
231
232
			if ( $next_sync_time ) {
233
				$delay = $next_sync_time - time() + 1;
234
				if ( $delay > 15 ) {
235
					break;
236
				} elseif ( $delay > 0 ) {
237
					sleep( $delay );
238
				}
239
			}
240
241
			$result = self::$sender->do_sync();
242
243
			// if we are time-limited, only do one cycle
244
			if ( !! ini_get('max_execution_time') ) {
245
				return;
246
			}
247
		} while ( $result );
248
	}
249
250
	static function do_cron_full_sync() {
251
		if ( ! self::sync_allowed() ) {
@@ 250-276 (lines=27) @@
247
		} while ( $result );
248
	}
249
250
	static function do_cron_full_sync() {
251
		if ( ! self::sync_allowed() ) {
252
			return;
253
		}
254
255
		self::initialize_sender();
256
257
		do {
258
			$next_sync_time = self::$sender->get_next_sync_time( 'full_sync' );
259
260
			if ( $next_sync_time ) {
261
				$delay = $next_sync_time - time() + 1;
262
				if ( $delay > 15 ) {
263
					break;
264
				} elseif ( $delay > 0 ) {
265
					sleep( $delay );
266
				}
267
			}
268
269
			$result = self::$sender->do_full_sync();
270
271
			// if we are time-limited, only do one cycle
272
			if ( !! ini_get('max_execution_time') ) {
273
				return;
274
			}
275
		} while ( $result );
276
	}
277
278
	static function initialize_listener() {
279
		require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php';