Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,12 @@
require $ah_settings_file;
}
// @codeCoverageIgnoreEnd
// Set the config sync directory to a `config_vcs_directory`, but still
// allow overriding it with the DRUPAL_CONFIG_PATH environment variable.
if (!empty($settings['config_vcs_directory'])) {
$settings['config_sync_directory'] = getenv('DRUPAL_CONFIG_PATH') ?: $settings['config_vcs_directory'];
}

// Automatically create an Apache HTTP .htaccess file in writable directories.
$settings['auto_create_htaccess'] = TRUE;

// Default all environments to 'dev', including ODE environments.
$settings['environment'] = ENVIRONMENT_DEV;

// Do not put any Acquia-specific settings in this code block. It is used
// to explicitly map Acquia environments to $settings['environment']
// variable only.
// Instead, use 'PER-ENVIRONMENT SETTINGS' section below.
switch (getenv('AH_SITE_ENVIRONMENT')) {
case 'prod':
$settings['environment'] = ENVIRONMENT_PROD;
Expand All @@ -57,4 +47,18 @@
$settings['environment'] = ENVIRONMENT_STAGE;
break;
}

// Override the config sync directory with the DRUPAL_CONFIG_PATH environment
// variable if provided, or fall back to the config_vcs_directory setting
// provided by Acquia.
$drupal_config_path = getenv('DRUPAL_CONFIG_PATH');
if (!empty($drupal_config_path)) {
$settings['config_sync_directory'] = $drupal_config_path;
}
elseif (!empty($settings['config_vcs_directory'])) {
$settings['config_sync_directory'] = $settings['config_vcs_directory'];
}

// Automatically create an Apache HTTP .htaccess file in writable directories.
$settings['auto_create_htaccess'] = TRUE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
];
}

@@ -315,6 +359,177 @@
@@ -315,6 +359,221 @@
$settings['skip_permissions_hardening'] = TRUE;
$settings['config_sync_directory'] = '../config/default';
$settings['suspend_mail_send'] = TRUE;
Expand Down Expand Up @@ -223,6 +223,50 @@
+ ];
+ $settings['config_sync_directory'] = '../config/default';
+ $settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
+ $settings['maintenance_theme'] = 'claro';
+ $settings['trusted_host_patterns'] = [
+ '^localhost$',
+ ];
+ $this->assertSettings($settings);
+ }
+
+ /**
+ * Test Acquia config_sync_directory override with DRUPAL_CONFIG_PATH.
+ */
+ public function testEnvironmentAcquiaConfigPathOverride(): void {
+ $this->setEnvVars([
+ 'AH_SITE_ENVIRONMENT' => 1,
+ 'DRUPAL_CONFIG_PATH' => 'custom_acquia_config',
+ ]);
+
+ $this->requireSettingsFile();
+
+ $config['acquia_hosting_settings_autoconnect'] = FALSE;
+ $config['config_split.config_split.dev']['status'] = TRUE;
+ $config['environment_indicator.indicator']['bg_color'] = '#4caf50';
+ $config['environment_indicator.indicator']['fg_color'] = '#000000';
+ $config['environment_indicator.indicator']['name'] = self::ENVIRONMENT_DEV;
+ $config['environment_indicator.settings']['favicon'] = TRUE;
+ $config['environment_indicator.settings']['toolbar_integration'] = [TRUE];
+ $config['robotstxt.settings']['content'] = "User-agent: *\nDisallow: /";
+ $config['shield.settings']['shield_enable'] = TRUE;
+ $config['system.performance']['cache']['page']['max_age'] = 900;
+ $this->assertConfig($config);
+
+ $settings['auto_create_htaccess'] = TRUE;
+ $settings['config_exclude_modules'] = [];
+ $settings['config_sync_directory'] = 'custom_acquia_config';
+ $settings['container_yamls'][0] = $this->app_root . '/' . $this->site_path . '/services.yml';
+ $settings['entity_update_batch_size'] = 50;
+ $settings['environment'] = self::ENVIRONMENT_DEV;
+ $settings['file_public_path'] = 'sites/default/files';
+ $settings['file_private_path'] = 'sites/default/files/private';
+ $settings['file_temp_path'] = '/tmp';
+ $settings['file_scan_ignore_directories'] = [
+ 'node_modules',
+ 'bower_components',
+ ];
+ $settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
+ $settings['maintenance_theme'] = 'claro';
$settings['trusted_host_patterns'] = [
'^localhost$',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,12 @@
require $ah_settings_file;
}
// @codeCoverageIgnoreEnd
// Set the config sync directory to a `config_vcs_directory`, but still
// allow overriding it with the DRUPAL_CONFIG_PATH environment variable.
if (!empty($settings['config_vcs_directory'])) {
$settings['config_sync_directory'] = getenv('DRUPAL_CONFIG_PATH') ?: $settings['config_vcs_directory'];
}

// Automatically create an Apache HTTP .htaccess file in writable directories.
$settings['auto_create_htaccess'] = TRUE;

// Default all environments to 'dev', including ODE environments.
$settings['environment'] = ENVIRONMENT_DEV;

// Do not put any Acquia-specific settings in this code block. It is used
// to explicitly map Acquia environments to $settings['environment']
// variable only.
// Instead, use 'PER-ENVIRONMENT SETTINGS' section below.
switch (getenv('AH_SITE_ENVIRONMENT')) {
case 'prod':
$settings['environment'] = ENVIRONMENT_PROD;
Expand All @@ -57,4 +47,18 @@
$settings['environment'] = ENVIRONMENT_STAGE;
break;
}

// Override the config sync directory with the DRUPAL_CONFIG_PATH environment
// variable if provided, or fall back to the config_vcs_directory setting
// provided by Acquia.
$drupal_config_path = getenv('DRUPAL_CONFIG_PATH');
if (!empty($drupal_config_path)) {
$settings['config_sync_directory'] = $drupal_config_path;
}
elseif (!empty($settings['config_vcs_directory'])) {
$settings['config_sync_directory'] = $settings['config_vcs_directory'];
}

// Automatically create an Apache HTTP .htaccess file in writable directories.
$settings['auto_create_htaccess'] = TRUE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
];
}

