Bug #69636 [Opn->Fbk]: putenv() persits in a cURL request to same server.
Edit report at https://bugs.php.net/bug.php?id=69636&edit=1
ID: 69636
Updated by: ab@php.net
Reported by: jake dot zatecky at gmail dot com
Summary: putenv() persits in a cURL request to same server.
-Status: Open
+Status: Feedback
Type: Bug
Package: PHP options/info functions
Operating System: Windows 7/Windows Server 2008
PHP Version: 5.6.8
Block user comment: N
Private report: N
New Comment:
Hm, this should have been fixed already, see bug #69033. Anyway I cannot reproduce this with the
built-in web server. Is there something special one needs to care about? Which server?
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2015-05-14 23:20:45] jake dot zatecky at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=69636&edit=1
Thread (5 messages)