0; } /** * Whether WP-Cron had not run for over an hour although requests kept starting it. * * @return bool True only on that evidence, or on a late event with DISABLE_WP_CRON. */ public static function isStalled(): bool { if ( ! self::oldestEventIsOverdue() ) { return false; } if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) { return true; } return true === self::$lock_seen_before_spawn; } /** * Forgets the lock read. * * For tests only: runtime code never calls it, because the read must come from the * start of the request. * * @return void */ public static function reset(): void { self::$lock_seen_before_spawn = null; } /** * Whether the oldest scheduled event is late by more than the overdue limit. * * An empty or unreadable cron array is unknown, and unknown is not late. * * @return bool */ private static function oldestEventIsOverdue(): bool { $crons = _get_cron_array(); if ( ! is_array( $crons ) ) { return false; } $oldest = null; foreach ( array_keys( $crons ) as $timestamp ) { if ( ! is_int( $timestamp ) ) { continue; } if ( null === $oldest || $timestamp < $oldest ) { $oldest = $timestamp; } } return null !== $oldest && time() - $oldest > DiagnosticsDebugInfo::OVERDUE_AFTER_SECONDS; } }