Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15461126
D19685.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D19685.id.diff
View Options
diff --git a/scripts/__init_script__.php b/scripts/__init_script__.php
--- a/scripts/__init_script__.php
+++ b/scripts/__init_script__.php
@@ -1,11 +1,5 @@
<?php
-if (function_exists('pcntl_async_signals')) {
- pcntl_async_signals(true);
-} else {
- declare(ticks = 1);
-}
-
function __phutil_init_script__() {
// Adjust the runtime language configuration to be reasonable and inline with
// expectations. We do this first, then load libraries.
@@ -86,6 +80,11 @@
require_once $root.'/src/__phutil_library_init__.php';
PhutilErrorHandler::initialize();
+
+ // If "variables_order" excludes "E", silently repair it so that $_ENV has
+ // the values we expect.
+ PhutilExecutionEnvironment::repairMissingVariablesOrder();
+
$router = PhutilSignalRouter::initialize();
$handler = new PhutilBacktraceSignalHandler();
diff --git a/src/utils/PhutilExecutionEnvironment.php b/src/utils/PhutilExecutionEnvironment.php
--- a/src/utils/PhutilExecutionEnvironment.php
+++ b/src/utils/PhutilExecutionEnvironment.php
@@ -13,4 +13,34 @@
return php_uname('r');
}
+ /**
+ * If the PHP configuration setting "variables_order" does not include "E",
+ * the `$_ENV` superglobal is not populated with the containing environment.
+ * For details, see T12071.
+ *
+ * This can be fixed by adding "E" to the configuration, but we can also
+ * repair it ourselves by re-executing a subprocess with the configuration
+ * option defined to include "E". This is clumsy, but saves users from
+ * needing to go find and edit their PHP files.
+ *
+ * @return void
+ */
+ public static function repairMissingVariablesOrder() {
+ $variables_order = ini_get('variables_order');
+ $variables_order = strtoupper($variables_order);
+
+ if (strpos($variables_order, 'E') !== false) {
+ // The "variables_order" option already has "E", so we don't need to
+ // repair $_ENV.
+ return;
+ }
+
+ list($env) = execx(
+ 'php -d variables_order=E -r %s',
+ 'echo json_encode($_ENV);');
+ $env = phutil_json_decode($env);
+
+ $_ENV = $_ENV + $env;
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 2, 5:27 AM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7713269
Default Alt Text
D19685.id.diff (2 KB)
Attached To
Mode
D19685: When running libphutil scripts, repair bad "variables_order"
Attached
Detach File
Event Timeline
Log In to Comment