Page MenuHomePhabricator

When running libphutil scripts, repair bad "variables_order"
AbandonedPublic

Authored by epriestley on Sep 18 2018, 5:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 21, 11:15 PM
Unknown Object (File)
Fri, Apr 19, 7:58 PM
Unknown Object (File)
Sat, Mar 30, 6:44 AM
Unknown Object (File)
Sat, Mar 30, 6:44 AM
Unknown Object (File)
Fri, Mar 29, 4:45 PM
Unknown Object (File)
Mar 22 2024, 3:01 AM
Unknown Object (File)
Mar 21 2024, 9:46 AM
Unknown Object (File)
Mar 14 2024, 4:55 PM
Subscribers
None

Details

Summary

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) {
  ["PHABRICATOR_INSTANCE"]=>
  string(5) "local"
  ["TERM_PROGRAM"]=>
  string(14) "Apple_Terminal"
  ["TERM"]=>
  string(14) "xterm-256color"

...

Usage Exception: Choose a workflow!

Diff Detail

Repository
rPHU libphutil
Branch
wilds6
Lint
Lint Passed
Unit
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.
scripts/__init_script__.php
3–7

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.