@@ 250-276 (lines=27) @@ | ||
247 | // try to send actions until we run out of things to send, |
|
248 | // or have to wait more than 15s before sending again, |
|
249 | // or we hit a lock or some other sending issue |
|
250 | static function do_cron_sync() { |
|
251 | if ( ! self::sync_allowed() ) { |
|
252 | return; |
|
253 | } |
|
254 | ||
255 | self::initialize_sender(); |
|
256 | ||
257 | // remove shutdown hook - no need to sync twice |
|
258 | if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) { |
|
259 | remove_action( 'shutdown', array( self::$sender, 'do_sync' ) ); |
|
260 | } |
|
261 | ||
262 | do { |
|
263 | $next_sync_time = self::$sender->get_next_sync_time( 'sync' ); |
|
264 | ||
265 | if ( $next_sync_time ) { |
|
266 | $delay = $next_sync_time - time() + 1; |
|
267 | if ( $delay > 15 ) { |
|
268 | break; |
|
269 | } elseif ( $delay > 0 ) { |
|
270 | sleep( $delay ); |
|
271 | } |
|
272 | } |
|
273 | ||
274 | $result = self::$sender->do_sync(); |
|
275 | } while ( $result ); |
|
276 | } |
|
277 | ||
278 | static function do_cron_full_sync() { |
|
279 | if ( ! self::sync_allowed() ) { |
|
@@ 278-304 (lines=27) @@ | ||
275 | } while ( $result ); |
|
276 | } |
|
277 | ||
278 | static function do_cron_full_sync() { |
|
279 | if ( ! self::sync_allowed() ) { |
|
280 | return; |
|
281 | } |
|
282 | ||
283 | self::initialize_sender(); |
|
284 | ||
285 | // remove shutdown hook - no need to sync twice |
|
286 | if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) { |
|
287 | remove_action( 'shutdown', array( self::$sender, 'do_sync' ) ); |
|
288 | } |
|
289 | ||
290 | do { |
|
291 | $next_sync_time = self::$sender->get_next_sync_time( 'full_sync' ); |
|
292 | ||
293 | if ( $next_sync_time ) { |
|
294 | $delay = $next_sync_time - time() + 1; |
|
295 | if ( $delay > 15 ) { |
|
296 | break; |
|
297 | } elseif ( $delay > 0 ) { |
|
298 | sleep( $delay ); |
|
299 | } |
|
300 | } |
|
301 | ||
302 | $result = self::$sender->do_full_sync(); |
|
303 | } while ( $result ); |
|
304 | } |
|
305 | ||
306 | static function initialize_listener() { |
|
307 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php'; |