diff -u b/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php --- b/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -179,6 +179,7 @@ $this->processedExtensions = $this->getEmptyExtensionsProcessedList(); $this->createExtensionChangelist(); $this->validated = FALSE; + $this->processedSystemTheme = FALSE; return $this; } @@ -407,7 +408,7 @@ throw new ConfigImporterException(sprintf('%s is already importing', static::LOCK_ID)); } - // Where to put this? + // Process any extension changes before importing configuration. $this->handleExtensions(); // First pass deleted, then new, and lastly changed configuration, in order diff -u b/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php --- b/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -147,12 +147,10 @@ // If we are syncing do not create configuration entities. Pluggable // configuration entities can have dependencies on modules that are - // not yet enabled. In the absence of dependency management for config - // entities this is a good as we can do. The problem with this - // approach is that any code that expects default configuration - // entities to exist (even if there is code the prevents this from - // happening) will be unstable after the module has been enabled and - // before the config entity has been imported. + // not yet enabled. This approach means that any code that expects + // default configuration entities to exist will be unstable after the + // module has been enabled and before the config entity has been + // imported. if ($this->isSyncing) { continue; } diff -u b/core/lib/Drupal/Core/Config/StorageComparer.php b/core/lib/Drupal/Core/Config/StorageComparer.php --- b/core/lib/Drupal/Core/Config/StorageComparer.php +++ b/core/lib/Drupal/Core/Config/StorageComparer.php @@ -6,6 +6,8 @@ */ namespace Drupal\Core\Config; + +use Drupal\Component\Utility\String; use Drupal\Core\Config\Entity\ConfigDependencyManager; /** @@ -119,14 +121,21 @@ * @param array $changes * Array of changes to add to the changelist. * @param array $sort_order - * Array to sort that can be used to sort the changelist. + * Array to sort that can be used to sort the changelist. This array must + * contain all the items that are in the change list. */ protected function addChangeList($op, array $changes, array $sort_order = NULL) { // Only add changes that aren't already listed. $changes = array_diff($changes, $this->changelist[$op]); $this->changelist[$op] = array_merge($this->changelist[$op], $changes); - if (!empty($sort_order)) { - $this->changelist[$op] = array_intersect($sort_order, $this->changelist[$op]); + if (isset($sort_order)) { + $count = count($this->changelist[$op]); + // Sort the changlist in the same order as the $sort_order array and + // ensure the array is keyed from 0. + $this->changelist[$op] = array_values(array_intersect($sort_order, $this->changelist[$op])); + if ($count != count($this->changelist[$op])) { + throw \InvalidArgumentException(String::format('Sorting the @op changelist should not change its length.', array('@op' => $op))); + } } } diff -u b/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php --- b/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -146,8 +146,12 @@ // Refresh the theme list as installation of default configuration needs // an updated list to work. $this->reset(); - // If we're not in a config synchronisation reset the source storage so - // that the extension install storage will pick up the new configuration. + + // The default config installation storage only knows about the currently + // enabled list of themes, so it has to be reset in order to pick up the + // default config of the newly installed theme. However, do not reset the + // source storage when synchronizing configuration, since that would + // needlessly trigger a reload of the whole configuration to be imported. if (!$this->configInstaller->isSyncing()) { $this->configInstaller->resetSourceStorage(); } diff -u b/core/modules/config/tests/config_import_test/config_import_test.services.yml b/core/modules/config/tests/config_import_test/config_import_test.services.yml --- b/core/modules/config/tests/config_import_test/config_import_test.services.yml +++ b/core/modules/config/tests/config_import_test/config_import_test.services.yml @@ -6 +6 @@ - arguments: ['@state'] \ No newline at end of file + arguments: ['@state']