-
-
Notifications
You must be signed in to change notification settings - Fork 28
Improved Acquia settings with env var overrides and three-tier temp path handling. #2445
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,22 +15,23 @@ | |||||||||||||||||
| declare(strict_types=1); | ||||||||||||||||||
|
|
||||||||||||||||||
| if (!empty(getenv('AH_SITE_ENVIRONMENT'))) { | ||||||||||||||||||
| $ah_site_group = getenv('AH_SITE_GROUP'); | ||||||||||||||||||
| $ah_site_env = getenv('AH_SITE_ENVIRONMENT'); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Delay the initial database connection. | ||||||||||||||||||
| $config['acquia_hosting_settings_autoconnect'] = FALSE; | ||||||||||||||||||
|
|
||||||||||||||||||
| // Include Acquia environment settings. | ||||||||||||||||||
| // 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); | ||||||||||||||||||
| $ah_settings_file = getenv('DRUPAL_ACQUIA_SETTINGS_FILE') ?: sprintf('/var/www/site-php/%s/%s-settings.inc', $ah_site_group, $ah_site_group); | ||||||||||||||||||
| // @codeCoverageIgnoreStart | ||||||||||||||||||
| 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 | ||||||||||||||||||
| } | ||||||||||||||||||
| // @codeCoverageIgnoreEnd | ||||||||||||||||||
|
|
||||||||||||||||||
| // Default all environments to 'dev', including ODE environments. | ||||||||||||||||||
| $settings['environment'] = ENVIRONMENT_DEV; | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -51,14 +52,28 @@ | |||||||||||||||||
| // 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; | ||||||||||||||||||
| $config_path = getenv('DRUPAL_CONFIG_PATH'); | ||||||||||||||||||
| if (!empty($config_path)) { | ||||||||||||||||||
| $settings['config_sync_directory'] = $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; | ||||||||||||||||||
|
|
||||||||||||||||||
| // Allow to override temporary path using per-head mounted directory or | ||||||||||||||||||
| // DRUPAL_TMP_PATH variable. | ||||||||||||||||||
| // @see https://docs.acquia.com/acquia-cloud-platform/manage-apps/files/temporary#section-important-considerations | ||||||||||||||||||
| $settings['file_temp_path'] = '/tmp'; | ||||||||||||||||||
|
|
||||||||||||||||||
| if (!empty($ah_site_group) && getenv('DRUPAL_TMP_PATH_IS_SHARED')) { | ||||||||||||||||||
| // @see https://acquia.my.site.com/s/article/360054835954-Bulk-Upload-Not-Working-Correctly | ||||||||||||||||||
| $settings['file_temp_path'] = sprintf('/mnt/gfs/%s.%s/tmp', $ah_site_group, $ah_site_env); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+71
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: In PHP, getenv($name) returns the string value of the environment variable if it is set, or false if it is unset (does not exist). This behavior is unchanged in PHP 8+. In boolean conditions (e.g., if (getenv('VAR'))), PHP converts the result to bool: - If unset: false → false - If set to non-empty string: true (truthy) - If set to empty string "": false - If set to "0": false (specifically listed as falsy) The string "false" (or any other non-empty string except "0") evaluates to true in boolean contexts. Examples: $unset = getenv('UNSET_VAR'); // false → if($unset) is false $set_empty = getenv('EMPTY'); // "" (if VAR=) → if($set_empty) is false $set_zero = getenv('ZERO'); // "0" → if($set_zero) is false $set_false = getenv('FALSE'); // "false" → if($set_false) is true $set_one = getenv('ONE'); // "1" → if($set_one) is true Citations:
Use explicit comparison for
Suggested fix- if (!empty($ah_site_group) && getenv('DRUPAL_TMP_PATH_IS_SHARED')) {
+ if (!empty($ah_site_group) && getenv('DRUPAL_TMP_PATH_IS_SHARED') === '1') {
// `@see` https://acquia.my.site.com/s/article/360054835954-Bulk-Upload-Not-Working-Correctly
$settings['file_temp_path'] = "/mnt/gfs/{$ah_site_group}.{$ah_site_env}/tmp";
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is intentional. The convention in this project is to use truthiness checks for environment variable flags, consistent with how other env vars are handled in these settings files. Setting DRUPAL_TMP_PATH_IS_SHARED=false is not an expected usage pattern — the variable is either set (to any non-empty value) or unset. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
✏️ Learnings added
|
||||||||||||||||||
|
|
||||||||||||||||||
| if (getenv('DRUPAL_TMP_PATH')) { | ||||||||||||||||||
| $settings['file_temp_path'] = getenv('DRUPAL_TMP_PATH'); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.