function drupal_install_config_directories

Creates the config directory and ensures it is operational.

See also

install_settings_form_submit()

update_prepare_d8_bootstrap()

2 calls to drupal_install_config_directories()
install_settings_form_submit in drupal/core/includes/install.core.inc
Form submission handler for install_settings_form().
update_prepare_d8_bootstrap in drupal/core/includes/update.inc
Performs extra steps required to bootstrap when using a Drupal 7 database.

File

drupal/core/includes/install.inc, line 252
API functions for installing modules and themes.

Code

function drupal_install_config_directories() {
  global $config_directories;

  // Add a randomized config directory name to settings.php, unless it was
  // manually defined in the existing already.
  if (empty($config_directories)) {
    $config_directories_hash = drupal_hash_base64(drupal_random_bytes(55));
    $settings['config_directories'] = array(
      'value' => array(
        CONFIG_ACTIVE_DIRECTORY => array(
          'path' => 'config_' . $config_directories_hash . '/active',
        ),
        CONFIG_STAGING_DIRECTORY => array(
          'path' => 'config_' . $config_directories_hash . '/staging',
        ),
      ),
      'required' => TRUE,
    );

    // Rewrite settings.php, which also sets the value as global variable.
    drupal_rewrite_settings($settings);
  }

  // Ensure the config directories exist or can be created, and are writable.
  foreach (array(
    CONFIG_ACTIVE_DIRECTORY,
    CONFIG_STAGING_DIRECTORY,
  ) as $config_type) {

    // This should never fail, since if the config directory was specified in
    // settings.php it will have already been created and verified earlier, and
    // if it wasn't specified in settings.php, it is created here inside the
    // public files directory, which has already been verified to be writable
    // itself. But if it somehow fails anyway, the installation cannot proceed.
    // Bail out using a similar error message as in system_requirements().
    if (!install_ensure_config_directory($config_type)) {
      throw new Exception(st('The directory %directory could not be created or could not be made writable. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see the <a href="@handbook_url">online handbook</a>.', array(
        '%directory' => config_get_config_directory($config_type),
        '@handbook_url' => 'http://drupal.org/server-permissions',
      )));
    }

    // Put a README.txt into each config directory. This is required so that
    // they can later be added to git. Since these directories are auto-
    // created, we have to write out the README rather than just adding it
    // to the drupal core repo.
    switch ($config_type) {
      case CONFIG_ACTIVE_DIRECTORY:
        $text = 'This directory contains the active configuration for your Drupal site. To move this configuration between environments, contents from this directory should be placed in the staging directory on the target server. To make this configuration active, see admin/config/development/sync on the target server.';
        break;
      case CONFIG_STAGING_DIRECTORY:
        $text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, see admin/config/development/sync.';
        break;
    }
    $text .= ' For information about deploying configuration between servers, see http://drupal.org/documentation/administer/config';
    file_put_contents(config_get_config_directory($config_type) . '/README.txt', $text);
  }
}