Bug #69636 [NEW]: putenv() persits in a cURL request to same server.
| From: | jake dot zatecky at gmail dot com | Date: | Thu, 14 May 2015 23:20:46 +0000 |
| Subject: | Bug #69636 [NEW]: putenv() persits in a cURL request to same server. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-192666@lists.php.net to get a copy of this message | ||
From: jake dot zatecky at gmail dot com
Operating system: Windows 7/Windows Server 2008
PHP version: 5.6.8
Package: PHP options/info functions
Bug Type: Bug
Bug description:putenv() persits in a cURL request to same server.
Description:
------------
http://php.net/manual/en/function.putenv.php
The PHP doc states that when using putenv(), "The environment variable
will only exist for the duration of the current request." I have found
that if one uses this function and then invokes a cURL request targeting
the same server, this environment change persists. Presumably this is
because we're using the same request?
The same cannot be said if I utilize the $_ENV superglobal. In the test
script below, the TEST environment variable will persist for the cURL
request.
There appears to be no way to reset all environment variables to their
original state, short of tracking each key and setting each value before
making the request. Setting several of the cURL options also appears to
have no affect.
Test script:
---------------
<?php
// caller.php
// ------------------
putenv("TEST=This persists on cURL request.");
$url = "http://127.0.0.1/callee.php";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
echo curl_exec($ch);
// callee.php
// ------------------
var_dump(getenv("TEST"));
Expected result:
----------------
getenv("TEST") returns false
Actual result:
--------------
getenv("TEST") returns "This persists on cURL request."
--
Edit bug report at https://bugs.php.net/bug.php?id=69636&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69636&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69636&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69636&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69636&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69636&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69636&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69636&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69636&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69636&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69636&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69636&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69636&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69636&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69636&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69636&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69636&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69636&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69636&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69636&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69636&r=mysqlcfg