You are here

public function PendingUpdatesValidator::checkPendingUpdates in Automatic Updates 8.2

Validates that there are no pending database updates.

Parameters

\Drupal\automatic_updates\Event\UpdateEvent $event: The update event.

File

src/Validator/PendingUpdatesValidator.php, line 57

Class

PendingUpdatesValidator
Validates that there are no pending database updates.

Namespace

Drupal\automatic_updates\Validator

Code

public function checkPendingUpdates(UpdateEvent $event) {
  require_once $this->appRoot . '/core/includes/install.inc';
  require_once $this->appRoot . '/core/includes/update.inc';
  drupal_load_updates();
  $hook_updates = update_get_update_list();
  $post_updates = $this->updateRegistry
    ->getPendingUpdateFunctions();
  if ($hook_updates || $post_updates) {
    $message = $this
      ->t('Some modules have database schema updates to install. You should run the <a href=":update">database update script</a> immediately.', [
      ':update' => Url::fromRoute('system.db_update')
        ->toString(),
    ]);
    $error = ValidationResult::createError([
      $message,
    ]);
    $event
      ->addValidationResult($error);
  }
}