Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e7e3593

Browse filesBrowse files
committed
Read environment variable from superglobals
The Dotenv component has recently been switched to using superglobals instead of putenv(). Let us support both and give priority to superglobals. Closes #31857
1 parent 3b0e9df commit e7e3593
Copy full SHA for e7e3593

File tree

3 files changed

+36
-5
lines changed
Filter options

3 files changed

+36
-5
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public static function register($mode = 0)
9090
}
9191
}
9292

93+
public static function registerAndConfigureFromEnvironment()
94+
{
95+
self::register(self::getModeFromEnvironment());
96+
}
97+
9398
public static function collectDeprecations($outputFile)
9499
{
95100
$deprecations = [];
@@ -209,12 +214,28 @@ public function shutdown()
209214
});
210215
}
211216

217+
/**
218+
* @return mixed string|false
219+
*/
220+
private static function getModeFromEnvironment()
221+
{
222+
if (isset($_SERVER['SYMFONY_DEPRECATIONS_HELPER'])) {
223+
return $_SERVER['SYMFONY_DEPRECATIONS_HELPER'];
224+
}
225+
226+
if (isset($_ENV['SYMFONY_DEPRECATIONS_HELPER'])) {
227+
return $_ENV['SYMFONY_DEPRECATIONS_HELPER'];
228+
}
229+
230+
return getenv('SYMFONY_DEPRECATIONS_HELPER');
231+
}
232+
212233
private function getConfiguration()
213234
{
214235
if (null !== $this->configuration) {
215236
return $this->configuration;
216237
}
217-
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
238+
$mode = self::getModeFromEnvironment();
218239
if ('strict' === $mode) {
219240
return $this->configuration = Configuration::inStrictMode();
220241
}

‎src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled.phpt

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/disabled.phpt
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--TEST--
2-
Test DeprecationErrorHandler in weak mode
2+
Test DeprecationErrorHandler in disabled mode
33
--FILE--
44
<?php
55

6-
putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
6+
$_SERVER['SYMFONY_DEPRECATIONS_HELPER'] = 'disabled';
77
putenv('ANSICON');
88
putenv('ConEmuANSI');
99
putenv('TERM');

‎src/Symfony/Bridge/PhpUnit/bootstrap.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/bootstrap.php
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
}
3636
}
3737

38-
if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) {
39-
DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
38+
if (isset($_SERVER['SYMFONY_DEPRECATIONS_HELPER']) && 'disabled' === $_SERVER['SYMFONY_DEPRECATIONS_HELPER']) {
39+
return;
40+
}
41+
42+
if (isset($_ENV['SYMFONY_DEPRECATIONS_HELPER']) && 'disabled' === $_ENV['SYMFONY_DEPRECATIONS_HELPER']) {
43+
return;
4044
}
45+
46+
if ('disabled' === getenv('SYMFONY_DEPRECATIONS_HELPER')) {
47+
return;
48+
}
49+
50+
DeprecationErrorHandler::registerAndConfigureFromEnvironment();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.