diff --git a/.vortex/installer/src/Prompts/Handlers/HostingProjectName.php b/.vortex/installer/src/Prompts/Handlers/HostingProjectName.php index 0e9fa5c8d..0e9d66b56 100644 --- a/.vortex/installer/src/Prompts/Handlers/HostingProjectName.php +++ b/.vortex/installer/src/Prompts/Handlers/HostingProjectName.php @@ -70,7 +70,10 @@ public function discover(): null|string|bool|array { return $v; } - // Try to discover from settings.acquia.php. + // @deprecated Discovery from hardcoded path in settings.acquia.php. The + // new settings.acquia.php uses AH_SITE_GROUP environment variable instead + // of a hardcoded project name. Kept for backward compatibility with older + // installations. $acquia_settings_file = $this->dstDir . sprintf('/%s/sites/default/includes/providers/settings.acquia.php', $this->webroot); if (file_exists($acquia_settings_file)) { $content = file_get_contents($acquia_settings_file); @@ -125,6 +128,10 @@ public function process(): void { $w = $this->webroot; Env::writeValueDotenv('VORTEX_ACQUIA_APP_NAME', $v, $t . '/.env'); + // @deprecated The settings.acquia.php no longer uses hardcoded project + // names - it uses AH_SITE_GROUP environment variable instead. This + // replacement is kept for backward compatibility with older installations + // that may still use the hardcoded path pattern. File::replaceContentInFile($t . '/' . $w . '/sites/default/includes/providers/settings.acquia.php', 'your_site', $v); Env::writeValueDotenv('LAGOON_PROJECT', $v, $t . '/.env'); diff --git a/.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/docroot/sites/default/includes/providers/settings.acquia.php b/.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/docroot/sites/default/includes/providers/settings.acquia.php index 6f3020bcc..18f137138 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/docroot/sites/default/includes/providers/settings.acquia.php +++ b/.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/docroot/sites/default/includes/providers/settings.acquia.php @@ -19,13 +19,18 @@ $config['acquia_hosting_settings_autoconnect'] = FALSE; // Include Acquia environment settings. - if (file_exists('/var/www/site-php/star_wars/star_wars-settings.inc')) { - // @codeCoverageIgnoreStart - // @phpstan-ignore-next-line - require '/var/www/site-php/star_wars/star_wars-settings.inc'; - // @codeCoverageIgnoreEnd + // The path is built dynamically from the AH_SITE_GROUP environment variable + // provided by Acquia Cloud. + $ah_site_group = getenv('AH_SITE_GROUP'); + // @codeCoverageIgnoreStart + if (!empty($ah_site_group)) { + $ah_settings_file = sprintf('/var/www/site-php/%s/%s-settings.inc', $ah_site_group, $ah_site_group); + if (!file_exists($ah_settings_file)) { + throw new \RuntimeException(sprintf('Acquia settings file "%s" not found. Check Acquia Cloud environment configuration.', $ah_settings_file)); + } + 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'])) { diff --git a/.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/docroot/sites/default/includes/providers/settings.acquia.php b/.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/docroot/sites/default/includes/providers/settings.acquia.php index 1c1269653..18f137138 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/docroot/sites/default/includes/providers/settings.acquia.php +++ b/.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/docroot/sites/default/includes/providers/settings.acquia.php @@ -19,13 +19,18 @@ $config['acquia_hosting_settings_autoconnect'] = FALSE; // Include Acquia environment settings. - if (file_exists('/var/www/site-php/my_custom_acquia-project/my_custom_acquia-project-settings.inc')) { - // @codeCoverageIgnoreStart - // @phpstan-ignore-next-line - require '/var/www/site-php/my_custom_acquia-project/my_custom_acquia-project-settings.inc'; - // @codeCoverageIgnoreEnd + // The path is built dynamically from the AH_SITE_GROUP environment variable + // provided by Acquia Cloud. + $ah_site_group = getenv('AH_SITE_GROUP'); + // @codeCoverageIgnoreStart + if (!empty($ah_site_group)) { + $ah_settings_file = sprintf('/var/www/site-php/%s/%s-settings.inc', $ah_site_group, $ah_site_group); + if (!file_exists($ah_settings_file)) { + throw new \RuntimeException(sprintf('Acquia settings file "%s" not found. Check Acquia Cloud environment configuration.', $ah_settings_file)); + } + 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'])) { diff --git a/.vortex/installer/tests/Functional/Handlers/HostingProjectNameHandlerProcessTest.php b/.vortex/installer/tests/Functional/Handlers/HostingProjectNameHandlerProcessTest.php index d227969d7..12cd3b102 100644 --- a/.vortex/installer/tests/Functional/Handlers/HostingProjectNameHandlerProcessTest.php +++ b/.vortex/installer/tests/Functional/Handlers/HostingProjectNameHandlerProcessTest.php @@ -24,7 +24,6 @@ public static function dataProviderHandlerProcess(): array { static::cw(function (FunctionalTestCase $test): void { $test->assertSutContains([ 'VORTEX_ACQUIA_APP_NAME=my_custom_acquia-project', - '/site-php\/my_custom_acquia-project\/my_custom_acquia-project-settings\.inc/', ]); }), ], diff --git a/web/sites/default/includes/providers/settings.acquia.php b/web/sites/default/includes/providers/settings.acquia.php index 70876d512..18f137138 100644 --- a/web/sites/default/includes/providers/settings.acquia.php +++ b/web/sites/default/includes/providers/settings.acquia.php @@ -19,13 +19,18 @@ $config['acquia_hosting_settings_autoconnect'] = FALSE; // Include Acquia environment settings. - if (file_exists('/var/www/site-php/your_site/your_site-settings.inc')) { - // @codeCoverageIgnoreStart - // @phpstan-ignore-next-line - require '/var/www/site-php/your_site/your_site-settings.inc'; - // @codeCoverageIgnoreEnd + // The path is built dynamically from the AH_SITE_GROUP environment variable + // provided by Acquia Cloud. + $ah_site_group = getenv('AH_SITE_GROUP'); + // @codeCoverageIgnoreStart + if (!empty($ah_site_group)) { + $ah_settings_file = sprintf('/var/www/site-php/%s/%s-settings.inc', $ah_site_group, $ah_site_group); + if (!file_exists($ah_settings_file)) { + throw new \RuntimeException(sprintf('Acquia settings file "%s" not found. Check Acquia Cloud environment configuration.', $ah_settings_file)); + } + 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'])) {