Bug #79254 [Ver->Csd]: CLI: getenv() w/o arguments not showing changes

From: Date: Tue, 11 Feb 2020 11:09:02 +0000
Subject: Bug #79254 [Ver->Csd]: CLI: getenv() w/o arguments not showing changes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225489@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79254&edit=1

 ID:                 79254
 Updated by:         cmb@php.net
 Reported by:        franz dot zieris at gmail dot com
 Summary:            CLI: getenv() w/o arguments not showing changes
-Status:             Verified
+Status:             Closed
 Type:               Bug
 Package:            PHP options/info functions
 Operating System:   Windows ZTS
 PHP Version:        7.4.2
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2020-02-11 08:59:32] 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-10 16:05:06] 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-10 14:35:22] 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"


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79254&edit=1


Thread (4 messages)

« previous php.bugs (#225489) next »