Bug #79051 [NEW]: putenv variables not accessible to dependent functions in Windows CLI

From: Date: Wed, 01 Jan 2020 02:24:52 +0000
Subject: Bug #79051 [NEW]: putenv variables not accessible to dependent functions in Windows CLI
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224640@lists.php.net to get a copy of this message
From: danielklein at airpost dot net Operating system: Windows 10 PHP version: 7.3.13 Package: Unknown/Other Function Bug Type: Bug Bug description:putenv variables not accessible to dependent functions in Windows CLI Description: ------------ In Windows CLI, setting an environment with putenv(), such as "all_proxy" which is supposed to affect cURL, has no effect on later function calls. The test script works as expected on Ubuntu CLI, but not Windows CLI. Test script: --------------- <?php function search() { $url = 'x3m.dev'; $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, ]); $data = curl_exec($curl); if (!$data) { throw new Exception('An error occurred while trying to process the request.'); } return $data; } function do_curl_request() { echo getenv("all_proxy") . "\n\n"; try { echo search(); } catch (Exception $e) { echo $e->getMessage(); } echo "\n\n"; } echo "========== first run without proxy\n"; do_curl_request(); putenv("all_proxy=localhost:5678"); echo "========== second run with proxy override\n"; do_curl_request(); Expected result: ---------------- ========== first run without proxy <html> <head></head> <body>.</body> </html> ========== second run with proxy override localhost:5678 An error occurred while trying to process the request. Actual result: -------------- ========== first run without proxy <html> <head></head> <body>.</body> </html> ========== second run with proxy override localhost:5678 An error occurred while trying to process the request. -- Edit bug report at https://bugs.php.net/bug.php?id=79051&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79051&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79051&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79051&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79051&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79051&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79051&r=support Expected behavior: https://bugs.php.net/fix.php?id=79051&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79051&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79051&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79051&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79051&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79051&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79051&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79051&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79051&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79051&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79051&r=mysqlcfg

« previous php.bugs (#224640) next »