diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php
index 12e1273..d1a7d22 100644
|
a
|
b
|
class WP_Site_Health {
|
| 1411 | 1411 | ) |
| 1412 | 1412 | ); |
| 1413 | 1413 | } else { |
| 1414 | | if ( $this->has_missed_cron() ) { |
| | 1414 | $has_missed_cron = $this->has_missed_cron(); |
| | 1415 | if ( 'failed' === $has_missed_cron ) { |
| 1415 | 1416 | $result['status'] = 'recommended'; |
| 1416 | 1417 | |
| 1417 | 1418 | $result['label'] = __( 'A scheduled event has failed' ); |
| … |
… |
class WP_Site_Health {
|
| 1424 | 1425 | $this->last_missed_cron |
| 1425 | 1426 | ) |
| 1426 | 1427 | ); |
| | 1428 | } elseif ( 'late' === $has_missed_cron ) { |
| | 1429 | $result['status'] = 'recommended'; |
| | 1430 | |
| | 1431 | $result['label'] = __( 'A scheduled event is late' ); |
| | 1432 | |
| | 1433 | $result['description'] = sprintf( |
| | 1434 | '<p>%s</p>', |
| | 1435 | sprintf( |
| | 1436 | /* translators: %s: The name of the failed cron event. */ |
| | 1437 | __( 'The scheduled event, %s, is late to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.' ), |
| | 1438 | $this->last_missed_cron |
| | 1439 | ) |
| | 1440 | ); |
| 1427 | 1441 | } |
| 1428 | 1442 | } |
| 1429 | 1443 | |
| … |
… |
class WP_Site_Health {
|
| 1907 | 1921 | /** |
| 1908 | 1922 | * Check if any scheduled tasks have been missed. |
| 1909 | 1923 | * |
| 1910 | | * Returns a boolean value of `true` if a scheduled task has been missed and ends processing. If the list of |
| 1911 | | * crons is an instance of WP_Error, return the instance instead of a boolean value. |
| | 1924 | * Returns a boolean `false` if there are no missed cron jobs, otherwise |
| | 1925 | * returns the status of missed events as either `late` or `failed`. |
| | 1926 | * |
| | 1927 | * If getting cron jobs has failed, a WP_Error object is returned. |
| 1912 | 1928 | * |
| 1913 | 1929 | * @since 5.2.0 |
| 1914 | 1930 | * |
| 1915 | | * @return bool|WP_Error true if a cron was missed, false if it wasn't. WP_Error if the cron is set to that. |
| | 1931 | * @return bool|string|WP_Error False if no cron was missed, |
| | 1932 | * 'failed' if a cron failed to run, |
| | 1933 | * 'late' if a cron is late to run. |
| | 1934 | * WP_Error if the cron is set to that. |
| 1916 | 1935 | */ |
| 1917 | 1936 | public function has_missed_cron() { |
| 1918 | 1937 | if ( is_wp_error( $this->crons ) ) { |
| 1919 | 1938 | return $this->crons; |
| 1920 | 1939 | } |
| 1921 | 1940 | |
| | 1941 | $late_timeout = 0; |
| | 1942 | $failed_timeout = -5 * MINUTE_IN_SECONDS; |
| | 1943 | $late_cron = false; |
| | 1944 | |
| | 1945 | if ( defined( 'DISABLE_WP_CRON' ) && true === DISABLE_WP_CRON ) { |
| | 1946 | $late_timeout = -15 * MINUTE_IN_SECONDS; |
| | 1947 | $failed_timeout = -1 * HOUR_IN_SECONDS; |
| | 1948 | } |
| | 1949 | |
| 1922 | 1950 | foreach ( $this->crons as $id => $cron ) { |
| 1923 | | if ( ( $cron->time - time() ) < 0 ) { |
| | 1951 | if ( ( $cron->time - time() ) < $failed_timeout ) { |
| | 1952 | $this->last_missed_cron = $cron->hook; |
| | 1953 | return 'failed'; |
| | 1954 | } elseif ( ( $cron->time - time() < $late_timeout ) ) { |
| 1924 | 1955 | $this->last_missed_cron = $cron->hook; |
| 1925 | | return true; |
| | 1956 | $late_cron = true; |
| 1926 | 1957 | } |
| 1927 | 1958 | } |
| 1928 | 1959 | |
| | 1960 | if ( true === $late_cron ) { |
| | 1961 | return 'late'; |
| | 1962 | } |
| | 1963 | |
| 1929 | 1964 | return false; |
| 1930 | 1965 | } |
| 1931 | 1966 | |