Commit ef809cba authored by catch's avatar catch

Revert "Issue #2156401 by alexpott, moshe weitzman, tedbow, dawehner,...

Revert "Issue #2156401 by alexpott, moshe weitzman, tedbow, dawehner, greg.1.anderson, phenaproxima, chris.smith, heddn, balsama, xjm, Mile23, izus, Manuel Garcia, sun, pwolanin, Berdir: Write install_profile value to configuration and only to settings.php if it is writeable"

This reverts commit 480eb82c.
parent 11c92ce9
module: {} module: {}
theme: {} theme: {}
profile: ''
...@@ -14,6 +14,3 @@ core.extension: ...@@ -14,6 +14,3 @@ core.extension:
sequence: sequence:
type: integer type: integer
label: 'Weight' label: 'Weight'
profile:
type: string
label: 'Install profile'
...@@ -303,7 +303,7 @@ services: ...@@ -303,7 +303,7 @@ services:
- { name: event_subscriber } - { name: event_subscriber }
config.installer: config.installer:
class: Drupal\Core\Config\ConfigInstaller class: Drupal\Core\Config\ConfigInstaller
arguments: ['@config.factory', '@config.storage', '@config.typed', '@config.manager', '@event_dispatcher', '%install_profile%'] arguments: ['@config.factory', '@config.storage', '@config.typed', '@config.manager', '@event_dispatcher']
lazy: true lazy: true
config.storage: config.storage:
class: Drupal\Core\Config\CachedStorage class: Drupal\Core\Config\CachedStorage
...@@ -328,7 +328,7 @@ services: ...@@ -328,7 +328,7 @@ services:
- { name: backend_overridable } - { name: backend_overridable }
config.storage.schema: config.storage.schema:
class: Drupal\Core\Config\ExtensionInstallStorage class: Drupal\Core\Config\ExtensionInstallStorage
arguments: ['@config.storage', '%install_profile%', 'config/schema'] arguments: ['@config.storage', 'config/schema']
config.typed: config.typed:
class: Drupal\Core\Config\TypedConfigManager class: Drupal\Core\Config\TypedConfigManager
arguments: ['@config.storage', '@config.storage.schema', '@cache.discovery', '@module_handler'] arguments: ['@config.storage', '@config.storage.schema', '@cache.discovery', '@module_handler']
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\BootstrapConfigStorageFactory;
use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Logger\RfcLogLevel;
use Drupal\Core\Render\Markup; use Drupal\Core\Render\Markup;
use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Render\MarkupInterface;
...@@ -728,20 +727,12 @@ function drupal_installation_attempted() { ...@@ -728,20 +727,12 @@ function drupal_installation_attempted() {
* When this function is called during Drupal's initial installation process, * When this function is called during Drupal's initial installation process,
* the name of the profile that's about to be installed is stored in the global * the name of the profile that's about to be installed is stored in the global
* installation state. At all other times, the "install_profile" setting will be * installation state. At all other times, the "install_profile" setting will be
* available in container as a parameter. * available in settings.php.
* *
* @return string|null $profile * @return string|null $profile
* The name of the installation profile or NULL if no installation profile is * The name of the installation profile or NULL if no installation profile is
* currently active. This is the case for example during the first steps of * currently active. This is the case for example during the first steps of
* the installer or during unit tests. * the installer or during unit tests.
*
* @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0.
* Use the install_profile container parameter or \Drupal::installProfile()
* instead. If you are accessing the value before it is written to
* configuration during the installer use the $install_state global. If you
* need to access the value before container is available you can use
* BootstrapConfigStorageFactory to load the value directly from
* configuration.
*/ */
function drupal_get_profile() { function drupal_get_profile() {
global $install_state; global $install_state;
...@@ -756,18 +747,8 @@ function drupal_get_profile() { ...@@ -756,18 +747,8 @@ function drupal_get_profile() {
} }
} }
else { else {
if (\Drupal::hasContainer()) { // Fall back to NULL, if there is no 'install_profile' setting.
$profile = \Drupal::installProfile(); $profile = Settings::get('install_profile');
}
else {
$profile = BootstrapConfigStorageFactory::getDatabaseStorage()->read('core.extension')['profile'];
}
// A BC layer just in in case this only exists in Settings. Introduced in
// Drupal 8.3.x and will be removed before Drupal 9.0.0.
if (empty($profile)) {
$profile = Settings::get('install_profile');
}
} }
return $profile; return $profile;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormState;
use Drupal\Core\Installer\Exception\AlreadyInstalledException; use Drupal\Core\Installer\Exception\AlreadyInstalledException;
use Drupal\Core\Installer\Exception\InstallerException; use Drupal\Core\Installer\Exception\InstallerException;
use Drupal\Core\Installer\Exception\InstallProfileMismatchException;
use Drupal\Core\Installer\Exception\NoProfilesException; use Drupal\Core\Installer\Exception\NoProfilesException;
use Drupal\Core\Installer\InstallerKernel; use Drupal\Core\Installer\InstallerKernel;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
...@@ -2173,23 +2172,13 @@ function install_display_requirements($install_state, $requirements) { ...@@ -2173,23 +2172,13 @@ function install_display_requirements($install_state, $requirements) {
} }
/** /**
* Installation task; writes profile to settings.php if possible. * Installation task; ensures install profile is written to settings.php.
* *
* @param array $install_state * @param array $install_state
* An array of information about the current installation state. * An array of information about the current installation state.
*
* @see _install_select_profile()
*
* @throws \Drupal\Core\Installer\Exception\InstallProfileMismatchException
*
* @deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0. The
* install profile is written to core.extension.
*/ */
function install_write_profile($install_state) { function install_write_profile($install_state) {
// Only need to write to settings.php if it is possible. The primary storage if (Settings::get('install_profile') !== $install_state['parameters']['profile']) {
// for the install profile is the core.extension configuration.
$settings_path = \Drupal::service('site.path') . '/settings.php';
if (is_writable($settings_path)) {
// Remember the profile which was used. // Remember the profile which was used.
$settings['settings']['install_profile'] = (object) array( $settings['settings']['install_profile'] = (object) array(
'value' => $install_state['parameters']['profile'], 'value' => $install_state['parameters']['profile'],
...@@ -2197,7 +2186,4 @@ function install_write_profile($install_state) { ...@@ -2197,7 +2186,4 @@ function install_write_profile($install_state) {
); );
drupal_rewrite_settings($settings); drupal_rewrite_settings($settings);
} }
elseif (($settings_profile = Settings::get('install_profile')) && $settings_profile !== $install_state['parameters']['profile']) {
throw new InstallProfileMismatchException($install_state['parameters']['profile'], $settings_profile, $settings_path, \Drupal::translation());
}
} }
...@@ -621,12 +621,6 @@ function drupal_install_system($install_state) { ...@@ -621,12 +621,6 @@ function drupal_install_system($install_state) {
// Install base system configuration. // Install base system configuration.
\Drupal::service('config.installer')->installDefaultConfig('core', 'core'); \Drupal::service('config.installer')->installDefaultConfig('core', 'core');
// Store the installation profile in configuration to populate the
// 'install_profile' container parameter.
\Drupal::configFactory()->getEditable('core.extension')
->set('profile', $install_state['parameters']['profile'])
->save();
// Install System module and rebuild the newly available routes. // Install System module and rebuild the newly available routes.
$kernel->getContainer()->get('module_installer')->install(array('system'), FALSE); $kernel->getContainer()->get('module_installer')->install(array('system'), FALSE);
\Drupal::service('router.builder')->rebuild(); \Drupal::service('router.builder')->rebuild();
......
...@@ -181,16 +181,6 @@ public static function root() { ...@@ -181,16 +181,6 @@ public static function root() {
return static::getContainer()->get('app.root'); return static::getContainer()->get('app.root');
} }
/**
* Gets the active install profile.
*
* @return string|null
* The name of the active install profile.
*/
public static function installProfile() {
return static::getContainer()->getParameter('install_profile');
}
/** /**
* Indicates if there is a currently active request object. * Indicates if there is a currently active request object.
* *
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,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\Config\Entity\ConfigEntityDependency; use Drupal\Core\Config\Entity\ConfigEntityDependency;
use Drupal\Core\Site\Settings;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class ConfigInstaller implements ConfigInstallerInterface { class ConfigInstaller implements ConfigInstallerInterface {
...@@ -59,13 +60,6 @@ class ConfigInstaller implements ConfigInstallerInterface { ...@@ -59,13 +60,6 @@ class ConfigInstaller implements ConfigInstallerInterface {
*/ */
protected $isSyncing = FALSE; protected $isSyncing = FALSE;
/**
* The name of the currently active installation profile.
*
* @var string
*/
protected $installProfile;
/** /**
* Constructs the configuration installer. * Constructs the configuration installer.
* *
...@@ -79,16 +73,13 @@ class ConfigInstaller implements ConfigInstallerInterface { ...@@ -79,16 +73,13 @@ class ConfigInstaller implements ConfigInstallerInterface {
* The configuration manager. * The configuration manager.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher. * The event dispatcher.
* @param string $install_profile
* The name of the currently active installation profile.
*/ */
public function __construct(ConfigFactoryInterface $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher, $install_profile) { public function __construct(ConfigFactoryInterface $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher) {
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
$this->activeStorages[$active_storage->getCollectionName()] = $active_storage; $this->activeStorages[$active_storage->getCollectionName()] = $active_storage;
$this->typedConfig = $typed_config; $this->typedConfig = $typed_config;
$this->configManager = $config_manager; $this->configManager = $config_manager;
$this->eventDispatcher = $event_dispatcher; $this->eventDispatcher = $event_dispatcher;
$this->installProfile = $install_profile;
} }
/** /**
...@@ -149,7 +140,7 @@ public function installDefaultConfig($type, $name) { ...@@ -149,7 +140,7 @@ public function installDefaultConfig($type, $name) {
// Install any optional configuration entities whose dependencies can now // Install any optional configuration entities whose dependencies can now
// be met. This searches all the installed modules config/optional // be met. This searches all the installed modules config/optional
// directories. // directories.
$storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), $this->installProfile, InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, FALSE); $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, FALSE);
$this->installOptionalConfig($storage, [$type => $name]); $this->installOptionalConfig($storage, [$type => $name]);
} }
...@@ -165,11 +156,11 @@ public function installOptionalConfig(StorageInterface $storage = NULL, $depende ...@@ -165,11 +156,11 @@ public function installOptionalConfig(StorageInterface $storage = NULL, $depende
$optional_profile_config = []; $optional_profile_config = [];
if (!$storage) { if (!$storage) {
// Search the install profile's optional configuration too. // Search the install profile's optional configuration too.
$storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), $this->installProfile, InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, TRUE); $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, TRUE);
// The extension install storage ensures that overrides are used. // The extension install storage ensures that overrides are used.
$profile_storage = NULL; $profile_storage = NULL;
} }
elseif (!empty($profile)) { elseif (isset($profile)) {
// Creates a profile storage to search for overrides. // Creates a profile storage to search for overrides.
$profile_install_path = $this->drupalGetPath('module', $profile) . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY; $profile_install_path = $this->drupalGetPath('module', $profile) . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
$profile_storage = new FileStorage($profile_install_path, StorageInterface::DEFAULT_COLLECTION); $profile_storage = new FileStorage($profile_install_path, StorageInterface::DEFAULT_COLLECTION);
...@@ -340,7 +331,7 @@ protected function createConfiguration($collection, array $config_to_create) { ...@@ -340,7 +331,7 @@ protected function createConfiguration($collection, array $config_to_create) {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function installCollectionDefaultConfig($collection) { public function installCollectionDefaultConfig($collection) {
$storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), $this->installProfile, InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection, $this->drupalInstallationAttempted()); $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection, $this->drupalInstallationAttempted());
// Only install configuration for enabled extensions. // Only install configuration for enabled extensions.
$enabled_extensions = $this->getEnabledExtensions(); $enabled_extensions = $this->getEnabledExtensions();
$config_to_install = array_filter($storage->listAll(), function ($config_name) use ($enabled_extensions) { $config_to_install = array_filter($storage->listAll(), function ($config_name) use ($enabled_extensions) {
...@@ -680,7 +671,9 @@ protected function drupalGetPath($type, $name) { ...@@ -680,7 +671,9 @@ protected function drupalGetPath($type, $name) {
* of the installer or during unit tests. * of the installer or during unit tests.
*/ */
protected function drupalGetProfile() { protected function drupalGetProfile() {
return $this->installProfile; // Settings is safe to use because settings.php is written before any module
// is installed.
return Settings::get('install_profile');
} }
/** /**
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Core\Site\Settings;
use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\Extension\ExtensionDiscovery;
/** /**
...@@ -26,21 +27,12 @@ class ExtensionInstallStorage extends InstallStorage { ...@@ -26,21 +27,12 @@ class ExtensionInstallStorage extends InstallStorage {
*/ */
protected $includeProfile = TRUE; protected $includeProfile = TRUE;
/**
* The name of the currently active installation profile.
*
* @var string
*/
protected $installProfile;
/** /**
* Overrides \Drupal\Core\Config\InstallStorage::__construct(). * Overrides \Drupal\Core\Config\InstallStorage::__construct().
* *
* @param \Drupal\Core\Config\StorageInterface $config_storage * @param \Drupal\Core\Config\StorageInterface $config_storage
* The active configuration store where the list of enabled modules and * The active configuration store where the list of enabled modules and
* themes is stored. * themes is stored.
* @param string $profile
* The current installation profile.
* @param string $directory * @param string $directory
* The directory to scan in each extension to scan for files. Defaults to * The directory to scan in each extension to scan for files. Defaults to
* 'config/install'. * 'config/install'.
...@@ -51,12 +43,10 @@ class ExtensionInstallStorage extends InstallStorage { ...@@ -51,12 +43,10 @@ class ExtensionInstallStorage extends InstallStorage {
* (optional) Whether to include the install profile in extensions to * (optional) Whether to include the install profile in extensions to
* search and to get overrides from. * search and to get overrides from.
*/ */
public function __construct(StorageInterface $config_storage, $profile, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION, $include_profile = TRUE) { public function __construct(StorageInterface $config_storage, $directory = self::CONFIG_INSTALL_DIRECTORY, $collection = StorageInterface::DEFAULT_COLLECTION, $include_profile = TRUE) {
parent::__construct($directory, $collection); parent::__construct($directory, $collection);
$this->configStorage = $config_storage; $this->configStorage = $config_storage;
$this->includeProfile = $include_profile; $this->includeProfile = $include_profile;
$this->installProfile = $profile;
} }
/** /**
...@@ -87,20 +77,22 @@ protected function getAllFolders() { ...@@ -87,20 +77,22 @@ protected function getAllFolders() {
$this->folders = array(); $this->folders = array();
$this->folders += $this->getCoreNames(); $this->folders += $this->getCoreNames();
$install_profile = Settings::get('install_profile');
$profile = drupal_get_profile();
$extensions = $this->configStorage->read('core.extension'); $extensions = $this->configStorage->read('core.extension');
// @todo Remove this scan as part of https://www.drupal.org/node/2186491 // @todo Remove this scan as part of https://www.drupal.org/node/2186491
$listing = new ExtensionDiscovery(\Drupal::root()); $listing = new ExtensionDiscovery(\Drupal::root());
if (!empty($extensions['module'])) { if (!empty($extensions['module'])) {
$modules = $extensions['module']; $modules = $extensions['module'];
// Remove the install profile as this is handled later. // Remove the install profile as this is handled later.
unset($modules[$this->installProfile]); unset($modules[$install_profile]);
$profile_list = $listing->scan('profile'); $profile_list = $listing->scan('profile');
if ($this->installProfile && isset($profile_list[$this->installProfile])) { if ($profile && isset($profile_list[$profile])) {
// Prime the drupal_get_filename() static cache with the profile info // Prime the drupal_get_filename() static cache with the profile info
// file location so we can use drupal_get_path() on the active profile // file location so we can use drupal_get_path() on the active profile
// during the module scan. // during the module scan.
// @todo Remove as part of https://www.drupal.org/node/2186491 // @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', $this->installProfile, $profile_list[$this->installProfile]->getPathname()); drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname());
} }
$module_list_scan = $listing->scan('module'); $module_list_scan = $listing->scan('module');
$module_list = array(); $module_list = array();
...@@ -125,12 +117,12 @@ protected function getAllFolders() { ...@@ -125,12 +117,12 @@ protected function getAllFolders() {
// The install profile can override module default configuration. We do // The install profile can override module default configuration. We do
// this by replacing the config file path from the module/theme with the // this by replacing the config file path from the module/theme with the
// install profile version if there are any duplicates. // install profile version if there are any duplicates.
if ($this->installProfile) { if (isset($profile)) {
if (!isset($profile_list)) { if (!isset($profile_list)) {
$profile_list = $listing->scan('profile'); $profile_list = $listing->scan('profile');
} }
if (isset($profile_list[$this->installProfile])) { if (isset($profile_list[$profile])) {
$profile_folders = $this->getComponentNames(array($profile_list[$this->installProfile])); $profile_folders = $this->getComponentNames(array($profile_list[$profile]));
$this->folders = $profile_folders + $this->folders; $this->folders = $profile_folders + $this->folders;
} }
} }
......
...@@ -1195,7 +1195,6 @@ protected function compileContainer() { ...@@ -1195,7 +1195,6 @@ protected function compileContainer() {
$container = $this->getContainerBuilder(); $container = $this->getContainerBuilder();
$container->set('kernel', $this); $container->set('kernel', $this);
$container->setParameter('container.modules', $this->getModulesParameter()); $container->setParameter('container.modules', $this->getModulesParameter());
$container->setParameter('install_profile', $this->getInstallProfile());
// Get a list of namespaces and put it onto the container. // Get a list of namespaces and put it onto the container.
$namespaces = $this->getModuleNamespacesPsr4($this->getModuleFileNames()); $namespaces = $this->getModuleNamespacesPsr4($this->getModuleFileNames());
...@@ -1553,25 +1552,4 @@ protected function addServiceFiles(array $service_yamls) { ...@@ -1553,25 +1552,4 @@ protected function addServiceFiles(array $service_yamls) {
$this->serviceYamls['site'] = array_filter($service_yamls, 'file_exists'); $this->serviceYamls['site'] = array_filter($service_yamls, 'file_exists');
} }
/**
* Gets the active install profile.
*
* @return string|null
* The name of the any active install profile or distribution.
*/
protected function getInstallProfile() {
$config = $this->getConfigStorage()->read('core.extension');
if (!empty($config['profile'])) {
$install_profile = $config['profile'];
}
// @todo https://www.drupal.org/node/2831065 remove the BC layer.
else {
// If system_update_8300() has not yet run fallback to using settings.
$install_profile = Settings::get('install_profile');
}
// Normalize an empty string to a NULL value.
return empty($install_profile) ? NULL : $install_profile;
}
} }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase; use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase;
use Drupal\Core\Config\ConfigNameException; use Drupal\Core\Config\ConfigNameException;
use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Site\Settings;
/** /**
* Config import subscriber for config import events. * Config import subscriber for config import events.
...@@ -111,10 +112,9 @@ protected function validateModules(ConfigImporter $config_importer) { ...@@ -111,10 +112,9 @@ protected function validateModules(ConfigImporter $config_importer) {
} }
} }
// Get the install profile from the site's configuration. // Settings is safe to use because settings.php is written before any module
$current_core_extension = $config_importer->getStorageComparer()->getTargetStorage()->read('core.extension'); // is installed.
$install_profile = isset($current_core_extension['profile']) ? $current_core_extension['profile'] : NULL; $install_profile = Settings::get('install_profile');
// Ensure that all modules being uninstalled are not required by modules // Ensure that all modules being uninstalled are not required by modules
// that will be installed after the import. // that will be installed after the import.
$uninstalls = $config_importer->getExtensionChangelist('module', 'uninstall'); $uninstalls = $config_importer->getExtensionChangelist('module', 'uninstall');
...@@ -129,15 +129,10 @@ protected function validateModules(ConfigImporter $config_importer) { ...@@ -129,15 +129,10 @@ protected function validateModules(ConfigImporter $config_importer) {
} }
// Ensure that the install profile is not being uninstalled. // Ensure that the install profile is not being uninstalled.
if (in_array($install_profile, $uninstalls, TRUE)) { if (in_array($install_profile, $uninstalls)) {
$profile_name = $module_data[$install_profile]->info['name']; $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.', array('%profile' => $profile_name))); $config_importer->logError($this->t('Unable to uninstall the %profile profile since it is the install profile.', array('%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 %new_profile to %profile once Drupal is installed.', array('%profile' => $install_profile, '%new_profile' => $core_extension['profile'])));
}
} }
/** /**
......
<?php
namespace Drupal\Core\Installer\Exception;
use Drupal\Core\StringTranslation\TranslationInterface;
/**
* Exception thrown if settings.php cannot be written and the chosen profile does not match.
*/
class InstallProfileMismatchException extends InstallerException {
/**
* Constructs a new InstallProfileMismatchException exception.
*
* @param string $selected_profile
* The profile selected by _install_select_profile().
* @param string $settings_profile
* The profile in settings.php.
* @param string $settings_file
* The path to settigns.php.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation manager.
*
* @deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0. The
* install profile is written to core.extension.
*
* @see _install_select_profile()
* @see install_write_profile
*/
public function __construct($selected_profile, $settings_profile, $settings_file, TranslationInterface $string_translation) {
$this->stringTranslation = $string_translation;
$title = $this->t('Install profile mismatch');
$message = $this->t(
'The selected profile %profile does not match the install_profile setting, which is %settings_profile. Cannot write updated setting to %settings_file.',
[
'%profile' => $selected_profile,
'%settings_profile' => $settings_profile,
'%settings_file' => $settings_file,
]
);
parent::__construct($message, $title);
}
}
...@@ -46,24 +46,4 @@ public function getConfigStorage() { ...@@ -46,24 +46,4 @@ public function getConfigStorage() {
return parent::getConfigStorage(); return parent::getConfigStorage();
} }
/**
* {@inheritdoc}
*/
public function getInstallProfile() {
global $install_state;
if ($install_state && empty($install_state['installation_finished'])) {
// If the profile has been selected return it.
if (isset($install_state['parameters']['profile'])) {
$profile = $install_state['parameters']['profile'];
}
else {
$profile = NULL;
}
}
else {
$profile = parent::getInstallProfile();
}
return $profile;
}
} }
services: services:
locale.default.config.storage: locale.default.config.storage:
class: Drupal\locale\LocaleDefaultConfigStorage class: Drupal\locale\LocaleDefaultConfigStorage
arguments: ['@config.storage', '@language_manager', '%install_profile%'] arguments: ['@config.storage', '@language_manager']
public: false public: false
locale.config_manager: locale.config_manager:
class: Drupal\locale\LocaleConfigManager class: Drupal\locale\LocaleConfigManager
......
...@@ -57,12 +57,12 @@ class LocaleDefaultConfigStorage { ...@@ -57,12 +57,12 @@ class LocaleDefaultConfigStorage {
* @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager * @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager
* The language manager. * The language manager.
*/ */
public function __construct(StorageInterface $config_storage, ConfigurableLanguageManagerInterface $language_manager, $install_profile) { public function __construct(StorageInterface $config_storage, ConfigurableLanguageManagerInterface $language_manager) {
$this->configStorage = $config_storage; $this->configStorage = $config_storage;
$this->languageManager = $language_manager; $this->languageManager = $language_manager;
$this->requiredInstallStorage = new ExtensionInstallStorage($this->configStorage, $install_profile);