Bug #74143 [NEW]: putenv can't update existing environment variables, still returns true
| From: | greg dot bowler at g105b dot com | Date: | Tue, 21 Feb 2017 23:08:24 +0000 |
| Subject: | Bug #74143 [NEW]: putenv can't update existing environment variables, still returns true | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207498@lists.php.net to get a copy of this message | ||
From: greg dot bowler at g105b dot com
Operating system: Linux Ubuntu 16.04
PHP version: Irrelevant
Package: FPM related
Bug Type: Bug
Bug description:putenv can't update existing environment variables, still returns true
Description:
------------
The putenv function sets the value of an environment variable. According
to the manual, putenv returns true on success, false on failure.
The scope of this bug report tracks setting an existing environment
variable to a new value. The putenv function sometimes returns true
without updating the environment variable for the current session.
To reproduce this issue, set an environment variable in a webserver
using PHP FPM, by using the fastcgi_param directive. See test script
below for example.
Test script:
---------------
Webserver config file:
----------------------
fastcgi_param TESTVAR_ENV old-value;
test.php:
---------
var_dump(getenv("TESTVAR_ENV"));
var_dump(putenv("TESTVAR_ENV=new-value"));
var_dump(getenv("TESTVAR_ENV"));
Output:
-------
string(12) "old-value"
bool(true)
string(12) "old-value"
Expected result:
----------------
One of the two outcomes are expected:
1. putenv returns false, as there is a failure in setting the variable.
2. getenv returns the newly updated value.
Actual result:
--------------
The reason I consider this a bug is due to the manual stating that
putenv will return true on success.
1. putenv is returning true, indicating the variable has been
successfully set.
2. getenv is returning the old value, not updated.
--
Edit bug report at https://bugs.php.net/bug.php?id=74143&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74143&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74143&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74143&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74143&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74143&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74143&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74143&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74143&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74143&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74143&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74143&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74143&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74143&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74143&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74143&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74143&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74143&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74143&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74143&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74143&r=mysqlcfg