diff --git a/core/modules/system/src/SystemConfigSubscriber.php b/core/modules/system/src/SystemConfigSubscriber.php index 3c0de5f..e0a84a2 100644 --- a/core/modules/system/src/SystemConfigSubscriber.php +++ b/core/modules/system/src/SystemConfigSubscriber.php @@ -78,6 +78,40 @@ public function onConfigImporterValidateSiteUUID(ConfigImporterEvent $event) { } /** + * Checks for any pending database updates. + * + * As pending database update can cause issues as they potentially make + * changes code base and database. + * + * @see https://www.drupal.org/node/2628144 + * + * @param ConfigImporterEvent $event + * The config import event. + */ + public function onConfigImporterValidateDatabaseUpdate(ConfigImporterEvent $event) { + if ($this->hasModuleUpdates()) { + $event->getConfigImporter()->logError($this->t('Pending database updates available')); + } + } + + /** + * Checks if there any pending database updates. + * + * @return bool + * TRUE, if there any pending update on modules, FALSE otherwise. + */ + protected function hasModuleUpdates() { + $updates = update_get_update_list(); + foreach ($updates as $module => $update) { + if (isset($updates['start'])) { + return TRUE; + } + } + + return FALSE; + } + + /** * {@inheritdoc} */ public static function getSubscribedEvents() { @@ -86,6 +120,7 @@ public static function getSubscribedEvents() { // there is no configuration to import. $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateNotEmpty', 512); $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateSiteUUID', 256); + $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateDatabaseUpdate', 255); return $events; }