Commit 02569d15 authored by catch's avatar catch
Browse files

Issue #2487592 by alexpott, JeroenT, Schnitzel, cilefen: CMI: don't ship with...

Issue #2487592 by alexpott, JeroenT, Schnitzel, cilefen: CMI: don't ship with a default "active" directory that is empty in most Drupal installations
parent 795d9f92
Loading
Loading
Loading
Loading
+0 −4
Changes for core/core.services.yml: 0 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -290,10 +290,6 @@ services:
    public: false
    tags:
      - { name: backend_overridable }
  config.storage.file:
    class: Drupal\Core\Config\FileStorage
    factory: Drupal\Core\Config\FileStorageFactory::getActive
    public: false
  config.storage.staging:
    class: Drupal\Core\Config\FileStorage
    factory: Drupal\Core\Config\FileStorageFactory::getStaging
+11 −3
Changes for core/includes/bootstrap.inc: 11 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -101,6 +101,9 @@
 * $config_directories key for active directory.
 *
 * @see config_get_config_directory()
 *
 * @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Drupal core no
 *   longer creates an active directory.
 */
const CONFIG_ACTIVE_DIRECTORY = 'active';

@@ -162,14 +165,19 @@ function conf_path($require_settings = TRUE, $reset = FALSE, Request $request =
/**
 * Returns the path of a configuration directory.
 *
 * Configuration directories are configured using $config_directories in
 * settings.php.
 *
 * @param string $type
 *   (optional) The type of config directory to return. Drupal core provides
 *   'active' and 'staging'. Defaults to CONFIG_ACTIVE_DIRECTORY.
 *   The type of config directory to return. Drupal core provides the
 *   CONFIG_STAGING_DIRECTORY constant to access the staging directory.
 *
 * @return string
 *   The configuration directory path.
 *
 * @throws \Exception
 */
function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) {
function config_get_config_directory($type) {
  global $config_directories;

  if (!empty($config_directories[$type])) {
+0 −1
Changes for core/includes/file.inc: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -335,7 +335,6 @@ function file_ensure_htaccess() {
    file_save_htaccess('private://', TRUE);
  }
  file_save_htaccess('temporary://', TRUE);
  file_save_htaccess(config_get_config_directory(), TRUE);
  file_save_htaccess(config_get_config_directory(CONFIG_STAGING_DIRECTORY), TRUE);
}

+1 −1
Changes for core/includes/install.core.inc: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -365,7 +365,7 @@ function install_begin_request($class_loader, &$install_state) {
  \Drupal::setContainer($container);

  // Determine whether base system services are ready to operate.
  $install_state['config_verified'] = install_ensure_config_directory(CONFIG_ACTIVE_DIRECTORY) && install_ensure_config_directory(CONFIG_STAGING_DIRECTORY);
  $install_state['config_verified'] = install_ensure_config_directory(CONFIG_STAGING_DIRECTORY);
  $install_state['database_verified'] = install_verify_database_settings($site_path);
  $install_state['settings_verified'] = $install_state['config_verified'] && $install_state['database_verified'];

+6 −27
Changes for core/includes/install.inc: 6 added lines, 27 removed lines.
Original line number Diff line number Diff line
@@ -178,10 +178,6 @@ function drupal_get_database_types() {
 *   and comment properties.
 *   @code
 *   $settings['config_directories'] = array(
 *     CONFIG_ACTIVE_DIRECTORY => (object) array(
 *       'value' => 'config_hash/active'
 *       'required' => TRUE,
 *     ),
 *     CONFIG_STAGING_DIRECTORY => (object) array(
 *       'value' => 'config_hash/staging',
 *       'required' => TRUE,
@@ -467,12 +463,6 @@ function drupal_install_config_directories() {
  // manually defined in the existing already.
  $settings = [];
  $config_directories_hash = Crypt::randomBytesBase64(55);
  if (empty($config_directories[CONFIG_ACTIVE_DIRECTORY])) {
    $settings['config_directories'][CONFIG_ACTIVE_DIRECTORY] = (object) [
      'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/active',
      'required' => TRUE,
    ];
  }
  if (empty($config_directories[CONFIG_STAGING_DIRECTORY])) {
    $settings['config_directories'][CONFIG_STAGING_DIRECTORY] = (object) [
      'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/staging',
@@ -485,36 +475,25 @@ function drupal_install_config_directories() {
    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)) {
  if (!install_ensure_config_directory(CONFIG_STAGING_DIRECTORY)) {
    throw new Exception(t('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),
      '%directory' => config_get_config_directory(CONFIG_STAGING_DIRECTORY),
      '@handbook_url' => 'https://www.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-
  // Put a README.txt into the staging config directory. This is required so
  // that they can later be added to git. Since this directory is 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 = 'If you change the configuration system to use file storage instead of the database for the active Drupal site configuration, this directory will contain the active configuration. By default, this directory will be empty. If you are using files to store the active configuration, and you want to move it between environments, files from this directory should be placed in the staging directory on the target server. To make this configuration active, visit admin/config/development/configuration/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, visit admin/config/development/configuration/sync.';
        break;
    }
    $text .=  ' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
    file_put_contents(config_get_config_directory($config_type) . '/README.txt', $text);
  }
  $text =  'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.'  .' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
  file_put_contents(config_get_config_directory(CONFIG_STAGING_DIRECTORY) . '/README.txt', $text);
}

/**
Loading