|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79254 CLI: getenv() w/o arguments not showing changes
Submitted: 2020-02-10 14:35 UTC Modified: 2020-02-11 11:11 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: franz dot zieris at gmail dot com Assigned: cmb (profile)
Status: Closed Package: PHP options/info functions
PHP Version: 7.4.2 OS: Windows ZTS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: franz dot zieris at gmail dot com
New email:
PHP Version: OS:


 [2020-02-10 14:35 UTC] franz dot zieris at gmail dot com
Calling `getenv()` without an argument does not reflect change made with `putenv`, but calling `getenv()` on a concrete variable *does*.

The test script below produces the expected output on a Linux machine, but on my Windows machine the array difference is "array(0) { }".

I'm using the out-of-the box configuration of php.ini-development.

These are the first lines of `php -i`

System => Windows NT MYPC 10.0 build 18363 (Windows 10) AMD64
Build Date => Jan 21 2020 17:46:05
Compiler => Visual C++ 2017
Architecture => x64
Configure Command => cscript /nologo configure.js  "--enable-snapshot-build" "--enable-debug-pack" "--with-pdo-oci=c:\php-snap-build\deps_aux\oracle\x64\instantclient_12_1\sdk,shared" "--with-oci8-12c=c:\php-snap-build\deps_aux\oracle\x64\instantclient_12_1\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--with-pgo"
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path => C:\WINDOWS
Loaded Configuration File => C:\xampp\php\php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20190902
PHP Extension => 20190902
Zend Extension => 320190902
Zend Extension Build => API320190902,TS,VC15
PHP Extension Build => API20190902,TS,VC15
Debug Build => no
Thread Safety => enabled
Thread API => Windows Threads
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => disabled
IPv6 Support => enabled
DTrace Support => disabled

Test script:

$old = getenv();
var_dump(getenv("FOO", true));    // expected: bool(false)


$new = getenv();
var_dump(array_diff($new, $old)); // expected: array(1){["FOO"]=>string(3) "BAR"}
var_dump(getenv("FOO", true));    // expected: string(3) "BAR"


Expected result:
array(1) {
  string(3) "BAR"
string(3) "BAR"

Actual result:
array(0) {
string(3) "BAR"


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-10 16:05 UTC]
-Status: Open +Status: Verified -Operating System: Windows +Operating System: Windows ZTS
 [2020-02-10 16:05 UTC]
Confirmed for ZTS builds.  The problem is that ZTS builds use only
SetEnvironmentVariable(), but not putenv() (because the latter is
not thread-safe), but read the enviroment using environ, which
only would reflect putenv() changes.
 [2020-02-11 08:59 UTC]
The following pull request has been associated:

Patch Name: Fix #79254: getenv() w/o arguments not showing changes
On GitHub:
 [2020-02-11 11:09 UTC]
Automatic comment on behalf of
Log: Fix #79254: getenv() w/o arguments not showing changes
 [2020-02-11 11:09 UTC]
-Status: Verified +Status: Closed
 [2020-02-11 11:11 UTC]
-Assigned To: +Assigned To: cmb
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 21:01:29 2024 UTC