Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Installer / Form / SiteConfigureForm.php
index c28b7f8fd4947fbb99452d05dbb205edafcbc083..2cca962599934cae8bf9be19ca85be15122031d9 100644 (file)
@@ -6,12 +6,15 @@ use Drupal\Core\Extension\ModuleInstallerInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Locale\CountryManagerInterface;
+use Drupal\Core\Site\Settings;
 use Drupal\Core\State\StateInterface;
 use Drupal\user\UserStorageInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Provides the site configuration form.
+ *
+ * @internal
  */
 class SiteConfigureForm extends ConfigFormBase {
 
@@ -118,6 +121,7 @@ class SiteConfigureForm extends ConfigFormBase {
    * {@inheritdoc}
    */
   public function buildForm(array $form, FormStateInterface $form_state) {
+    global $install_state;
     $form['#title'] = $this->t('Configure site');
 
     // Warn about settings.php permissions risk
@@ -131,8 +135,8 @@ class SiteConfigureForm extends ConfigFormBase {
     // distract from the message that the Drupal installation has completed
     // successfully.)
     $post_params = $this->getRequest()->request->all();
-    if (empty($post_params) && (!drupal_verify_install_file($this->root . '/' . $settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($this->root . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
-      drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href=":handbook_url">online handbook</a>.', ['%dir' => $settings_dir, '%file' => $settings_file, ':handbook_url' => 'https://www.drupal.org/server-permissions']), 'warning');
+    if (empty($post_params) && (Settings::get('skip_permissions_hardening') || !drupal_verify_install_file($this->root . '/' . $settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($this->root . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) {
+      $this->messenger()->addWarning(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href=":handbook_url">online handbook</a>.', ['%dir' => $settings_dir, '%file' => $settings_file, ':handbook_url' => 'https://www.drupal.org/server-permissions']));
     }
 
     $form['#attached']['library'][] = 'system/drupal.system';
@@ -145,12 +149,14 @@ class SiteConfigureForm extends ConfigFormBase {
     $form['site_information'] = [
       '#type' => 'fieldgroup',
       '#title' => $this->t('Site information'),
+      '#access' => empty($install_state['config_install_path']),
     ];
     $form['site_information']['site_name'] = [
       '#type' => 'textfield',
       '#title' => $this->t('Site name'),
       '#required' => TRUE,
       '#weight' => -20,
+      '#access' => empty($install_state['config_install_path']),
     ];
     $form['site_information']['site_mail'] = [
       '#type' => 'email',
@@ -159,6 +165,7 @@ class SiteConfigureForm extends ConfigFormBase {
       '#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,
+      '#access' => empty($install_state['config_install_path']),
     ];
 
     $form['admin_account'] = [
@@ -188,6 +195,7 @@ class SiteConfigureForm extends ConfigFormBase {
     $form['regional_settings'] = [
       '#type' => 'fieldgroup',
       '#title' => $this->t('Regional settings'),
+      '#access' => empty($install_state['config_install_path']),
     ];
     $countries = $this->countryManager->getList();
     $form['regional_settings']['site_default_country'] = [
@@ -198,27 +206,31 @@ class SiteConfigureForm extends ConfigFormBase {
       '#options' => $countries,
       '#description' => $this->t('Select the default country for the site.'),
       '#weight' => 0,
+      '#access' => empty($install_state['config_install_path']),
     ];
     $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(),
-      '#options' => system_time_zones(),
+      '#options' => system_time_zones(NULL, TRUE),
       '#description' => $this->t('By default, dates in this site will be displayed in the chosen time zone.'),
       '#weight' => 5,
       '#attributes' => ['class' => ['timezone-detect']],
+      '#access' => empty($install_state['config_install_path']),
     ];
 
     $form['update_notifications'] = [
       '#type' => 'fieldgroup',
       '#title' => $this->t('Update notifications'),
       '#description' => $this->t('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to <a href=":drupal">Drupal.org</a>.', [':drupal' => 'https://www.drupal.org']),
+      '#access' => empty($install_state['config_install_path']),
     ];
     $form['update_notifications']['enable_update_status_module'] = [
       '#type' => 'checkbox',
       '#title' => $this->t('Check for updates automatically'),
       '#default_value' => 1,
+      '#access' => empty($install_state['config_install_path']),
     ];
     $form['update_notifications']['enable_update_status_emails'] = [
       '#type' => 'checkbox',
@@ -229,6 +241,7 @@ class SiteConfigureForm extends ConfigFormBase {
           'input[name="enable_update_status_module"]' => ['checked' => TRUE],
         ],
       ],
+      '#access' => empty($install_state['config_install_path']),
     ];
 
     $form['actions'] = ['#type' => 'actions'];
@@ -255,21 +268,25 @@ class SiteConfigureForm extends ConfigFormBase {
    * {@inheritdoc}
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
-    $this->config('system.site')
-      ->set('name', (string) $form_state->getValue('site_name'))
-      ->set('mail', (string) $form_state->getValue('site_mail'))
-      ->save(TRUE);
+    global $install_state;
 
-    $this->config('system.date')
-      ->set('timezone.default', (string) $form_state->getValue('date_default_timezone'))
-      ->set('country.default', (string) $form_state->getValue('site_default_country'))
-      ->save(TRUE);
+    if (empty($install_state['config_install_path'])) {
+      $this->config('system.site')
+        ->set('name', (string) $form_state->getValue('site_name'))
+        ->set('mail', (string) $form_state->getValue('site_mail'))
+        ->save(TRUE);
+
+      $this->config('system.date')
+        ->set('timezone.default', (string) $form_state->getValue('date_default_timezone'))
+        ->set('country.default', (string) $form_state->getValue('site_default_country'))
+        ->save(TRUE);
+    }
 
     $account_values = $form_state->getValue('account');
 
     // Enable update.module if this option was selected.
     $update_status_module = $form_state->getValue('enable_update_status_module');
-    if ($update_status_module) {
+    if (empty($install_state['config_install_path']) && $update_status_module) {
       $this->moduleInstaller->install(['file', 'update'], FALSE);
 
       // Add the site maintenance account's email address to the list of