| @@ 267-293 (lines=27) @@ | ||
| 264 | // try to send actions until we run out of things to send, |
|
| 265 | // or have to wait more than 15s before sending again, |
|
| 266 | // or we hit a lock or some other sending issue |
|
| 267 | static function do_cron_sync() { |
|
| 268 | if ( ! self::sync_allowed() ) { |
|
| 269 | return; |
|
| 270 | } |
|
| 271 | ||
| 272 | self::initialize_sender(); |
|
| 273 | ||
| 274 | // remove shutdown hook - no need to sync twice |
|
| 275 | if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) { |
|
| 276 | remove_action( 'shutdown', array( self::$sender, 'do_sync' ) ); |
|
| 277 | } |
|
| 278 | ||
| 279 | do { |
|
| 280 | $next_sync_time = self::$sender->get_next_sync_time( 'sync' ); |
|
| 281 | ||
| 282 | if ( $next_sync_time ) { |
|
| 283 | $delay = $next_sync_time - time() + 1; |
|
| 284 | if ( $delay > 15 ) { |
|
| 285 | break; |
|
| 286 | } elseif ( $delay > 0 ) { |
|
| 287 | sleep( $delay ); |
|
| 288 | } |
|
| 289 | } |
|
| 290 | ||
| 291 | $result = self::$sender->do_sync(); |
|
| 292 | } while ( $result ); |
|
| 293 | } |
|
| 294 | ||
| 295 | static function do_cron_full_sync() { |
|
| 296 | if ( ! self::sync_allowed() ) { |
|
| @@ 295-321 (lines=27) @@ | ||
| 292 | } while ( $result ); |
|
| 293 | } |
|
| 294 | ||
| 295 | static function do_cron_full_sync() { |
|
| 296 | if ( ! self::sync_allowed() ) { |
|
| 297 | return; |
|
| 298 | } |
|
| 299 | ||
| 300 | self::initialize_sender(); |
|
| 301 | ||
| 302 | // remove shutdown hook - no need to sync twice |
|
| 303 | if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) { |
|
| 304 | remove_action( 'shutdown', array( self::$sender, 'do_sync' ) ); |
|
| 305 | } |
|
| 306 | ||
| 307 | do { |
|
| 308 | $next_sync_time = self::$sender->get_next_sync_time( 'full_sync' ); |
|
| 309 | ||
| 310 | if ( $next_sync_time ) { |
|
| 311 | $delay = $next_sync_time - time() + 1; |
|
| 312 | if ( $delay > 15 ) { |
|
| 313 | break; |
|
| 314 | } elseif ( $delay > 0 ) { |
|
| 315 | sleep( $delay ); |
|
| 316 | } |
|
| 317 | } |
|
| 318 | ||
| 319 | $result = self::$sender->do_full_sync(); |
|
| 320 | } while ( $result ); |
|
| 321 | } |
|
| 322 | ||
| 323 | static function initialize_listener() { |
|
| 324 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php'; |
|