Bug #74986 [Opn]: Environment variables set via putenv are not accessible via parse_ini_*

From: Date: Wed, 26 Jul 2017 05:24:21 +0000
Subject: Bug #74986 [Opn]: Environment variables set via putenv are not accessible via parse_ini_*
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210338@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74986&edit=1 ID: 74986 Updated by: ab@php.net Reported by: alan at aondra dot com Summary: Environment variables set via putenv are not accessible via parse_ini_* Status: Open Type: Bug Package: *General Issues Operating System: Windows 7 Professional SP1 x64 PHP Version: 7.1.7 Block user comment: N Private report: N New Comment: @alan at aondra dot com, usage of undocumented features is not a reliable way of development, as for me ;) And you link to the page that doesn't document the feature. Now after @requinix's comment it looks like documented anyway. In further, you also can check bug #71607. If you want to shoot yourself in the foot - yes, use environment variables. @requinix, it might be useful, but from the security and portability perspective it is quite poor. While we know some PHP software uses it officially, which is even more of disservice, as for me. Thanks. Previous Comments: ------------------------------------------------------------------------ [2017-07-25 22:12:01] alan at aondra dot com Thanks to requinix, I'll give that a shot. ------------------------------------------------------------------------ [2017-07-25 22:11:03] alan at aondra dot com "We didn't write it in the description, so it doesn't happen" could not be any more disingenuous of a response. Fix and document it, or remove it entirely. Don't think me while saying it's likely to be a wontfix; it's just as disingenuous as the documentation comment. ------------------------------------------------------------------------ [2017-07-25 22:02:49] requinix@php.net Not documented with parse_ini_file/string, but it's the same parser used for php.ini and support for environment variables is documented there. http://php.net/manual/en/configuration.file.php#example-36 It is a handy feature to have in userland. I know I've used it myself. I think the problem is because of how Apache deals with environment variables - by taking a copy at startup - combined with how PHP's environment variable getting and setting works in Windows. putenv() probably works fine by setting the variable at the process level (SetEnvironmentVariable), but reading it back from the SAPI won't work because Apache is still using the old list it had. I suspect apache_setenv() instead of putenv() will work, and using $walk_to_top=true sounds like it might address the potential multithreading problem too. ------------------------------------------------------------------------ [2017-07-25 21:02:07] ab@php.net Thanks for the report. This feature is not documented, why is it expected behavior? Furthermore, it is not thread safe and therefore not portable. I'd tend to say it's a won't fix. Thanks. ------------------------------------------------------------------------ [2017-07-25 16:29:38] alan at aondra dot com Actual results appear on a second Windows-based server running PHP 7.1.6 on Windows 7 Professional SP1 x64. Expected results appear on Amazon EC2 instance running Amazon Linux AMI release 2017.03 with PHP 7.0.16 and Apache HTTPD 2.4.25. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=74986 -- Edit this bug report at https://bugs.php.net/bug.php?id=74986&edit=1

« previous php.bugs (#210338) next »