PendingDbUpdates.php in Automatic Updates 8
File
src/ReadinessChecker/PendingDbUpdates.php
View source
<?php
namespace Drupal\automatic_updates\ReadinessChecker;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Update\UpdateRegistry;
class PendingDbUpdates implements ReadinessCheckerInterface {
use StringTranslationTrait;
protected $updateRegistry;
public function __construct(UpdateRegistry $update_registry) {
$this->updateRegistry = $update_registry;
}
public function run() {
$messages = [];
if ($this
->areDbUpdatesPending()) {
$messages[] = $this
->t('There are pending database updates. Please run update.php.');
}
return $messages;
}
protected function areDbUpdatesPending() {
require_once DRUPAL_ROOT . '/core/includes/install.inc';
require_once DRUPAL_ROOT . '/core/includes/update.inc';
drupal_load_updates();
$hook_updates = update_get_update_list();
$post_updates = $this->updateRegistry
->getPendingUpdateFunctions();
return (bool) array_merge($hook_updates, $post_updates);
}
}