@@ -315,6 +359,177 @@
@@ -315,6 +359,221 @@
$settings['skip_permissions_hardening'] = TRUE;
$settings['config_sync_directory'] = '../config/default';
$settings['suspend_mail_send'] = TRUE;
Expand Down Expand Up @@ -223,6 +223,50 @@
+ ];
+ $settings['config_sync_directory'] = '../config/default';
+ $settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
+ $settings['maintenance_theme'] = 'claro';
+ $settings['trusted_host_patterns'] = [
+ '^localhost$',
+ ];
+ $this->assertSettings($settings);
+ }
+
+ /**
+ * Test Acquia config_sync_directory override with DRUPAL_CONFIG_PATH.
+ */
+ public function testEnvironmentAcquiaConfigPathOverride(): void {
+ $this->setEnvVars([
+ 'AH_SITE_ENVIRONMENT' => 1,
+ 'DRUPAL_CONFIG_PATH' => 'custom_acquia_config',
+ ]);
+
+ $this->requireSettingsFile();
+
+ $config['acquia_hosting_settings_autoconnect'] = FALSE;
+ $config['config_split.config_split.dev']['status'] = TRUE;
+ $config['environment_indicator.indicator']['bg_color'] = '#4caf50';
+ $config['environment_indicator.indicator']['fg_color'] = '#000000';
+ $config['environment_indicator.indicator']['name'] = self::ENVIRONMENT_DEV;
+ $config['environment_indicator.settings']['favicon'] = TRUE;
+ $config['environment_indicator.settings']['toolbar_integration'] = [TRUE];
+ $config['robotstxt.settings']['content'] = "User-agent: *\nDisallow: /";
+ $config['shield.settings']['shield_enable'] = TRUE;
+ $config['system.performance']['cache']['page']['max_age'] = 900;
+ $this->assertConfig($config);
+
+ $settings['auto_create_htaccess'] = TRUE;
+ $settings['config_exclude_modules'] = [];
+ $settings['config_sync_directory'] = 'custom_acquia_config';
+ $settings['container_yamls'][0] = $this->app_root . '/' . $this->site_path . '/services.yml';
+ $settings['entity_update_batch_size'] = 50;
+ $settings['environment'] = self::ENVIRONMENT_DEV;
+ $settings['file_public_path'] = 'sites/default/files';
+ $settings['file_private_path'] = 'sites/default/files/private';
+ $settings['file_temp_path'] = '/tmp';
+ $settings['file_scan_ignore_directories'] = [
+ 'node_modules',
+ 'bower_components',
+ ];
+ $settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
+ $settings['maintenance_theme'] = 'claro';
$settings['trusted_host_patterns'] = [
'^localhost$',
Expand Down
44 changes: 44 additions & 0 deletions tests/phpunit/Drupal/EnvironmentSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,50 @@ public function testEnvironmentAcquiaProd(): void {
];
$this->assertSettings($settings);
}

/**
* Test Acquia config_sync_directory override with DRUPAL_CONFIG_PATH.
*/
public function testEnvironmentAcquiaConfigPathOverride(): void {
$this->setEnvVars([
'AH_SITE_ENVIRONMENT' => 1,
'DRUPAL_CONFIG_PATH' => 'custom_acquia_config',
]);
Comment on lines +781 to +785
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider adding a test for the config_vcs_directory fallback path.

The test covers the DRUPAL_CONFIG_PATH override scenario but doesn't verify the fallback to config_vcs_directory when DRUPAL_CONFIG_PATH is absent. While the Acquia settings file that sets config_vcs_directory is excluded from coverage (due to file system dependencies), you could potentially mock this by pre-setting $settings['config_vcs_directory'] before including the settings file, if the test harness supports it.

🤖 Prompt for AI Agents
In `@tests/phpunit/Drupal/EnvironmentSettingsTest.php` around lines 781 - 785, Add
a new unit test (or extend testEnvironmentAcquiaConfigPathOverride) to verify
the fallback to config_vcs_directory when DRUPAL_CONFIG_PATH is not set:
clear/unset DRUPAL_CONFIG_PATH in the environment, pre-populate/mock the
settings array key $settings['config_vcs_directory'] to a test path before
including/loading the Acquia settings logic, then assert that the resulting
config path resolution uses that $settings['config_vcs_directory'] value;
reference the existing testEnvironmentAcquiaConfigPathOverride behavior and the
$settings['config_vcs_directory'] symbol when implementing the mock and
assertions.


$this->requireSettingsFile();

$config['acquia_hosting_settings_autoconnect'] = FALSE;
$config['config_split.config_split.dev']['status'] = TRUE;
$config['environment_indicator.indicator']['bg_color'] = '#4caf50';
$config['environment_indicator.indicator']['fg_color'] = '#000000';
$config['environment_indicator.indicator']['name'] = self::ENVIRONMENT_DEV;
$config['environment_indicator.settings']['favicon'] = TRUE;
$config['environment_indicator.settings']['toolbar_integration'] = [TRUE];
$config['robotstxt.settings']['content'] = "User-agent: *\nDisallow: /";
$config['shield.settings']['shield_enable'] = TRUE;
$config['system.performance']['cache']['page']['max_age'] = 900;
$this->assertConfig($config);

$settings['auto_create_htaccess'] = TRUE;
$settings['config_exclude_modules'] = [];
$settings['config_sync_directory'] = 'custom_acquia_config';
$settings['container_yamls'][0] = $this->app_root . '/' . $this->site_path . '/services.yml';
$settings['entity_update_batch_size'] = 50;
$settings['environment'] = self::ENVIRONMENT_DEV;
$settings['file_public_path'] = 'sites/default/files';
$settings['file_private_path'] = 'sites/default/files/private';
$settings['file_temp_path'] = '/tmp';
$settings['file_scan_ignore_directories'] = [
'node_modules',
'bower_components',
];
$settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
$settings['maintenance_theme'] = 'claro';
$settings['trusted_host_patterns'] = [
'^localhost$',
];
$this->assertSettings($settings);
}
// phpcs:ignore #;> SETTINGS_PROVIDER_ACQUIA
// phpcs:ignore #;< SETTINGS_PROVIDER_LAGOON
/**
Expand Down
24 changes: 14 additions & 10 deletions web/sites/default/includes/providers/settings.acquia.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,12 @@
require $ah_settings_file;
}
// @codeCoverageIgnoreEnd
// Set the config sync directory to a `config_vcs_directory`, but still
// allow overriding it with the DRUPAL_CONFIG_PATH environment variable.
if (!empty($settings['config_vcs_directory'])) {
$settings['config_sync_directory'] = getenv('DRUPAL_CONFIG_PATH') ?: $settings['config_vcs_directory'];
}

// Automatically create an Apache HTTP .htaccess file in writable directories.
$settings['auto_create_htaccess'] = TRUE;

// Default all environments to 'dev', including ODE environments.
$settings['environment'] = ENVIRONMENT_DEV;

// Do not put any Acquia-specific settings in this code block. It is used
// to explicitly map Acquia environments to $settings['environment']
// variable only.
// Instead, use 'PER-ENVIRONMENT SETTINGS' section below.
switch (getenv('AH_SITE_ENVIRONMENT')) {
case 'prod':
$settings['environment'] = ENVIRONMENT_PROD;
Expand All @@ -57,4 +47,18 @@
$settings['environment'] = ENVIRONMENT_STAGE;
break;
}

// Override the config sync directory with the DRUPAL_CONFIG_PATH environment
// variable if provided, or fall back to the config_vcs_directory setting
// provided by Acquia.
$drupal_config_path = getenv('DRUPAL_CONFIG_PATH');
if (!empty($drupal_config_path)) {
$settings['config_sync_directory'] = $drupal_config_path;
}
elseif (!empty($settings['config_vcs_directory'])) {
$settings['config_sync_directory'] = $settings['config_vcs_directory'];
}

// Automatically create an Apache HTTP .htaccess file in writable directories.
$settings['auto_create_htaccess'] = TRUE;
}