php.net |  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
Votes:1
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
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:
---------------
<?php

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

putenv("FOO=BAR");

$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:
----------------
bool(false)
array(1) {
  ["FOO"]=>
  string(3) "BAR"
}
string(3) "BAR"

Actual result:
--------------
bool(false)
array(0) {
}
string(3) "BAR"

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-10 16:05 UTC] cmb@php.net
-Status: Open +Status: Verified -Operating System: Windows +Operating System: Windows ZTS
 [2020-02-10 16:05 UTC] cmb@php.net
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] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #79254: getenv() w/o arguments not showing changes
On GitHub:  https://github.com/php/php-src/pull/5167
Patch:      https://github.com/php/php-src/pull/5167.patch
 [2020-02-11 11:09 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7b464ce6f3feb94dc5b897e4f8792a39e07710b6
Log: Fix #79254: getenv() w/o arguments not showing changes
 [2020-02-11 11:09 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2020-02-11 11:11 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 27 16:01:27 2024 UTC