diff --git a/core/includes/config.inc b/core/includes/config.inc index 56364a8..d1bbb83 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -41,8 +41,10 @@ * @see \Drupal\Core\Config\ConfigInstaller */ function config_install_default_config($type, $name) { - // Get all default configuration owned by this extension. - $source_storage = new ExtensionInstallStorage(); + // Get all default configuration owned by this extension. During installation + // this should include config from the installation profile. During normal + // runtime the installation profile should be ignored. + $source_storage = new ExtensionInstallStorage(drupal_get_profile(), drupal_installation_attempted()); $config_to_install = $source_storage->listAll($name . '.'); // Work out if this extension provides default configuration for any other diff --git a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php index 689b14d..45b14d0 100644 --- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -16,6 +16,36 @@ class ExtensionInstallStorage extends InstallStorage { /** + * Include profile config directories + *. + * @var bool + */ + protected $includeProfile; + + /** + * The installation profile. + * + * @var string + */ + protected $profile; + + /** + * Constructs a new FileStorage controller. + * + * @param string $profile + * The name of the installation profile used on the site. + * @param bool $include_profile + * If TRUE, include default configuration from the installation profile's + * config directory. + * + * Overrides Drupal\Core\Config\FileStorage::__construct(). + */ + public function __construct($profile, $include_profile = FALSE) { + $this->includeProfile = $include_profile; + $this->profile = $profile; + } + + /** * Returns a map of all config object names and their folders. * * The list is based on enabled modules and themes. @@ -25,7 +55,13 @@ class ExtensionInstallStorage extends InstallStorage { */ protected function getAllFolders() { if (!isset($this->folders)) { - $this->folders = $this->getComponentNames('module', array_keys(\Drupal::moduleHandler()->getModuleList())); + $module_list = \Drupal::moduleHandler()->getModuleList(); + // Only include the profile module's config if $this->includeProfile is + // set to TRUE. + if (!$this->includeProfile && isset($module_list[$this->profile])) { + unset($module_list[$this->profile]); + } + $this->folders = $this->getComponentNames('module', array_keys($module_list)); $this->folders += $this->getComponentNames('theme', array_keys(array_filter(list_themes(), function ($theme) {return $theme->status;}))); } return $this->folders; diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php index 37ad031..079a2a0 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareStandardUpgradePathTest.php @@ -86,5 +86,24 @@ public function testBasicStandardUpgrade() { $this->assertEqual($blog_type->module, 'node', "Content type 'blog' has been reassigned from the blog module to the node module."); $this->assertEqual($blog_type->base, 'node_content', "The base string used to construct callbacks corresponding to content type 'Blog' has been reassigned to 'node_content'."); + // Get enabled modules. + $enabled = \Drupal::moduleHandler()->getModuleList(); + // Get all available modules. + $available = system_rebuild_module_data(); + // Filter out hidden test modules. + foreach ($available as $module => $data) { + if (!empty($data->info['hidden'])) { + unset($available[$module]); + } + } + $to_enable = array_diff_key($available, $enabled); + // Try enabling all available modules to ensure that this works after an + // upgrade. This tests that the standard profile default configuration is + // ignored during upgrade and normal module enable. It should only be used + // during installation. This can cause problems when the configuration + // depends on multiple modules that also have a dependency. For example, + // editor.editor.full_html.yml and the Ckeditor and Editor modules. + $this->container->get('module_handler')->enable(array_keys($to_enable)); + } }