1 install.core.inc install_settings_form_submit($form, &$form_state)

Form submission handler for install_settings_form().

See also

install_settings_form_validate()

File

core/includes/install.core.inc, line 1068
API functions for installing Backdrop.

Code

function install_settings_form_submit($form, &$form_state) {
  global $install_state;

  // Update global settings array and save.
  $db_settings = $form_state['storage']['database'];
  $settings['database'] = array(
    'value' => array(
      'database' => $db_settings['database'],
      'username' => $db_settings['username'],
      'password' => $db_settings['password'],
      'host' => $db_settings['host'],
    ),
    'required' => TRUE,
  );

  // If UTF-8 MB4 is not supported, use the old UTF-8 charset.
  if (install_verify_database_utf8mb4() === FALSE && $db_settings['charset'] === 'utf8mb4') {
    $db_settings['charset'] = 'utf8';
  }

  // Only populate values if they are not the defaults:
  if ($db_settings['driver'] != 'mysql') {
    $settings['database']['value']['driver'] = $db_settings['driver'];
  }
  if (!empty($db_settings['prefix'])) {
    $settings['database']['value']['prefix'] = $db_settings['prefix'];
  }
  if ($db_settings['port'] && $db_settings['port'] != '3306') {
    $settings['database']['value']['port'] = $db_settings['port'];
  }
  if ($db_settings['charset'] && $db_settings['charset'] != 'utf8mb4') {
    $settings['database']['value']['charset'] = $db_settings['charset'];
  }
  if ($db_settings['collation'] && $db_settings['collation'] != 'utf8mb4_general_ci') {
    $settings['database']['value']['collation'] = $db_settings['collation'];
  }
  backdrop_rewrite_settings($settings);

  // Indicate that the settings file has been verified, and check the database
  // for the last completed task, now that we have a valid connection. This
  // last step is important since we want to trigger an error if the new
  // database already has Backdrop installed.
  $install_state['settings_verified'] = TRUE;
  $install_state['completed_task'] = install_verify_completed_task();
}