Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4293. Stop using CONFIG_ACTIVE_DIRECTORY and especially CONFIG_SYNC_DIRECTORY. #4301

Merged
merged 2 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions includes/legacy.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ function drush_file_directory_temp()
* settings.php.
*
* @param string $type
* The type of config directory to return. Drupal core provides the
* CONFIG_SYNC_DIRECTORY constant to access the sync directory.
* The type of config directory to return.
*
* @return string
* The configuration directory path.
*
* @throws \Exception
*/
function drush_config_get_config_directory($type) {
function drush_config_get_config_directory($type = 'sync') {
if (drush_drupal_major_version() >= 9) {
return Settings::get('config_sync_directory');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/core/SiteInstallCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function install(array $profile, $options = ['db-url' => self::REQ, 'db-p

// Was giving error during validate() so its here for now.
if ($options['existing-config']) {
$existing_config_dir = drush_config_get_config_directory(CONFIG_SYNC_DIRECTORY);
$existing_config_dir = drush_config_get_config_directory();
if (!is_dir($existing_config_dir)) {
throw new \Exception(dt('Existing config directory @dir not found', ['@dir' => $existing_config_dir]));
}
Expand Down Expand Up @@ -175,7 +175,7 @@ protected function determineProfile($profile, $options, $class_loader)
// @todo Arguably Drupal core [$boot->getKernel()->getInstallProfile()] could do this - https://github.com/drupal/drupal/blob/8.6.x/core/lib/Drupal/Core/DrupalKernel.php#L1606 reads from DB storage but not file storage.
if (empty($profile) && $options['existing-config']) {
FileCacheFactory::setConfiguration([FileCacheFactory::DISABLE_CACHE => true]);
$source_storage = new FileStorage(drush_config_get_config_directory(CONFIG_SYNC_DIRECTORY));
$source_storage = new FileStorage(drush_config_get_config_directory());
if (!$source_storage->exists('core.extension')) {
throw new \Exception('Existing configuration directory not found or does not contain a core.extension.yml file.".');
}
Expand Down
9 changes: 7 additions & 2 deletions src/Drupal/Commands/config/ConfigCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public static function getDirectory($label, $directory = null)
}
} else {
// If a directory isn't specified, use the label argument or default sync directory.
$return = \drush_config_get_config_directory($label ?: CONFIG_SYNC_DIRECTORY);
$return = \drush_config_get_config_directory($label ?: 'sync');
}
return Path::canonicalize($return);
}
Expand Down Expand Up @@ -377,7 +377,7 @@ public function getChanges($target_storage)
*/
public function getStorage($directory)
{
if ($directory == Path::canonicalize(\drush_config_get_config_directory(CONFIG_SYNC_DIRECTORY))) {
if ($directory == Path::canonicalize(\drush_config_get_config_directory())) {
return \Drupal::service('config.storage.sync');
} else {
return new FileStorage($directory);
Expand Down Expand Up @@ -449,6 +449,11 @@ public function interactConfigName($input, $output)
*/
public function interactConfigLabel(InputInterface $input, ConsoleOutputInterface $output)
{
if (drush_drupal_major_version() >= 9) {
// Nothing to do.
return;
}

global $config_directories;

$option_name = $input->hasOption('destination') ? 'destination' : 'source';
Expand Down
2 changes: 1 addition & 1 deletion src/Drupal/Commands/config/ConfigExportCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function export($label = null, $options = ['add' => false, 'commit' => fa
public function doExport($options, $destination_dir)
{
// Prepare the configuration storage for the export.
if ($destination_dir == Path::canonicalize(\drush_config_get_config_directory(CONFIG_SYNC_DIRECTORY))) {
if ($destination_dir == Path::canonicalize(\drush_config_get_config_directory())) {
$target_storage = $this->getConfigStorageSync();
} else {
$target_storage = new FileStorage($destination_dir);
Expand Down
2 changes: 1 addition & 1 deletion src/Drupal/Commands/config/ConfigImportCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function import($label = null, $options = ['preview' => 'list', 'source'
$source_storage_dir = ConfigCommands::getDirectory($label, $options['source']);

// Prepare the configuration storage for the import.
if ($source_storage_dir == Path::canonicalize(\drush_config_get_config_directory(CONFIG_SYNC_DIRECTORY))) {
if ($source_storage_dir == Path::canonicalize(\drush_config_get_config_directory())) {
$source_storage = $this->getConfigStorageSync();
} else {
$source_storage = new FileStorage($source_storage_dir);
Expand Down