Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / EventSubscriber / ConfigImportSubscriber.php
index ea7d29fedfc176c86efa9a89684a6e0fb3bebcb0..c0e3a4a2c8b4009cc5a00422855c88d1b8f7930c 100644 (file)
@@ -84,6 +84,29 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
    */
   protected function validateModules(ConfigImporter $config_importer) {
     $core_extension = $config_importer->getStorageComparer()->getSourceStorage()->read('core.extension');
+
+    // Get the install profile from the site's configuration.
+    $current_core_extension = $config_importer->getStorageComparer()->getTargetStorage()->read('core.extension');
+    $install_profile = isset($current_core_extension['profile']) ? $current_core_extension['profile'] : NULL;
+
+    // Ensure the profile is not changing.
+    if ($install_profile !== $core_extension['profile']) {
+      if (drupal_installation_attempted()) {
+        $config_importer->logError($this->t('The selected installation profile %install_profile does not match the profile stored in configuration %config_profile.', [
+          '%install_profile' => $install_profile,
+          '%config_profile' => $core_extension['profile'],
+        ]));
+        // If this error has occurred the other checks are irrelevant.
+        return;
+      }
+      else {
+        $config_importer->logError($this->t('Cannot change the install profile from %profile to %new_profile once Drupal is installed.', [
+          '%profile' => $install_profile,
+          '%new_profile' => $core_extension['profile'],
+        ]));
+      }
+    }
+
     // Get a list of modules with dependency weights as values.
     $module_data = $this->getModuleData();
     $nonexistent_modules = array_keys(array_diff_key($core_extension['module'], $module_data));
@@ -111,10 +134,6 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
       }
     }
 
-    // Get the install profile from the site's configuration.
-    $current_core_extension = $config_importer->getStorageComparer()->getTargetStorage()->read('core.extension');
-    $install_profile = isset($current_core_extension['profile']) ? $current_core_extension['profile'] : NULL;
-
     // Ensure that all modules being uninstalled are not required by modules
     // that will be installed after the import.
     $uninstalls = $config_importer->getExtensionChangelist('module', 'uninstall');
@@ -133,11 +152,6 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
       $profile_name = $module_data[$install_profile]->info['name'];
       $config_importer->logError($this->t('Unable to uninstall the %profile profile since it is the install profile.', ['%profile' => $profile_name]));
     }
-
-    // Ensure the profile is not changing.
-    if ($install_profile !== $core_extension['profile']) {
-      $config_importer->logError($this->t('Cannot change the install profile from %profile to %new_profile once Drupal is installed.', ['%profile' => $install_profile, '%new_profile' => $core_extension['profile']]));
-    }
   }
 
   /**
@@ -214,19 +228,19 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
         if (!isset($core_extension['module'][$owner]) && isset($module_data[$owner])) {
           $message = $this->t('Configuration %name depends on the %owner module that will not be installed after import.', [
             '%name' => $name,
-            '%owner' => $module_data[$owner]->info['name']
+            '%owner' => $module_data[$owner]->info['name'],
           ]);
         }
         elseif (!isset($core_extension['theme'][$owner]) && isset($theme_data[$owner])) {
           $message = $this->t('Configuration %name depends on the %owner theme that will not be installed after import.', [
             '%name' => $name,
-            '%owner' => $theme_data[$owner]->info['name']
+            '%owner' => $theme_data[$owner]->info['name'],
           ]);
         }
         elseif (!isset($core_extension['module'][$owner]) && !isset($core_extension['theme'][$owner])) {
           $message = $this->t('Configuration %name depends on the %owner extension that will not be installed after import.', [
             '%name' => $name,
-            '%owner' => $owner
+            '%owner' => $owner,
           ]);
         }