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)
Thu, Nov 21, 9:31 PM
Unknown Object (File)
Wed, Nov 20, 11:18 AM
Unknown Object (File)
Mon, Nov 18, 4:55 PM
Unknown Object (File)
Oct 15 2024, 5:24 PM
Unknown Object (File)
Oct 9 2024, 10:08 AM
Unknown Object (File)
Oct 8 2024, 4:25 AM
Unknown Object (File)
Oct 8 2024, 4:24 AM
Unknown Object (File)
Oct 8 2024, 4:14 AM
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.