-
-
Notifications
You must be signed in to change notification settings - Fork 28
[#2202] Updated Acquia settings to use env variables to include the cloud setting file. #2260
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
Conversation
WalkthroughReplaces a hardcoded Acquia settings include with a path built from the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
1802c0e to
db68431
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@web/sites/default/includes/providers/settings.acquia.php`:
- Around line 22-33: The code currently reads $ah_site_group from
getenv('AH_SITE_GROUP') and silently skips requiring the Acquia settings file
when it's empty; update the logic so that if getenv('AH_SITE_ENVIRONMENT') is
non-empty but $ah_site_group is empty, you throw a RuntimeException indicating
missing AH_SITE_GROUP (before attempting to build $ah_settings_file or require
it). In practice, add a check referencing getenv('AH_SITE_ENVIRONMENT') and
$ah_site_group and throw a descriptive RuntimeException when AH_SITE_ENVIRONMENT
is present but AH_SITE_GROUP is not, keeping the existing
$ah_settings_file/file_exists/require flow unchanged otherwise.
| // The path is built dynamically from the AH_SITE_GROUP environment variable | ||
| // provided by Acquia Cloud. | ||
| // @codeCoverageIgnoreStart | ||
| $ah_site_group = getenv('AH_SITE_GROUP'); | ||
| 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)); | ||
| } | ||
| // @phpstan-ignore-next-line | ||
| require '/var/www/site-php/your_site/your_site-settings.inc'; | ||
| // @codeCoverageIgnoreEnd | ||
| require $ah_settings_file; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail fast when AH_SITE_GROUP is missing.
When AH_SITE_ENVIRONMENT is set but AH_SITE_GROUP is empty, this silently skips the include and doesn’t signal misconfiguration. The objective calls for a hard failure on misconfigured Acquia env vars—please throw if AH_SITE_GROUP is not set.
✅ Suggested fix
// `@codeCoverageIgnoreStart`
$ah_site_group = getenv('AH_SITE_GROUP');
- 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));
- }
- // `@phpstan-ignore-next-line`
- require $ah_settings_file;
- }
+ if (empty($ah_site_group)) {
+ throw new \RuntimeException('AH_SITE_GROUP is not set. Check Acquia Cloud environment configuration.');
+ }
+ $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));
+ }
+ // `@phpstan-ignore-next-line`
+ require $ah_settings_file;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // The path is built dynamically from the AH_SITE_GROUP environment variable | |
| // provided by Acquia Cloud. | |
| // @codeCoverageIgnoreStart | |
| $ah_site_group = getenv('AH_SITE_GROUP'); | |
| 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)); | |
| } | |
| // @phpstan-ignore-next-line | |
| require '/var/www/site-php/your_site/your_site-settings.inc'; | |
| // @codeCoverageIgnoreEnd | |
| require $ah_settings_file; | |
| } | |
| // The path is built dynamically from the AH_SITE_GROUP environment variable | |
| // provided by Acquia Cloud. | |
| // `@codeCoverageIgnoreStart` | |
| $ah_site_group = getenv('AH_SITE_GROUP'); | |
| if (empty($ah_site_group)) { | |
| throw new \RuntimeException('AH_SITE_GROUP is not set. Check Acquia Cloud environment configuration.'); | |
| } | |
| $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)); | |
| } | |
| // `@phpstan-ignore-next-line` | |
| require $ah_settings_file; |
🤖 Prompt for AI Agents
In `@web/sites/default/includes/providers/settings.acquia.php` around lines 22 -
33, The code currently reads $ah_site_group from getenv('AH_SITE_GROUP') and
silently skips requiring the Acquia settings file when it's empty; update the
logic so that if getenv('AH_SITE_ENVIRONMENT') is non-empty but $ah_site_group
is empty, you throw a RuntimeException indicating missing AH_SITE_GROUP (before
attempting to build $ah_settings_file or require it). In practice, add a check
referencing getenv('AH_SITE_ENVIRONMENT') and $ah_site_group and throw a
descriptive RuntimeException when AH_SITE_ENVIRONMENT is present but
AH_SITE_GROUP is not, keeping the existing $ah_settings_file/file_exists/require
flow unchanged otherwise.
…loud setting file.
db68431 to
3c0a000
Compare
|
|
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2260 +/- ##
==========================================
- Coverage 77.05% 76.44% -0.61%
==========================================
Files 114 107 -7
Lines 5988 5829 -159
Branches 44 0 -44
==========================================
- Hits 4614 4456 -158
+ Misses 1374 1373 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes #2202
Summary by CodeRabbit
Refactor
Bug Fixes
Tests