php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67808 Env variables through the built-in server set in $_ENV but not in $_SERVER
Submitted: 2014-08-08 20:42 UTC Modified: 2015-09-05 12:11 UTC
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:2 (50.0%)
From: morgan dot auchede at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: Built-in web server
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-08-08 20:42 UTC] morgan dot auchede at gmail dot com
Description:
------------
If we set an environment variable through Apache (or Nginx), the variable will be available in "$_ENV" and "$_SERVER". 

Unfortunately, if we set an environment variable through the built-in server, the variable will only be available in "$_ENV" (not in $_SERVER).

See the original issue related: https://github.com/symfony/symfony/issues/10208

Test script:
---------------
# test.php
<?php
var_dump($_ENV['FOO']);
var_dump($_SERVER['FOO']);

# bash
export FOO="bar"
php -d variables_order=EGPCS -S 0.0.0.0:8000 -t . test.php


Expected result:
----------------
string 'bar' (length=3)
string 'bar' (length=3)

Actual result:
--------------
string 'bar' (length=3)
Notice: Undefined index: FOO

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-08 20:50 UTC] aharvey@php.net
Honestly, my initial reaction to this is that CGI and FPM are wrong — I wouldn't support changing them (BC and all), but I don't think we need to be bug for bug compatible on the $_SERVER copying behaviour across SAPIs, either, given the documented method for accessing environment variables ($_ENV) works fine in all SAPIs in current versions.

Not won't fixing this now in case someone else wants to weigh in, but that's my inclination.
 [2015-09-05 12:11 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2015-09-05 12:11 UTC] cmb@php.net
I agree with Adam's assessment, so WONTFIX.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Sep 26 06:01:23 2020 UTC