Skip to content
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

DQA-9566: DRUPAL_REVERSE_PROXY not properly set #781

Merged
merged 3 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/TaskRunner/Commands/DrupalCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ protected function getToolkitSettingsBlock()
\$settings['file_temp_path'] = getenv('DRUPAL_FILE_TEMP_PATH') !== FALSE ? getenv('DRUPAL_FILE_TEMP_PATH') : '/tmp';

// Reverse proxy.
if (intval(getenv('DRUPAL_REVERSE_PROXY_ENABLE')) === 1) {
\$settings['reverse_proxy'] = (bool) getenv('DRUPAL_REVERSE_PROXY_ENABLE');
if (filter_var(getenv('DRUPAL_REVERSE_PROXY_ENABLE'), FILTER_VALIDATE_BOOLEAN)) {
\$settings['reverse_proxy'] = getenv('DRUPAL_REVERSE_PROXY_ENABLE');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be like this: $settings['reverse_proxy'] = true; ? Usage of FILTER_VALIDATE_BOOLEAN can handle multiple truthy values like "1", "true", "on" and "yes" and assigns the raw value of getenv('DRUPAL_REVERSE_PROXY_ENABLE') to $settings['reverse_proxy'], which could be a string ("true", "1", etc.).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Ozyrys ,
The problem is the different infrastructures, in one side it should be True and another should be 1.
To make this more flexible, I decided to let it just receive the value defined by each project, but using the filter_var() just to ensure that is set and is any kind of positive.
Let me know if it make sense.

\$settings['reverse_proxy_addresses'] = explode(',', getenv('DRUPAL_REVERSE_PROXY_ADDRESSES'));
}

Expand Down
12 changes: 6 additions & 6 deletions tests/fixtures/commands/drupal-settings-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
$settings['file_temp_path'] = getenv('DRUPAL_FILE_TEMP_PATH') !== FALSE ? getenv('DRUPAL_FILE_TEMP_PATH') : '/tmp';

// Reverse proxy.
if (intval(getenv('DRUPAL_REVERSE_PROXY_ENABLE')) === 1) {
$settings['reverse_proxy'] = (bool) getenv('DRUPAL_REVERSE_PROXY_ENABLE');
if (filter_var(getenv('DRUPAL_REVERSE_PROXY_ENABLE'), FILTER_VALIDATE_BOOLEAN)) {
$settings['reverse_proxy'] = getenv('DRUPAL_REVERSE_PROXY_ENABLE');
$settings['reverse_proxy_addresses'] = explode(',', getenv('DRUPAL_REVERSE_PROXY_ADDRESSES'));
}

Expand Down Expand Up @@ -103,8 +103,8 @@
$settings['file_temp_path'] = getenv('DRUPAL_FILE_TEMP_PATH') !== FALSE ? getenv('DRUPAL_FILE_TEMP_PATH') : '/tmp';

// Reverse proxy.
if (intval(getenv('DRUPAL_REVERSE_PROXY_ENABLE')) === 1) {
$settings['reverse_proxy'] = (bool) getenv('DRUPAL_REVERSE_PROXY_ENABLE');
if (filter_var(getenv('DRUPAL_REVERSE_PROXY_ENABLE'), FILTER_VALIDATE_BOOLEAN)) {
$settings['reverse_proxy'] = getenv('DRUPAL_REVERSE_PROXY_ENABLE');
$settings['reverse_proxy_addresses'] = explode(',', getenv('DRUPAL_REVERSE_PROXY_ADDRESSES'));
}

Expand Down Expand Up @@ -167,8 +167,8 @@
$settings['file_temp_path'] = getenv('DRUPAL_FILE_TEMP_PATH') !== FALSE ? getenv('DRUPAL_FILE_TEMP_PATH') : '/tmp';

// Reverse proxy.
if (intval(getenv('DRUPAL_REVERSE_PROXY_ENABLE')) === 1) {
$settings['reverse_proxy'] = (bool) getenv('DRUPAL_REVERSE_PROXY_ENABLE');
if (filter_var(getenv('DRUPAL_REVERSE_PROXY_ENABLE'), FILTER_VALIDATE_BOOLEAN)) {
$settings['reverse_proxy'] = getenv('DRUPAL_REVERSE_PROXY_ENABLE');
$settings['reverse_proxy_addresses'] = explode(',', getenv('DRUPAL_REVERSE_PROXY_ADDRESSES'));
}

Expand Down