Skip to content

Commit 72e6150

Browse files
authored
[#2202] Updated Acquia settings to use env variables to include the cloud setting file. (#2260)
1 parent 5f60d7c commit 72e6150

5 files changed

Lines changed: 41 additions & 20 deletions

File tree

.vortex/installer/src/Prompts/Handlers/HostingProjectName.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ public function discover(): null|string|bool|array {
7070
return $v;
7171
}
7272

73-
// Try to discover from settings.acquia.php.
73+
// @deprecated Discovery from hardcoded path in settings.acquia.php. The
74+
// new settings.acquia.php uses AH_SITE_GROUP environment variable instead
75+
// of a hardcoded project name. Kept for backward compatibility with older
76+
// installations.
7477
$acquia_settings_file = $this->dstDir . sprintf('/%s/sites/default/includes/providers/settings.acquia.php', $this->webroot);
7578
if (file_exists($acquia_settings_file)) {
7679
$content = file_get_contents($acquia_settings_file);
@@ -125,6 +128,10 @@ public function process(): void {
125128
$w = $this->webroot;
126129

127130
Env::writeValueDotenv('VORTEX_ACQUIA_APP_NAME', $v, $t . '/.env');
131+
// @deprecated The settings.acquia.php no longer uses hardcoded project
132+
// names - it uses AH_SITE_GROUP environment variable instead. This
133+
// replacement is kept for backward compatibility with older installations
134+
// that may still use the hardcoded path pattern.
128135
File::replaceContentInFile($t . '/' . $w . '/sites/default/includes/providers/settings.acquia.php', 'your_site', $v);
129136

130137
Env::writeValueDotenv('LAGOON_PROJECT', $v, $t . '/.env');

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@
1919
$config['acquia_hosting_settings_autoconnect'] = FALSE;
2020

2121
// Include Acquia environment settings.
22-
if (file_exists('/var/www/site-php/star_wars/star_wars-settings.inc')) {
23-
// @codeCoverageIgnoreStart
24-
// @phpstan-ignore-next-line
25-
require '/var/www/site-php/star_wars/star_wars-settings.inc';
26-
// @codeCoverageIgnoreEnd
22+
// The path is built dynamically from the AH_SITE_GROUP environment variable
23+
// provided by Acquia Cloud.
24+
$ah_site_group = getenv('AH_SITE_GROUP');
25+
// @codeCoverageIgnoreStart
26+
if (!empty($ah_site_group)) {
27+
$ah_settings_file = sprintf('/var/www/site-php/%s/%s-settings.inc', $ah_site_group, $ah_site_group);
28+
if (!file_exists($ah_settings_file)) {
29+
throw new \RuntimeException(sprintf('Acquia settings file "%s" not found. Check Acquia Cloud environment configuration.', $ah_settings_file));
30+
}
31+
require $ah_settings_file;
2732
}
28-
33+
// @codeCoverageIgnoreEnd
2934
// Set the config sync directory to a `config_vcs_directory`, but still
3035
// allow overriding it with the DRUPAL_CONFIG_PATH environment variable.
3136
if (!empty($settings['config_vcs_directory'])) {

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@
1919
$config['acquia_hosting_settings_autoconnect'] = FALSE;
2020

2121
// Include Acquia environment settings.
22-
if (file_exists('/var/www/site-php/my_custom_acquia-project/my_custom_acquia-project-settings.inc')) {
23-
// @codeCoverageIgnoreStart
24-
// @phpstan-ignore-next-line
25-
require '/var/www/site-php/my_custom_acquia-project/my_custom_acquia-project-settings.inc';
26-
// @codeCoverageIgnoreEnd
22+
// The path is built dynamically from the AH_SITE_GROUP environment variable
23+
// provided by Acquia Cloud.
24+
$ah_site_group = getenv('AH_SITE_GROUP');
25+
// @codeCoverageIgnoreStart
26+
if (!empty($ah_site_group)) {
27+
$ah_settings_file = sprintf('/var/www/site-php/%s/%s-settings.inc', $ah_site_group, $ah_site_group);
28+
if (!file_exists($ah_settings_file)) {
29+
throw new \RuntimeException(sprintf('Acquia settings file "%s" not found. Check Acquia Cloud environment configuration.', $ah_settings_file));
30+
}
31+
require $ah_settings_file;
2732
}
28-
33+
// @codeCoverageIgnoreEnd
2934
// Set the config sync directory to a `config_vcs_directory`, but still
3035
// allow overriding it with the DRUPAL_CONFIG_PATH environment variable.
3136
if (!empty($settings['config_vcs_directory'])) {

.vortex/installer/tests/Functional/Handlers/HostingProjectNameHandlerProcessTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public static function dataProviderHandlerProcess(): array {
2424
static::cw(function (FunctionalTestCase $test): void {
2525
$test->assertSutContains([
2626
'VORTEX_ACQUIA_APP_NAME=my_custom_acquia-project',
27-
'/site-php\/my_custom_acquia-project\/my_custom_acquia-project-settings\.inc/',
2827
]);
2928
}),
3029
],

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@
1919
$config['acquia_hosting_settings_autoconnect'] = FALSE;
2020

2121
// Include Acquia environment settings.
22-
if (file_exists('/var/www/site-php/your_site/your_site-settings.inc')) {
23-
// @codeCoverageIgnoreStart
24-
// @phpstan-ignore-next-line
25-
require '/var/www/site-php/your_site/your_site-settings.inc';
26-
// @codeCoverageIgnoreEnd
22+
// The path is built dynamically from the AH_SITE_GROUP environment variable
23+
// provided by Acquia Cloud.
24+
$ah_site_group = getenv('AH_SITE_GROUP');
25+
// @codeCoverageIgnoreStart
26+
if (!empty($ah_site_group)) {
27+
$ah_settings_file = sprintf('/var/www/site-php/%s/%s-settings.inc', $ah_site_group, $ah_site_group);
28+
if (!file_exists($ah_settings_file)) {
29+
throw new \RuntimeException(sprintf('Acquia settings file "%s" not found. Check Acquia Cloud environment configuration.', $ah_settings_file));
30+
}
31+
require $ah_settings_file;
2732
}
28-
33+
// @codeCoverageIgnoreEnd
2934
// Set the config sync directory to a `config_vcs_directory`, but still
3035
// allow overriding it with the DRUPAL_CONFIG_PATH environment variable.
3136
if (!empty($settings['config_vcs_directory'])) {

0 commit comments

Comments
 (0)