Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status Check - Report the overall status (accurately) #24027

Merged
merged 2 commits into from
Jul 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions CRM/Utils/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,6 @@ public function showPeriodicAlerts() {
}
}

/**
* Sort messages based upon severity
*
* @param CRM_Utils_Check_Message $a
* @param CRM_Utils_Check_Message $b
* @return int
*/
public static function severitySort($a, $b) {
$aSeverity = $a->getLevel();
$bSeverity = $b->getLevel();
if ($aSeverity == $bSeverity) {
return strcmp($a->getName(), $b->getName());
}
// The Message constructor guarantees that these will always be integers.
return ($aSeverity <=> $bSeverity);
}

/**
* Get the integer value (useful for thresholds) of the severity.
*
Expand Down Expand Up @@ -201,15 +184,11 @@ public function assertValid($messages = NULL, $threshold = \Psr\Log\LogLevel::ER
public static function checkAll($max = FALSE) {
$messages = self::checkStatus();

uasort($messages, [__CLASS__, 'severitySort']);

$maxSeverity = 1;
foreach ($messages as $message) {
if (!$message->isVisible()) {
continue;
if ($message->isVisible()) {
$maxSeverity = max($maxSeverity, $message->getLevel());
}
$maxSeverity = max(1, $message->getLevel());
break;
}

Civi::cache('checks')->set('systemStatusCheckResult', $maxSeverity);
Expand Down