diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php index f4bd493ca4f6..c24fd28ef429 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php @@ -158,10 +158,13 @@ class SiteConfigureForm extends ConfigFormBase { '#weight' => -20, '#access' => empty($install_state['config_install_path']), ]; + // Use the default site mail if one is already configured, or fall back to + // PHP's configured sendmail_from. + $default_site_mail = $this->config('system.site')->get('mail') ?: ini_get('sendmail_from'); $form['site_information']['site_mail'] = [ '#type' => 'email', '#title' => $this->t('Site email address'), - '#default_value' => ini_get('sendmail_from'), + '#default_value' => $default_site_mail, '#description' => $this->t("Automated emails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these emails from being flagged as spam."), '#required' => TRUE, '#weight' => -15, @@ -207,11 +210,14 @@ class SiteConfigureForm extends ConfigFormBase { '#weight' => 0, '#access' => empty($install_state['config_install_path']), ]; + // Use the default site timezone if one is already configured, or fall back + // to the system timezone if set (and avoid throwing a warning in + // PHP >=5.4). + $default_timezone = $this->config('system.date')->get('timezone.default') ?: @date_default_timezone_get(); $form['regional_settings']['date_default_timezone'] = [ '#type' => 'select', '#title' => $this->t('Default time zone'), - // Use system timezone if set, but avoid throwing a warning in PHP >=5.4 - '#default_value' => @date_default_timezone_get(), + '#default_value' => $default_timezone, '#options' => system_time_zones(NULL, TRUE), '#weight' => 5, '#attributes' => ['class' => ['timezone-detect']], diff --git a/core/profiles/testing_site_config/testing_site_config.info.yml b/core/profiles/testing_site_config/testing_site_config.info.yml new file mode 100644 index 000000000000..31a390557e08 --- /dev/null +++ b/core/profiles/testing_site_config/testing_site_config.info.yml @@ -0,0 +1,6 @@ +name: Testing site config +type: profile +description: 'Minimal profile for testing with default site config.' +version: VERSION +core: 8.x +hidden: true diff --git a/core/profiles/testing_site_config/testing_site_config.install b/core/profiles/testing_site_config/testing_site_config.install new file mode 100644 index 000000000000..0f718d0b8f49 --- /dev/null +++ b/core/profiles/testing_site_config/testing_site_config.install @@ -0,0 +1,22 @@ +getEditable('system.site') + ->set('mail', 'profile-testing-site-config@example.com') + ->save(TRUE); + + // Set the time zone to something that is not the system timezone (which is + // Australia/Sydney in the testing environment). + \Drupal::configFactory()->getEditable('system.date') + ->set('timezone.default', 'America/Los_Angeles') + ->save(TRUE); +} diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerSiteConfigProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerSiteConfigProfileTest.php new file mode 100644 index 000000000000..791befd0468b --- /dev/null +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerSiteConfigProfileTest.php @@ -0,0 +1,63 @@ +assertFieldByName('site_mail', self::EXPECTED_SITE_MAIL); + $this->assertFieldByName('date_default_timezone', self::EXPECTED_TIMEZONE); + + return parent::setUpSite(); + } + + /** + * Verify the correct site config was set. + */ + public function testInstaller() { + $this->assertEqual($this->config('system.site')->get('mail'), self::EXPECTED_SITE_MAIL); + $this->assertEqual($this->config('system.date')->get('timezone.default'), self::EXPECTED_TIMEZONE); + } + +}