Ticket #47223: 47223.diff
File 47223.diff, 2.2 KB (added by , 6 years ago) |
---|
-
wp-admin/includes/class-wp-site-health.php
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' ); … … 1425 1426 ) 1426 1427 ); 1427 1428 } 1429 else if ( 'late' === $has_missed_cron ) { 1430 $result['status'] = 'recommended'; 1431 1432 $result['label'] = __( 'A scheduled event is late' ); 1433 1434 $result['description'] = sprintf( 1435 '<p>%s</p>', 1436 sprintf( 1437 /* translators: %s: The name of the failed cron event. */ 1438 __( '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.' ), 1439 $this->last_missed_cron 1440 ) 1441 ); 1442 } 1428 1443 } 1429 1444 1430 1445 return $result; … … 1912 1927 * 1913 1928 * @since 5.2.0 1914 1929 * 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.1930 * @return bool|string|WP_Error false if no cron was missed, 'failed' if a cron failed to run, 'late' if a cron is late to run. WP_Error if the cron is set to that. 1916 1931 */ 1917 1932 public function has_missed_cron() { 1918 1933 if ( is_wp_error( $this->crons ) ) { 1919 1934 return $this->crons; 1920 1935 } 1921 1936 1937 $late_timeout = 0; 1938 $failed_timeout = -5 * MINUTE_IN_SECONDS; 1939 $late_cron = false; 1940 1941 if ( defined( 'DISABLE_WP_CRON' ) && true === DISABLE_WP_CRON ) { 1942 $late_timeout = -15 * MINUTE_IN_SECONDS; 1943 $failed_timeout = -HOUR_IN_SECONDS; 1944 } 1945 1922 1946 foreach ( $this->crons as $id => $cron ) { 1923 if ( ( $cron->time - time() ) < 0) {1947 if ( ( $cron->time - time() ) < $failed_timeout ) { 1924 1948 $this->last_missed_cron = $cron->hook; 1925 return true;1949 return 'failed'; 1926 1950 } 1951 else if ( ( $cron->time - time() < $late_timeout ) ) { 1952 $this->last_missed_cron = $cron->hook; 1953 $late_cron = true; 1954 } 1955 } 1956 1957 if ( true === $late_cron ) { 1958 return 'late'; 1927 1959 } 1928 1960 1929 1961 return false;