summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Hojtsy2017-11-29 18:58:03 (GMT)
committerGabor Hojtsy2017-11-29 18:58:03 (GMT)
commitdad79553d63d7d087975eb12563f74ae8813c19e (patch)
treedc0c3d531c4052bb0896bbdbb71c2f161f463c0e
parent3ed16f08d71b2315fa41d9fb2e64da3c938fe0b0 (diff)
Issue #2791405 by alexpott, Thew, flocondetoile, eyilmaz, bsnodgrass, cilefen, aralnoth, xjm, mikeohara, jaybee@baelemans.eu, szeidler, Gábor Hojtsy, catch, gagarine, vaplas, claudiu.cristea, ckaotik, idebr: When installing a site in a language besides English, the site name is not saved and reverts to "Drupal"
-rw-r--r--core/includes/install.core.inc1
-rw-r--r--core/lib/Drupal/Core/Installer/ConfigOverride.php62
-rw-r--r--core/modules/system/config/install/system.site.yml2
-rw-r--r--core/modules/system/src/Tests/Installer/DistributionProfileTest.php2
-rw-r--r--core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php16
5 files changed, 82 insertions, 1 deletions
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 869cae8..a869d90 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -415,6 +415,7 @@ function install_begin_request($class_loader, &$install_state) {
else {
$environment = 'prod';
}
+ $GLOBALS['conf']['container_service_providers']['InstallerConfigOverride'] = 'Drupal\Core\Installer\ConfigOverride';
// Only allow dumping the container once the hash salt has been created.
$kernel = InstallerKernel::createFromRequest($request, $class_loader, $environment, (bool) Settings::get('hash_salt', FALSE));
diff --git a/core/lib/Drupal/Core/Installer/ConfigOverride.php b/core/lib/Drupal/Core/Installer/ConfigOverride.php
new file mode 100644
index 0000000..ff8d068
--- /dev/null
+++ b/core/lib/Drupal/Core/Installer/ConfigOverride.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Drupal\Core\Installer;
+
+use Drupal\Core\Cache\CacheableMetadata;
+use Drupal\Core\Config\ConfigFactoryOverrideInterface;
+use Drupal\Core\Config\StorageInterface;
+use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\DependencyInjection\ServiceProviderInterface;
+
+/**
+ * Override configuration during the installer.
+ */
+class ConfigOverride implements ServiceProviderInterface, ConfigFactoryOverrideInterface {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function register(ContainerBuilder $container) {
+ // Register this class so that it can override configuration.
+ $container
+ ->register('core.install_config_override', static::class)
+ ->addTag('config.factory.override');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function loadOverrides($names) {
+ $overrides = [];
+ if (drupal_installation_attempted() && function_exists('drupal_install_profile_distribution_name')) {
+ // Early in the installer the site name is unknown. In this case we need
+ // to fallback to the distribution's name.
+ $overrides['system.site'] = [
+ 'name' => drupal_install_profile_distribution_name(),
+ ];
+ }
+ return $overrides;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCacheSuffix() {
+ return 'core.install_config_override';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
+ return NULL;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCacheableMetadata($name) {
+ return new CacheableMetadata();
+ }
+
+}
diff --git a/core/modules/system/config/install/system.site.yml b/core/modules/system/config/install/system.site.yml
index b5a932b..d1ab8de 100644
--- a/core/modules/system/config/install/system.site.yml
+++ b/core/modules/system/config/install/system.site.yml
@@ -1,5 +1,5 @@
uuid: ''
-name: 'Drupal'
+name: ''
mail: ''
slogan: ''
page:
diff --git a/core/modules/system/src/Tests/Installer/DistributionProfileTest.php b/core/modules/system/src/Tests/Installer/DistributionProfileTest.php
index e52b046..3d2c4c4 100644
--- a/core/modules/system/src/Tests/Installer/DistributionProfileTest.php
+++ b/core/modules/system/src/Tests/Installer/DistributionProfileTest.php
@@ -46,6 +46,8 @@ class DistributionProfileTest extends InstallerTestBase {
protected function setUpLanguage() {
// Verify that the distribution name appears.
$this->assertRaw($this->info['distribution']['name']);
+ // Verify that the distribution name is used in the site title.
+ $this->assertTitle('Choose language | ' . $this->info['distribution']['name']);
// Verify that the requested theme is used.
$this->assertRaw($this->info['distribution']['install']['theme']);
// Verify that the "Choose profile" step does not appear.
diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php
index a608cad..dcde753 100644
--- a/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php
+++ b/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php
@@ -51,13 +51,29 @@ msgstr "Anonymous $langcode"
msgid "Language"
msgstr "Language $langcode"
+
+#: Testing site name configuration during the installer.
+msgid "Drupal"
+msgstr "Drupal"
ENDPO;
}
/**
+ * {@inheritdoc}
+ */
+ protected function installParameters() {
+ $params = parent::installParameters();
+ $params['forms']['install_configure_form']['site_name'] = 'SITE_NAME_' . $this->langcode;
+ return $params;
+ }
+
+ /**
* Tests that translations ended up at the expected places.
*/
public function testTranslationsLoaded() {
+ // Ensure the title is correct.
+ $this->assertEqual('SITE_NAME_' . $this->langcode, \Drupal::config('system.site')->get('name'));
+
// Verify German and Spanish were configured.
$this->drupalGet('admin/config/regional/language');
$this->assertText('German');