Page MenuHomePhabricator

When running libphutil scripts, repair bad "variables_order"

Authored by epriestley on Sep 18 2018, 5:16 PM.
Referenced Files
F12186606: D19685.diff
Sat, Sep 16, 11:50 PM
F12178824: D19685.diff
Mon, Sep 11, 5:36 PM
F12165973: D19685.diff
Thu, Sep 7, 12:54 AM
F12149193: D19685.id47038.diff
Sat, Sep 2, 7:35 AM
F12147162: D19685.diff
Fri, Sep 1, 11:23 AM
F12145836: D19685.diff
Thu, Aug 31, 9:48 PM
Unknown Object (File)
Jul 19 2023, 1:24 PM
Unknown Object (File)
Jun 22 2023, 5:37 AM



Ref T12071. Ref T13098. If your "variables_order" does not include "E", you don't get a valid $_ENV.

Detect and automatically repair this. This rarely causes issues in arc, but it can crop up in unusual use cases (see PHI773), and sometimes hg and git care about things.

This doesn't fix the Phabricator case, but we could use a setup warning there more reasonably.

(I can't figure out a better way to repair the value than this one, even though it's gross -- T12071 has some of the things I tried.)

Test Plan

Before patch:

epriestley@orbital ~/dev/arcanist $ php -d variables_order=G -f bin/arc
array(0) {
Usage Exception: Choose a workflow!

After patch:

epriestley@orbital ~/dev/arcanist $ php -d variables_order=G -f bin/arc
array(22) {
  string(5) "local"
  string(14) "Apple_Terminal"
  string(14) "xterm-256color"


Usage Exception: Choose a workflow!

Diff Detail

rPHU libphutil
Lint Passed
Tests Passed
Build Status
Buildable 20851
Build 28362: Run Core Tests
Build 28361: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Sep 19 2018, 6:15 PM
epriestley added inline comments.

Oh, this has no effect before PHP7 because declare(ticks = 1) has file scope, not process scope.

I believe everything which cares about this already has the same block at top level anyway and that this has no effect.

This rolled into the "nuke libphutil forever" change, but I'm not currently planning to land it to libphutil prior to that because the things it addresses are all very niche and there's some possibility it does goofy things and breaks the world or something.