0 && ( time() - $held ) < self::LOCK_TTL ) { return false; } update_option( self::LOCK_OPTION, time(), false ); return true; } /** * Release the run lock. * * @return void */ private static function release_lock() { delete_option( self::LOCK_OPTION ); } /** * Run one poll inline (a connect-time or manual "refresh now") under the SAME * lock the cron uses. If a run already holds the lock, skip quietly — the REST * caller then returns the current stored data instead of racing a second * snapshot rewrite (a DELETE + chunked INSERT) over the first, which would leave * a mixed or doubled snapshot. The using class provides run_poll(). * * @return void */ public function poll_now() { if ( ! self::acquire_lock() ) { return; } try { $this->run_poll(); } finally { self::release_lock(); } } }