diff --git a/wp-admin/includes/class-wp-site-health.php b/wp-admin/includes/class-wp-site-health.php
index d8c097c93d..c17413b288 100644
a
|
b
|
class WP_Site_Health { |
11 | 11 | private $mysql_min_version_check; |
12 | 12 | private $mysql_rec_version_check; |
13 | 13 | |
14 | | public $is_mariadb = false; |
| 14 | public $is_mariadb = false; |
15 | 15 | private $mysql_server_version = ''; |
16 | 16 | private $health_check_mysql_required_version = '5.5'; |
17 | 17 | private $health_check_mysql_rec_version = ''; |
18 | 18 | |
19 | 19 | public $schedules; |
20 | 20 | public $crons; |
21 | | public $last_missed_cron = null; |
| 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' ) && 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 { |
1416 | 1427 | $this->has_missed_cron()->get_error_message() |
1417 | 1428 | ) |
1418 | 1429 | ); |
1419 | | } else { |
1420 | | if ( $this->has_missed_cron() ) { |
1421 | | $result['status'] = 'recommended'; |
| 1430 | } elseif ( $this->has_missed_cron() ) { |
| 1431 | $result['status'] = 'recommended'; |
1422 | 1432 | |
1423 | | $result['label'] = __( 'A scheduled event has failed' ); |
| 1433 | $result['label'] = __( 'A scheduled event has failed' ); |
1424 | 1434 | |
1425 | | $result['description'] = sprintf( |
1426 | | '<p>%s</p>', |
1427 | | sprintf( |
1428 | | /* translators: %s: The name of the failed cron event. */ |
1429 | | __( 'The scheduled event, %s, failed to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.' ), |
1430 | | $this->last_missed_cron |
1431 | | ) |
1432 | | ); |
1433 | | } |
| 1435 | $result['description'] = sprintf( |
| 1436 | '<p>%s</p>', |
| 1437 | sprintf( |
| 1438 | /* translators: %s: The name of the failed cron event. */ |
| 1439 | __( 'The scheduled event, %s, failed to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.' ), |
| 1440 | $this->last_missed_cron |
| 1441 | ) |
| 1442 | ); |
| 1443 | } elseif ( $this->has_late_cron() ) { |
| 1444 | $result['status'] = 'recommended'; |
| 1445 | |
| 1446 | $result['label'] = __( 'A scheduled event is late' ); |
| 1447 | |
| 1448 | $result['description'] = sprintf( |
| 1449 | '<p>%s</p>', |
| 1450 | sprintf( |
| 1451 | /* translators: %s: The name of the late cron event. */ |
| 1452 | __( '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.' ), |
| 1453 | $this->last_late_cron |
| 1454 | ) |
| 1455 | ); |
1434 | 1456 | } |
1435 | 1457 | |
1436 | 1458 | return $result; |
… |
… |
class WP_Site_Health { |
1926 | 1948 | } |
1927 | 1949 | |
1928 | 1950 | foreach ( $this->crons as $id => $cron ) { |
1929 | | if ( ( $cron->time - time() ) < 0 ) { |
| 1951 | if ( ( $cron->time - time() ) < $this->timeout_missed_cron ) { |
1930 | 1952 | $this->last_missed_cron = $cron->hook; |
1931 | 1953 | return true; |
1932 | 1954 | } |
… |
… |
class WP_Site_Health { |
1935 | 1957 | return false; |
1936 | 1958 | } |
1937 | 1959 | |
| 1960 | /** |
| 1961 | * Check if any scheduled tasks are late. |
| 1962 | * |
| 1963 | * Returns a boolean value of `true` if a scheduled task is late and ends processing. If the list of |
| 1964 | * crons is an instance of WP_Error, return the instance instead of a boolean value. |
| 1965 | * |
| 1966 | * @return bool|WP_Error true if a cron is late, false if it wasn't. WP_Error if the cron is set to that. |
| 1967 | */ |
| 1968 | public function has_late_cron() { |
| 1969 | if ( is_wp_error( $this->crons ) ) { |
| 1970 | return $this->crons; |
| 1971 | } |
| 1972 | |
| 1973 | $cron_late_time = $cron->time - time(); |
| 1974 | |
| 1975 | foreach ( $this->crons as $id => $cron ) { |
| 1976 | if ( $cron_late_time >= $this->timeout_missed_cron |
| 1977 | && ( $cron_late_time < $this->timeout_late_cron ) ) { |
| 1978 | $this->last_late_cron = $cron->hook; |
| 1979 | return true; |
| 1980 | } |
| 1981 | } |
| 1982 | |
| 1983 | return false; |
| 1984 | } |
| 1985 | |
1938 | 1986 | /** |
1939 | 1987 | * Run a loopback test on our site. |
1940 | 1988 | * |