@@ 211-237 (lines=27) @@ | ||
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 | // remove shutdown hook - no need to sync twice |
|
219 | if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) { |
|
220 | remove_action( 'shutdown', array( self::$sender, 'do_sync' ) ); |
|
221 | } |
|
222 | ||
223 | do { |
|
224 | $next_sync_time = self::$sender->get_next_sync_time( 'sync' ); |
|
225 | ||
226 | if ( $next_sync_time ) { |
|
227 | $delay = $next_sync_time - time() + 1; |
|
228 | if ( $delay > 15 ) { |
|
229 | break; |
|
230 | } elseif ( $delay > 0 ) { |
|
231 | sleep( $delay ); |
|
232 | } |
|
233 | } |
|
234 | ||
235 | $result = self::$sender->do_sync(); |
|
236 | } while ( $result ); |
|
237 | } |
|
238 | ||
239 | static function do_cron_full_sync() { |
|
240 | if ( ! self::sync_allowed() ) { |
|
@@ 239-265 (lines=27) @@ | ||
236 | } while ( $result ); |
|
237 | } |
|
238 | ||
239 | static function do_cron_full_sync() { |
|
240 | if ( ! self::sync_allowed() ) { |
|
241 | return; |
|
242 | } |
|
243 | ||
244 | self::initialize_sender(); |
|
245 | ||
246 | // remove shutdown hook - no need to sync twice |
|
247 | if ( has_action( 'shutdown', array( self::$sender, 'do_sync' ) ) ) { |
|
248 | remove_action( 'shutdown', array( self::$sender, 'do_sync' ) ); |
|
249 | } |
|
250 | ||
251 | do { |
|
252 | $next_sync_time = self::$sender->get_next_sync_time( 'full_sync' ); |
|
253 | ||
254 | if ( $next_sync_time ) { |
|
255 | $delay = $next_sync_time - time() + 1; |
|
256 | if ( $delay > 15 ) { |
|
257 | break; |
|
258 | } elseif ( $delay > 0 ) { |
|
259 | sleep( $delay ); |
|
260 | } |
|
261 | } |
|
262 | ||
263 | $result = self::$sender->do_full_sync(); |
|
264 | } while ( $result ); |
|
265 | } |
|
266 | ||
267 | static function initialize_listener() { |
|
268 | require_once dirname( __FILE__ ) . '/class.jetpack-sync-listener.php'; |