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

fix: fix dotenv loader to work without request matcher and fix tests #71

Merged
merged 3 commits into from
Apr 16, 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
7 changes: 4 additions & 3 deletions .github/workflows/test-drupal-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
branches:
- '6.**'
pull_request:
types: [opened, reopened]
types: [opened, reopened, edited]
jobs:
test-drupal-setup:
name: Build and install drupal project
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup PHP
run: |
sudo update-alternatives --set php /usr/bin/php8.1
Expand All @@ -37,6 +37,7 @@ jobs:
- name: Install composer dependencies.
run: |
composer config platform-check false
composer config --no-plugins allow-plugins.phpstan/extension-installer true
composer create-project
composer install
- name: Setup the environment
Expand All @@ -54,4 +55,4 @@ jobs:
docker-compose exec cli phapp install --no-build
- name: Check connection and response of the site
run: |
curl -v http://example.drupal-project.localdev.space | grep "Drupal 9"
curl -v http://example.drupal-project.localdev.space | grep "Drupal 10"
11 changes: 9 additions & 2 deletions dotenv/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ public static function prepareAppEnvironment() {
if (file_exists(__DIR__ . '/sites/all.env')) {
$vars .= file_get_contents(__DIR__ . '/sites/all.env') . "\n";
}
// Support dots in the environment name and load files by prefix.
// This allows grouping environments by host having shared settings.
if (strpos($phapp_env, '.') !== FALSE) {
$parts = explode('.', $phapp_env, 2);
if (file_exists(__DIR__ . '/sites/all.env-' . $parts[0] . '.env')) {
$vars .= file_get_contents(__DIR__ . '/sites/all.env-' . $parts[0] . '.env') . "\n";
}
}
// Support per-environment all.env files.
if (file_exists(__DIR__ . '/sites/all.env-' . $phapp_env . '.env')) {
$vars .= file_get_contents(__DIR__ . '/sites/all.env-' . $phapp_env . '.env') . "\n";
Expand Down Expand Up @@ -209,7 +217,6 @@ public static function getSiteVariables($site = NULL, $site_variant = '') {
$dotenv->populate($dotenv->parse(PhappEnvironmentLoader::prepareDeterminedEnvironment()), TRUE);

// Match the request and prepare site-specific dotenv vars.
$site = drunomics\MultisiteRequestMatcher\RequestMatcher::getInstance()
->match();
$site = PhappEnvironmentLoader::determineActiveSite();
$dotenv->populate($dotenv->parse(PhappEnvironmentLoader::prepareAppEnvironment()), TRUE);
}
Loading