@@ 222-243 (lines=22) @@ | ||
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 | } while ( $result ); |
|
243 | } |
|
244 | ||
245 | static function do_cron_full_sync() { |
|
246 | if ( ! self::sync_allowed() ) { |
|
@@ 245-266 (lines=22) @@ | ||
242 | } while ( $result ); |
|
243 | } |
|
244 | ||
245 | static function do_cron_full_sync() { |
|
246 | if ( ! self::sync_allowed() ) { |
|
247 | return; |
|
248 | } |
|
249 | ||
250 | self::initialize_sender(); |
|
251 | ||
252 | do { |
|
253 | $next_sync_time = self::$sender->get_next_sync_time( 'full_sync' ); |
|
254 | ||
255 | if ( $next_sync_time ) { |
|
256 | $delay = $next_sync_time - time() + 1; |
|
257 | if ( $delay > 15 ) { |
|
258 | break; |
|
259 | } elseif ( $delay > 0 ) { |
|
260 | sleep( $delay ); |
|
261 | } |
|
262 | } |
|
263 | ||
264 | $result = self::$sender->do_full_sync(); |
|
265 | } while ( $result ); |
|
266 | } |
|
267 | ||
268 | static function initialize_listener() { |
|
269 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php'; |