You are here

public static function ReadinessCheckerManager::run in Automatic Updates 7

Run checks.

Parameters

string $category: The category of check.

Return value

array An array of translatable strings.

2 calls to ReadinessCheckerManager::run()
automatic_updates_cron in ./automatic_updates.module
Implements hook_cron().
automatic_updates_run_checks in ./automatic_updates.admin.inc
Page callback to run all checkers.

File

ReadinessCheckers/ReadinessCheckerManager.php, line 48

Class

ReadinessCheckerManager
Defines a chained readiness checker implementation combining multiple checks.

Code

public static function run($category) {
  $messages = [];
  if (!static::isEnabled()) {
    return $messages;
  }
  if (!isset(static::getSortedCheckers()[$category])) {
    throw new \InvalidArgumentException(sprintf('No readiness checkers exist of category "%s"', $category));
  }
  foreach (static::getSortedCheckers()[$category] as $checker) {
    $messages[] = $checker::run();
  }
  $messages = array_merge(...$messages);

  // Guard against variable_set stampede by checking if the values have
  // changed since previous run.
  $previous_messages = variable_get("automatic_updates.readiness_check_results.{$category}");
  if ($previous_messages !== $messages) {
    variable_set("automatic_updates.readiness_check_results.{$category}", $messages);
  }
  if (variable_get('automatic_updates.readiness_check_timestamp') !== REQUEST_TIME) {
    variable_set('automatic_updates.readiness_check_timestamp', REQUEST_TIME);
  }
  return $messages;
}