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