From 21e831f071b7f7ade5dbb527dbbf348680a0a6c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Wed, 20 Dec 2023 21:50:28 +0100 Subject: [PATCH] Fix inconsistency with .env loaders out of the box PHP .env loaders such as `symfony/dotenv` or `vlucas/phpdotenv` populate `$_ENV` out of the box, but don't call `putenv()` in order to preserve thread safeness. This means .env is loaded by them, but AWS SDK does not read it, creating inconsistent experience when handling real env variables and env variables loaded by these loaders --- .../Aws/Test/Integ/ClientSideMonitoringContext.php | 2 ++ features/bootstrap/Aws/Test/Integ/IntegUtils.php | 2 ++ src/AbstractConfigurationProvider.php | 2 ++ src/ClientResolver.php | 2 ++ src/ClientSideMonitoring/ConfigurationProvider.php | 2 ++ src/Configuration/ConfigurationResolver.php | 2 ++ .../AssumeRoleWithWebIdentityCredentialProvider.php | 2 ++ src/Credentials/CredentialProvider.php | 2 ++ src/Credentials/EcsCredentialProvider.php | 2 ++ src/Credentials/InstanceProfileProvider.php | 2 ++ src/DefaultsMode/ConfigurationProvider.php | 2 ++ .../UseDualstackEndpoint/ConfigurationProvider.php | 2 ++ src/Endpoint/UseFipsEndpoint/ConfigurationProvider.php | 2 ++ src/EndpointDiscovery/ConfigurationProvider.php | 2 ++ src/Middleware.php | 2 ++ src/Retry/ConfigurationProvider.php | 2 ++ src/S3/RegionalEndpoint/ConfigurationProvider.php | 2 ++ src/S3/UseArnRegion/ConfigurationProvider.php | 2 ++ src/Sts/RegionalEndpoints/ConfigurationProvider.php | 2 ++ src/Token/ParsesIniTrait.php | 2 ++ src/Token/SsoTokenProvider.php | 2 ++ src/Token/TokenProvider.php | 2 ++ src/functions.php | 8 ++++++++ tests/FunctionsTest.php | 9 +++++++++ 24 files changed, 61 insertions(+) diff --git a/features/bootstrap/Aws/Test/Integ/ClientSideMonitoringContext.php b/features/bootstrap/Aws/Test/Integ/ClientSideMonitoringContext.php index 34e1502770..398ba822da 100644 --- a/features/bootstrap/Aws/Test/Integ/ClientSideMonitoringContext.php +++ b/features/bootstrap/Aws/Test/Integ/ClientSideMonitoringContext.php @@ -21,6 +21,8 @@ use PHPUnit\Framework\Assert; use Yoast\PHPUnitPolyfills\TestCases\TestCase; +use function Aws\getenv; + class ClientSideMonitoringContext extends TestCase implements Context, SnippetAcceptingContext { diff --git a/features/bootstrap/Aws/Test/Integ/IntegUtils.php b/features/bootstrap/Aws/Test/Integ/IntegUtils.php index 46bdd1e6f0..2d2c84a187 100644 --- a/features/bootstrap/Aws/Test/Integ/IntegUtils.php +++ b/features/bootstrap/Aws/Test/Integ/IntegUtils.php @@ -1,6 +1,8 @@ assertEquals(false, Aws\getenv('FOO')); + $this->assertEquals($_ENV['FOO'] = 'bar', Aws\getenv('FOO')); + } }