diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php
index 12e127353b..dc70812bd8 100644
a
|
b
|
class WP_Site_Health { |
16 | 16 | private $health_check_mysql_required_version = '5.5'; |
17 | 17 | private $health_check_mysql_rec_version = ''; |
18 | 18 | |
19 | | public $schedules; |
20 | | public $crons; |
21 | | public $last_missed_cron = null; |
| 19 | public $schedules; |
| 20 | public $crons; |
| 21 | public $last_missed_cron = null; |
| 22 | public $last_late_cron = null; |
| 23 | private $timeout_missed_cron = null; |
| 24 | private $timeout_late_cron = null; |
22 | 25 | |
23 | 26 | /** |
24 | 27 | * WP_Site_Health constructor. |
… |
… |
class WP_Site_Health { |
28 | 31 | public function __construct() { |
29 | 32 | $this->prepare_sql_data(); |
30 | 33 | |
| 34 | $this->timeout_late_cron = 0; |
| 35 | $this->timeout_missed_cron = - 5 * MINUTE_IN_SECONDS; |
| 36 | |
| 37 | if ( defined( 'DISABLE_WP_CRON' ) && true === DISABLE_WP_CRON ) { |
| 38 | $this->timeout_late_cron = - 15 * MINUTE_IN_SECONDS; |
| 39 | $this->timeout_missed_cron = - 1 * HOUR_IN_SECONDS; |
| 40 | } |
| 41 | |
31 | 42 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
32 | 43 | |
33 | 44 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
… |
… |
class WP_Site_Health { |
1424 | 1435 | $this->last_missed_cron |
1425 | 1436 | ) |
1426 | 1437 | ); |
| 1438 | } else if ( $this->has_late_cron() ) { |
| 1439 | $result['status'] = 'recommended'; |
| 1440 | |
| 1441 | $result['label'] = __( 'A scheduled event is late' ); |
| 1442 | |
| 1443 | $result['description'] = sprintf( |
| 1444 | '<p>%s</p>', |
| 1445 | sprintf( |
| 1446 | /* translators: %s: The name of the failed cron event. */ |
| 1447 | __( '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.' ), |
| 1448 | $this->last_late_cron |
| 1449 | ) |
| 1450 | ); |
1427 | 1451 | } |
1428 | 1452 | } |
1429 | 1453 | |
… |
… |
class WP_Site_Health { |
1920 | 1944 | } |
1921 | 1945 | |
1922 | 1946 | foreach ( $this->crons as $id => $cron ) { |
1923 | | if ( ( $cron->time - time() ) < 0 ) { |
| 1947 | if ( ( $cron->time - time() ) < $this->timeout_missed_cron ) { |
1924 | 1948 | $this->last_missed_cron = $cron->hook; |
1925 | 1949 | return true; |
1926 | 1950 | } |
… |
… |
class WP_Site_Health { |
1929 | 1953 | return false; |
1930 | 1954 | } |
1931 | 1955 | |
| 1956 | /** |
| 1957 | * Check if any scheduled tasks are late. |
| 1958 | * |
| 1959 | * Returns a boolean value of `true` if a scheduled task is late and ends processing. If the list of |
| 1960 | * crons is an instance of WP_Error, return the instance instead of a boolean value. |
| 1961 | * |
| 1962 | * @return bool|WP_Error true if a cron is late, false if it wasn't. WP_Error if the cron is set to that. |
| 1963 | */ |
| 1964 | public function has_late_cron() { |
| 1965 | if ( is_wp_error( $this->crons ) ) { |
| 1966 | return $this->crons; |
| 1967 | } |
| 1968 | |
| 1969 | foreach ( $this->crons as $id => $cron ) { |
| 1970 | if ( ( $cron->time - time() ) >= $this->timeout_missed_cron |
| 1971 | && ( $cron->time - time() < $this->timeout_late_cron ) ) { |
| 1972 | $this->last_late_cron = $cron->hook; |
| 1973 | return true; |
| 1974 | } |
| 1975 | } |
| 1976 | |
| 1977 | return false; |
| 1978 | } |
| 1979 | |
1932 | 1980 | /** |
1933 | 1981 | * Run a loopback test on our site. |
1934 | 1982 | * |