Bug #77782 [Com]: getenv without params returns keys that aren't accessible with $varname param
| From: | danack@php.net | Date: | Fri, 22 Mar 2019 22:51:38 +0000 |
| Subject: | Bug #77782 [Com]: getenv without params returns keys that aren't accessible with $varname param | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220139@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77782&edit=1
ID: 77782
Comment by: danack@php.net
Reported by: matt at mattallan dot me
Summary: getenv without params returns keys that aren't
accessible with $varname param
Status: Open
Type: Bug
Package: FPM related
Operating System: macOs Mojave 10.14
PHP Version: 7.3.3
Block user comment: N
Private report: N
New Comment:
To be clear, are you seeing this with 'FOO' or is foo being used as a metasyntatic name?,
Also, please could you run and show the output of:
$env = getenv();
foreach ($env as $key => $value) {
var_dump($key);
}
$var = 'FOO';
var_dump(getenv($var));
var_dump($env[$var]);
var_dump($var);
with FOO replaced by the actual name if it isn't FOO.
Previous Comments:
------------------------------------------------------------------------
[2019-03-22 20:52:46] matt at mattallan dot me
Description:
------------
PHP version:
PHP 7.3.3 (cli) (built: Mar 8 2019 16:40:07) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.3, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.3, Copyright (c) 1999-2018, by Zend Technologies
(installed with Homebrew)
Relevant ini params:
variables_order = "EGPCS"
auto_globals_jit = Off
Overview:
I set the environment variable
FOO using the fastcgi_param in my Nginx configuration.
If I make a HTTP request to the server I am able to access the environment variable using
getenv()['FOO'] but I am not able to access the environment variable using
getenv('FOO').
The same issue occurs with the Caddy server. If I set the environment variable in the fpm
configuration using env[FOO]=bar the issue does not occur. If I run the script from
the CLI or the built in web server it works as expected.
Test script:
---------------
<?php
$env = getenv();
var_dump(array_key_exists('FOO', $env));
var_dump($env['FOO']);
var_dump(getenv('FOO'));
Expected result:
----------------
I expect to see the output:
bool(true)
string(3) "bar"
string(3) "bar"
Actual result:
--------------
I see the output:
bool(true)
string(3) "bar"
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77782&edit=1