Page MenuHomePhabricator

Require "E" be defined in variables_order so $_ENV is correctly populated
Open, NormalPublic


If PHP's variables_order excludes "E", the $_ENV superglobal is not populated.

We currently manage to struggle through this in most cases, but it's a losing battle because we can't reliably build an environment correctly when executing subprocesses.

We should require installs to include "E" in variables_order, and likely require that they set it to the default value, "EGPCS", although we probably do not need that as long as it contains an "E" somewhere.

Event Timeline

One thought here is that updating variables_order is fine on the server, but I really don't want to force arc users to muck with php.ini. Some possible "solutions":

  • Re-execute php with -d variables_order=EGPCS. However: extremely gross.
  • Run export or printenv and parse the output. Also gross. What about Windows? (SET?)
    • Or, run php -d variables_order=E -r "echo json_encode($_ENV);". This is way more dumb but probably a lot less perilous.
  • Continue muddling through this, enumerating problematic variables one-by-one.

The php -d variables_order=E 'echo json_encode($_ENV);' approach seems maybe least-bad but takes 20ms on my machine, so doing it without a performance penalty will be involved.

My testing from D17296 indicates this would also resolve the original problem described in T9639

Via PHI773, filter_input_array(INPUT_ENV, FILTER_UNSAFE_RAW); does not appear to work if variables_order excludes E.