Skip to content

Commit

Permalink
[CMS-392] Change cron message now that Pantheon is running cron on Wo…
Browse files Browse the repository at this point in the history
…rdPress sites (#111)

* Apply coding style

* Change cron check message now that Pantheon is running cron on WordPress sites.
  • Loading branch information
Ryan Marks authored Mar 24, 2022
1 parent eafb144 commit a1eeb95
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions php/pantheon/checks/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public function run() {

public function checkIsRegularCron() {
if ( defined("DISABLE_WP_CRON") and true == DISABLE_WP_CRON ) {
$this->alerts[] = array(
'class' => 'fail',
'message' => 'Cron appears to be disabled, make sure DISABLE_WP_CRON is not defined in your wp-config.php',
'code' => 2
$this->alerts[] = array(
'class' => 'pass',
'message' => 'WP-Cron is disabled. Pantheon is running `wp cron event run --due-now` once per hour.',
'code' => 0
);
} else {
$this->alerts[] = array(
'class' => 'pass',
'message' => 'Cron is enabled.',
'message' => 'WP-Cron is enabled. Pantheon is also running `wp cron event run --due-now` once per hour.',
'code' => 0,
);
}
Expand Down Expand Up @@ -91,19 +91,19 @@ public function checkCron() {
}

if ($invalid) {
$this->alerts[] = array(
'class' => 'fail',
'message' => "You have $invalid cron job(s) with an invalid time.",
$this->alerts[] = array(
'class' => 'fail',
'message' => "You have $invalid cron job(s) with an invalid time.",
'code' => 2
);
}
}
if ($overdue) {
$this->alerts[] = array(
'class' => 'pass',
'message' => "You have $past cron job(s) which are past due. Make sure that cron jobs are running on your site.",
'code' => 1
$this->alerts[] = array(
'class' => 'pass',
'message' => "You have $past cron job(s) which are past due. Make sure that cron jobs are running on your site.",
'code' => 1
);
}
}
$excessive_jobs = array();
foreach( $job_name_counts as $job_name => $count ) {
if ( $count > self::EXCESSIVE_DUPLICATE_JOBS ) {
Expand All @@ -118,10 +118,10 @@ public function checkCron() {
);
}
if ($total > self::MAX_CRON_DISPLAY) {
$this->alerts[] = array(
'class' => 'pass',
'message' => "You have $total cron jobs scheduled. This is too many to display and may indicate a problem with your site.",
'code' => 1
$this->alerts[] = array(
'class' => 'pass',
'message' => "You have $total cron jobs scheduled. This is too many to display and may indicate a problem with your site.",
'code' => 1
);
// Truncate the output.
// @TODO: Put a note next to the output table reiterating that these are not the full results.
Expand All @@ -146,19 +146,19 @@ public function message(Messenger $messenger) {
'class' => $label
);
}

$avg = $total/count($this->alerts);
$this->result = sprintf("%s\n%s", $this->description, View::make('checklist', array('rows' => $rows)));

// format the cron table
$rows = array();
if ($this->cron_rows) {
$headers = array(
$headers = array(
'jobname' => 'Job',
'schedule' => 'Frequency',
'next' => 'Next Run',
);

$this->result .= sprintf( "<hr/>%s",View::make('table', array('rows' => $this->cron_rows, 'headers' => $headers)));
$this->score = $avg;
}
Expand Down

0 comments on commit a1eeb95

Please sign in to comment.