Page MenuHomePhabricator

phd no longer recognizes PHABRICATOR_ENV?
Closed, ResolvedPublic


We use PHABRICATOR_ENV to read many of our config settings from the khan.conf.php file. This worked until my recent upgrade of phabricator, when the daemons all started failing like so:

[2017-01-05 09:14:31] EXCEPTION: (Exception) Define 'phabricator.base-uri' in your configuration to continue. at [<phabricator>/src/infrastructure/env/PhabricatorEnv.php:473]

And when I run bin/config to show me the value of phabricator.base-uri, it also says it's unset, and only shows the values from the local config and the datastore. But when I view the config setting via the web UI, it has the correct value from the conf file.

Is PHABRICATOR_ENV supposed to be deprecated? Or should the daemons still be respecting it?

Event Timeline

This is an unintended side effect of D17100 but resolution isn't straightforward.

Only the bin/repository subprocess is losing PHABRICATOR_ENV.

I'll hack this for now. We probably need to start requiring that PHP be configured so that $_ENV populates in the longer run.

While I'm chasing this down, can you show me the output of this command?

$ php -i | grep variables_order
ubuntu@phabricator:~$ php -i | grep variables_order
variables_order => GPCS => GPCS

Perfect, thanks! That's what I expected, so D17148 should resolve this. Alternatively, setting that value to "EGPCS" (without upgrading, just restarting the daemons) should also resolve this.

Offhand, do you know why your configured order omits "E"? The PHP default should normally be "EGPCS" as far as I know.

Actually, it looks like PHP defaults to "EGPCS" but ships with config files that use "GPCS" (??? why would you do this ???), so this is probably not something that got changed or configured intentionally or accidentally.

Unfortunately, that means that T12071 is probably going to affect a lot of installs.

(After T12071 we will almost certainly require "E", so you could get ahead of that now.)

Am glad to get ahead of it. What's the exact incantation we need to put into our php.ini?

Yep, here is the default value on all the installs of PHP I've done from source:

; This directive determines which super global arrays are registered when PHP
; starts up. G,P,C,E & S are abbreviations for the following respective super
; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty
; paid for the registration of these arrays and because ENV is not as commonly
; used as the others, ENV is not recommended on productions servers. You
; can still get access to the environment variables through getenv() should you
; need to.
; Default Value: "EGPCS"
; Development Value: "GPCS"
; Production Value: "GPCS";
variables_order = "GPCS"

Why would the default not be the default? Oh PHP ...

This should do it:

variables_order = "EGPCS"

You likely have variables_order = ... somewhere already, and can just add an "E" to the existing line.

(Or delete all mentions of variables_order from all config files, since the default is "EGPCS".)