Commit 6d58240b authored by catch's avatar catch

Issue #2195957 by alexpott, tagini: Fixed Only install profile configuration...

Issue #2195957 by alexpott, tagini: Fixed Only install profile configuration when installing that profile, not when enabling associated modules.
parent 5f38198e
......@@ -9,6 +9,7 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\Site\Settings;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class ConfigInstaller implements ConfigInstallerInterface {
......@@ -105,8 +106,16 @@ public function installDefaultConfig($type, $name) {
// Read enabled extensions directly from configuration to avoid circular
// dependencies with ModuleHandler and ThemeHandler.
$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'));
// Core can provide configuration.
$enabled_extensions[] = 'core';
......@@ -284,8 +293,9 @@ public function resetSourceStorage() {
public function getSourceStorage($collection = StorageInterface::DEFAULT_COLLECTION) {
if (!isset($this->sourceStorage)) {
// Default to using the ExtensionInstallStorage which searches extension's
// config directories for default configuration.
$this->sourceStorage = new ExtensionInstallStorage($this->activeStorage, InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection);
// config directories for default configuration. Only include the profile
// configuration during Drupal installation.
$this->sourceStorage = new ExtensionInstallStorage($this->activeStorage, InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection, drupal_installation_attempted());
}
if ($this->sourceStorage->getCollectionName() != $collection) {
$this->sourceStorage = $this->sourceStorage->createCollection($collection);
......
......@@ -7,6 +7,8 @@
namespace Drupal\Core\Config;
use Drupal\Core\Site\Settings;
/**
* Storage to access configuration and schema in enabled extensions.
*
......@@ -22,6 +24,13 @@ class ExtensionInstallStorage extends InstallStorage {
*/
protected $configStorage;
/**
* Flag to include the profile in the list of enabled modules.
*
* @var bool
*/
protected $includeProfile = TRUE;
/**
* Overrides \Drupal\Core\Config\InstallStorage::__construct().
*
......@@ -34,11 +43,15 @@ class ExtensionInstallStorage extends InstallStorage {
* @param string $collection
* (optional) The collection to store configuration in. Defaults to the
* 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->directory = $directory;
$this->collection = $collection;
$this->includeProfile = $include_profile;
}
/**
......@@ -71,7 +84,13 @@ protected function getAllFolders() {
$extensions = $this->configStorage->read('core.extension');
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'])) {
$this->folders += $this->getComponentNames('theme', array_keys($extensions['theme']));
......
......@@ -100,6 +100,18 @@ function testStandard() {
$config = $factory->get($name);
$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