Commit 5ab43b6a authored by catch's avatar catch

Issue #2195957 by Wim Leers, alexpott: Fixed Only install profile...

Issue #2195957 by Wim Leers, alexpott: Fixed Only install profile configuration when installing that profile, not when enabling associated modules.
parent 4b9f358a
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\Entity\ConfigDependencyManager; use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\Site\Settings;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class ConfigInstaller implements ConfigInstallerInterface { class ConfigInstaller implements ConfigInstallerInterface {
...@@ -105,8 +106,16 @@ public function installDefaultConfig($type, $name) { ...@@ -105,8 +106,16 @@ public function installDefaultConfig($type, $name) {
// Read enabled extensions directly from configuration to avoid circular // Read enabled extensions directly from configuration to avoid circular
// dependencies with ModuleHandler and ThemeHandler. // dependencies with ModuleHandler and ThemeHandler.
$extension_config = $this->configFactory->get('core.extension'); $extension_config = $this->configFactory->get('core.extension');
$enabled_extensions = array_keys((array) $extension_config->get('module')); $modules = (array) $extension_config->get('module');
// Unless we are installing the profile, remove it from the list.
if ($install_profile = Settings::get('install_profile')) {
if ($name !== $install_profile) {
unset($modules[$install_profile]);
}
}
$enabled_extensions = array_keys($modules);
$enabled_extensions += array_keys((array) $extension_config->get('theme')); $enabled_extensions += array_keys((array) $extension_config->get('theme'));
// Core can provide configuration. // Core can provide configuration.
$enabled_extensions[] = 'core'; $enabled_extensions[] = 'core';
...@@ -284,8 +293,9 @@ public function resetSourceStorage() { ...@@ -284,8 +293,9 @@ public function resetSourceStorage() {
public function getSourceStorage($collection = StorageInterface::DEFAULT_COLLECTION) { public function getSourceStorage($collection = StorageInterface::DEFAULT_COLLECTION) {
if (!isset($this->sourceStorage)) { if (!isset($this->sourceStorage)) {
// Default to using the ExtensionInstallStorage which searches extension's // Default to using the ExtensionInstallStorage which searches extension's
// config directories for default configuration. // config directories for default configuration. Only include the profile
$this->sourceStorage = new ExtensionInstallStorage($this->activeStorage, InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection); // configuration during Drupal installation.
$this->sourceStorage = new ExtensionInstallStorage($this->activeStorage, InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection, drupal_installation_attempted());
} }
if ($this->sourceStorage->getCollectionName() != $collection) { if ($this->sourceStorage->getCollectionName() != $collection) {
$this->sourceStorage = $this->sourceStorage->createCollection($collection); $this->sourceStorage = $this->sourceStorage->createCollection($collection);
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Core\Site\Settings;
/** /**
* Storage to access configuration and schema in enabled extensions. * Storage to access configuration and schema in enabled extensions.
* *
...@@ -22,6 +24,13 @@ class ExtensionInstallStorage extends InstallStorage { ...@@ -22,6 +24,13 @@ class ExtensionInstallStorage extends InstallStorage {
*/ */
protected $configStorage; protected $configStorage;
/**
* Flag to include the profile in the list of enabled modules.
*
* @var bool
*/
protected $includeProfile = TRUE;
/** /**
* Overrides \Drupal\Core\Config\InstallStorage::__construct(). * Overrides \Drupal\Core\Config\InstallStorage::__construct().
* *
...@@ -34,11 +43,15 @@ class ExtensionInstallStorage extends InstallStorage { ...@@ -34,11 +43,15 @@ class ExtensionInstallStorage extends InstallStorage {
* @param string $collection * @param string $collection
* (optional) The collection to store configuration in. Defaults to the * (optional) The collection to store configuration in. Defaults to the
* default collection. * default collection.
* @param bool $include_profile
* (optional) Whether to include the install profile in extensions to
* search.
*/ */
public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION) { public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION, $include_profile = TRUE) {
$this->configStorage = $config_storage; $this->configStorage = $config_storage;
$this->directory = $directory; $this->directory = $directory;
$this->collection = $collection; $this->collection = $collection;
$this->includeProfile = $include_profile;
} }
/** /**
...@@ -71,7 +84,13 @@ protected function getAllFolders() { ...@@ -71,7 +84,13 @@ protected function getAllFolders() {
$extensions = $this->configStorage->read('core.extension'); $extensions = $this->configStorage->read('core.extension');
if (!empty($extensions['module'])) { if (!empty($extensions['module'])) {
$this->folders += $this->getComponentNames('module', array_keys($extensions['module'])); $modules = $extensions['module'];
if (!$this->includeProfile) {
if ($install_profile = Settings::get('install_profile')) {
unset($modules[$install_profile]);
}
}
$this->folders += $this->getComponentNames('module', array_keys($modules));
} }
if (!empty($extensions['theme'])) { if (!empty($extensions['theme'])) {
$this->folders += $this->getComponentNames('theme', array_keys($extensions['theme'])); $this->folders += $this->getComponentNames('theme', array_keys($extensions['theme']));
......
...@@ -100,6 +100,18 @@ function testStandard() { ...@@ -100,6 +100,18 @@ function testStandard() {
$config = $factory->get($name); $config = $factory->get($name);
$this->assertConfigSchema($typed_config, $name, $config->get()); $this->assertConfigSchema($typed_config, $name, $config->get());
} }
// Ensure that configuration from the Standard profile is not reused when
// enabling a module again since it contains configuration that can not be
// installed. For example, editor.editor.basic_html is editor configuration
// that depends on the ckeditor module. The ckeditor module can not be
// installed before the editor module since it depends on the editor module.
// The installer does not have this limitation since it ensures that all of
// the install profiles dependencies are installed before creating the
// editor configuration.
\Drupal::moduleHandler()->uninstall(array('editor', 'ckeditor'));
$this->rebuildContainer();
\Drupal::moduleHandler()->install(array('editor'));
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment