Skip to content

Commit 79bc146

Browse files
authored
[#2261] Fixed Acquia settings to allow DRUPAL_CONFIG_PATH override independently of config_vcs_directory. (#2263)
1 parent 72e6150 commit 79bc146

6 files changed

Lines changed: 176 additions & 32 deletions

File tree

.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/docroot/sites/default/includes/providers/settings.acquia.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,12 @@
3131
require $ah_settings_file;
3232
}
3333
// @codeCoverageIgnoreEnd
34-
// Set the config sync directory to a `config_vcs_directory`, but still
35-
// allow overriding it with the DRUPAL_CONFIG_PATH environment variable.
36-
if (!empty($settings['config_vcs_directory'])) {
37-
$settings['config_sync_directory'] = getenv('DRUPAL_CONFIG_PATH') ?: $settings['config_vcs_directory'];
38-
}
39-
40-
// Automatically create an Apache HTTP .htaccess file in writable directories.
41-
$settings['auto_create_htaccess'] = TRUE;
42-
4334
// Default all environments to 'dev', including ODE environments.
4435
$settings['environment'] = ENVIRONMENT_DEV;
4536

4637
// Do not put any Acquia-specific settings in this code block. It is used
4738
// to explicitly map Acquia environments to $settings['environment']
4839
// variable only.
49-
// Instead, use 'PER-ENVIRONMENT SETTINGS' section below.
5040
switch (getenv('AH_SITE_ENVIRONMENT')) {
5141
case 'prod':
5242
$settings['environment'] = ENVIRONMENT_PROD;
@@ -57,4 +47,18 @@
5747
$settings['environment'] = ENVIRONMENT_STAGE;
5848
break;
5949
}
50+
51+
// Override the config sync directory with the DRUPAL_CONFIG_PATH environment
52+
// variable if provided, or fall back to the config_vcs_directory setting
53+
// provided by Acquia.
54+
$drupal_config_path = getenv('DRUPAL_CONFIG_PATH');
55+
if (!empty($drupal_config_path)) {
56+
$settings['config_sync_directory'] = $drupal_config_path;
57+
}
58+
elseif (!empty($settings['config_vcs_directory'])) {
59+
$settings['config_sync_directory'] = $settings['config_vcs_directory'];
60+
}
61+
62+
// Automatically create an Apache HTTP .htaccess file in writable directories.
63+
$settings['auto_create_htaccess'] = TRUE;
6064
}

.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/tests/phpunit/Drupal/EnvironmentSettingsTest.php

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
];
5050
}
5151

52-
@@ -315,6 +359,177 @@
52+
@@ -315,6 +359,221 @@
5353
$settings['skip_permissions_hardening'] = TRUE;
5454
$settings['config_sync_directory'] = '../config/default';
5555
$settings['suspend_mail_send'] = TRUE;
@@ -223,6 +223,50 @@
223223
+ ];
224224
+ $settings['config_sync_directory'] = '../config/default';
225225
+ $settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
226+
+ $settings['maintenance_theme'] = 'claro';
227+
+ $settings['trusted_host_patterns'] = [
228+
+ '^localhost$',
229+
+ ];
230+
+ $this->assertSettings($settings);
231+
+ }
232+
+
233+
+ /**
234+
+ * Test Acquia config_sync_directory override with DRUPAL_CONFIG_PATH.
235+
+ */
236+
+ public function testEnvironmentAcquiaConfigPathOverride(): void {
237+
+ $this->setEnvVars([
238+
+ 'AH_SITE_ENVIRONMENT' => 1,
239+
+ 'DRUPAL_CONFIG_PATH' => 'custom_acquia_config',
240+
+ ]);
241+
+
242+
+ $this->requireSettingsFile();
243+
+
244+
+ $config['acquia_hosting_settings_autoconnect'] = FALSE;
245+
+ $config['config_split.config_split.dev']['status'] = TRUE;
246+
+ $config['environment_indicator.indicator']['bg_color'] = '#4caf50';
247+
+ $config['environment_indicator.indicator']['fg_color'] = '#000000';
248+
+ $config['environment_indicator.indicator']['name'] = self::ENVIRONMENT_DEV;
249+
+ $config['environment_indicator.settings']['favicon'] = TRUE;
250+
+ $config['environment_indicator.settings']['toolbar_integration'] = [TRUE];
251+
+ $config['robotstxt.settings']['content'] = "User-agent: *\nDisallow: /";
252+
+ $config['shield.settings']['shield_enable'] = TRUE;
253+
+ $config['system.performance']['cache']['page']['max_age'] = 900;
254+
+ $this->assertConfig($config);
255+
+
256+
+ $settings['auto_create_htaccess'] = TRUE;
257+
+ $settings['config_exclude_modules'] = [];
258+
+ $settings['config_sync_directory'] = 'custom_acquia_config';
259+
+ $settings['container_yamls'][0] = $this->app_root . '/' . $this->site_path . '/services.yml';
260+
+ $settings['entity_update_batch_size'] = 50;
261+
+ $settings['environment'] = self::ENVIRONMENT_DEV;
262+
+ $settings['file_public_path'] = 'sites/default/files';
263+
+ $settings['file_private_path'] = 'sites/default/files/private';
264+
+ $settings['file_temp_path'] = '/tmp';
265+
+ $settings['file_scan_ignore_directories'] = [
266+
+ 'node_modules',
267+
+ 'bower_components',
268+
+ ];
269+
+ $settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
226270
+ $settings['maintenance_theme'] = 'claro';
227271
$settings['trusted_host_patterns'] = [
228272
'^localhost$',

.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/docroot/sites/default/includes/providers/settings.acquia.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,12 @@
3131
require $ah_settings_file;
3232
}
3333
// @codeCoverageIgnoreEnd
34-
// Set the config sync directory to a `config_vcs_directory`, but still
35-
// allow overriding it with the DRUPAL_CONFIG_PATH environment variable.
36-
if (!empty($settings['config_vcs_directory'])) {
37-
$settings['config_sync_directory'] = getenv('DRUPAL_CONFIG_PATH') ?: $settings['config_vcs_directory'];
38-
}
39-
40-
// Automatically create an Apache HTTP .htaccess file in writable directories.
41-
$settings['auto_create_htaccess'] = TRUE;
42-
4334
// Default all environments to 'dev', including ODE environments.
4435
$settings['environment'] = ENVIRONMENT_DEV;
4536

4637
// Do not put any Acquia-specific settings in this code block. It is used
4738
// to explicitly map Acquia environments to $settings['environment']
4839
// variable only.
49-
// Instead, use 'PER-ENVIRONMENT SETTINGS' section below.
5040
switch (getenv('AH_SITE_ENVIRONMENT')) {
5141
case 'prod':
5242
$settings['environment'] = ENVIRONMENT_PROD;
@@ -57,4 +47,18 @@
5747
$settings['environment'] = ENVIRONMENT_STAGE;
5848
break;
5949
}
50+
51+
// Override the config sync directory with the DRUPAL_CONFIG_PATH environment
52+
// variable if provided, or fall back to the config_vcs_directory setting
53+
// provided by Acquia.
54+
$drupal_config_path = getenv('DRUPAL_CONFIG_PATH');
55+
if (!empty($drupal_config_path)) {
56+
$settings['config_sync_directory'] = $drupal_config_path;
57+
}
58+
elseif (!empty($settings['config_vcs_directory'])) {
59+
$settings['config_sync_directory'] = $settings['config_vcs_directory'];
60+
}
61+
62+
// Automatically create an Apache HTTP .htaccess file in writable directories.
63+
$settings['auto_create_htaccess'] = TRUE;
6064
}

.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/tests/phpunit/Drupal/EnvironmentSettingsTest.php

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
];
5050
}
5151

52-
@@ -315,6 +359,177 @@
52+
@@ -315,6 +359,221 @@
5353
$settings['skip_permissions_hardening'] = TRUE;
5454
$settings['config_sync_directory'] = '../config/default';
5555
$settings['suspend_mail_send'] = TRUE;
@@ -223,6 +223,50 @@
223223
+ ];
224224
+ $settings['config_sync_directory'] = '../config/default';
225225
+ $settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
226+
+ $settings['maintenance_theme'] = 'claro';
227+
+ $settings['trusted_host_patterns'] = [
228+
+ '^localhost$',
229+
+ ];
230+
+ $this->assertSettings($settings);
231+
+ }
232+
+
233+
+ /**
234+
+ * Test Acquia config_sync_directory override with DRUPAL_CONFIG_PATH.
235+
+ */
236+
+ public function testEnvironmentAcquiaConfigPathOverride(): void {
237+
+ $this->setEnvVars([
238+
+ 'AH_SITE_ENVIRONMENT' => 1,
239+
+ 'DRUPAL_CONFIG_PATH' => 'custom_acquia_config',
240+
+ ]);
241+
+
242+
+ $this->requireSettingsFile();
243+
+
244+
+ $config['acquia_hosting_settings_autoconnect'] = FALSE;
245+
+ $config['config_split.config_split.dev']['status'] = TRUE;
246+
+ $config['environment_indicator.indicator']['bg_color'] = '#4caf50';
247+
+ $config['environment_indicator.indicator']['fg_color'] = '#000000';
248+
+ $config['environment_indicator.indicator']['name'] = self::ENVIRONMENT_DEV;
249+
+ $config['environment_indicator.settings']['favicon'] = TRUE;
250+
+ $config['environment_indicator.settings']['toolbar_integration'] = [TRUE];
251+
+ $config['robotstxt.settings']['content'] = "User-agent: *\nDisallow: /";
252+
+ $config['shield.settings']['shield_enable'] = TRUE;
253+
+ $config['system.performance']['cache']['page']['max_age'] = 900;
254+
+ $this->assertConfig($config);
255+
+
256+
+ $settings['auto_create_htaccess'] = TRUE;
257+
+ $settings['config_exclude_modules'] = [];
258+
+ $settings['config_sync_directory'] = 'custom_acquia_config';
259+
+ $settings['container_yamls'][0] = $this->app_root . '/' . $this->site_path . '/services.yml';
260+
+ $settings['entity_update_batch_size'] = 50;
261+
+ $settings['environment'] = self::ENVIRONMENT_DEV;
262+
+ $settings['file_public_path'] = 'sites/default/files';
263+
+ $settings['file_private_path'] = 'sites/default/files/private';
264+
+ $settings['file_temp_path'] = '/tmp';
265+
+ $settings['file_scan_ignore_directories'] = [
266+
+ 'node_modules',
267+
+ 'bower_components',
268+
+ ];
269+
+ $settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
226270
+ $settings['maintenance_theme'] = 'claro';
227271
$settings['trusted_host_patterns'] = [
228272
'^localhost$',

tests/phpunit/Drupal/EnvironmentSettingsTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,50 @@ public function testEnvironmentAcquiaProd(): void {
774774
];
775775
$this->assertSettings($settings);
776776
}
777+
778+
/**
779+
* Test Acquia config_sync_directory override with DRUPAL_CONFIG_PATH.
780+
*/
781+
public function testEnvironmentAcquiaConfigPathOverride(): void {
782+
$this->setEnvVars([
783+
'AH_SITE_ENVIRONMENT' => 1,
784+
'DRUPAL_CONFIG_PATH' => 'custom_acquia_config',
785+
]);
786+
787+
$this->requireSettingsFile();
788+
789+
$config['acquia_hosting_settings_autoconnect'] = FALSE;
790+
$config['config_split.config_split.dev']['status'] = TRUE;
791+
$config['environment_indicator.indicator']['bg_color'] = '#4caf50';
792+
$config['environment_indicator.indicator']['fg_color'] = '#000000';
793+
$config['environment_indicator.indicator']['name'] = self::ENVIRONMENT_DEV;
794+
$config['environment_indicator.settings']['favicon'] = TRUE;
795+
$config['environment_indicator.settings']['toolbar_integration'] = [TRUE];
796+
$config['robotstxt.settings']['content'] = "User-agent: *\nDisallow: /";
797+
$config['shield.settings']['shield_enable'] = TRUE;
798+
$config['system.performance']['cache']['page']['max_age'] = 900;
799+
$this->assertConfig($config);
800+
801+
$settings['auto_create_htaccess'] = TRUE;
802+
$settings['config_exclude_modules'] = [];
803+
$settings['config_sync_directory'] = 'custom_acquia_config';
804+
$settings['container_yamls'][0] = $this->app_root . '/' . $this->site_path . '/services.yml';
805+
$settings['entity_update_batch_size'] = 50;
806+
$settings['environment'] = self::ENVIRONMENT_DEV;
807+
$settings['file_public_path'] = 'sites/default/files';
808+
$settings['file_private_path'] = 'sites/default/files/private';
809+
$settings['file_temp_path'] = '/tmp';
810+
$settings['file_scan_ignore_directories'] = [
811+
'node_modules',
812+
'bower_components',
813+
];
814+
$settings['hash_salt'] = hash('sha256', getenv('DATABASE_HOST') ?: 'localhost');
815+
$settings['maintenance_theme'] = 'claro';
816+
$settings['trusted_host_patterns'] = [
817+
'^localhost$',
818+
];
819+
$this->assertSettings($settings);
820+
}
777821
// phpcs:ignore #;> SETTINGS_PROVIDER_ACQUIA
778822
// phpcs:ignore #;< SETTINGS_PROVIDER_LAGOON
779823
/**

web/sites/default/includes/providers/settings.acquia.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,12 @@
3131
require $ah_settings_file;
3232
}
3333
// @codeCoverageIgnoreEnd
34-
// Set the config sync directory to a `config_vcs_directory`, but still
35-
// allow overriding it with the DRUPAL_CONFIG_PATH environment variable.
36-
if (!empty($settings['config_vcs_directory'])) {
37-
$settings['config_sync_directory'] = getenv('DRUPAL_CONFIG_PATH') ?: $settings['config_vcs_directory'];
38-
}
39-
40-
// Automatically create an Apache HTTP .htaccess file in writable directories.
41-
$settings['auto_create_htaccess'] = TRUE;
42-
4334
// Default all environments to 'dev', including ODE environments.
4435
$settings['environment'] = ENVIRONMENT_DEV;
4536

4637
// Do not put any Acquia-specific settings in this code block. It is used
4738
// to explicitly map Acquia environments to $settings['environment']
4839
// variable only.
49-
// Instead, use 'PER-ENVIRONMENT SETTINGS' section below.
5040
switch (getenv('AH_SITE_ENVIRONMENT')) {
5141
case 'prod':
5242
$settings['environment'] = ENVIRONMENT_PROD;
@@ -57,4 +47,18 @@
5747
$settings['environment'] = ENVIRONMENT_STAGE;
5848
break;
5949
}
50+
51+
// Override the config sync directory with the DRUPAL_CONFIG_PATH environment
52+
// variable if provided, or fall back to the config_vcs_directory setting
53+
// provided by Acquia.
54+
$drupal_config_path = getenv('DRUPAL_CONFIG_PATH');
55+
if (!empty($drupal_config_path)) {
56+
$settings['config_sync_directory'] = $drupal_config_path;
57+
}
58+
elseif (!empty($settings['config_vcs_directory'])) {
59+
$settings['config_sync_directory'] = $settings['config_vcs_directory'];
60+
}
61+
62+
// Automatically create an Apache HTTP .htaccess file in writable directories.
63+
$settings['auto_create_htaccess'] = TRUE;
6064
}

0 commit comments

Comments
 (0)