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