Doc #76957 [NEW]: Missing values in $_SERVER

From: Date: Mon, 01 Oct 2018 18:05:40 +0000
Subject: Doc #76957 [NEW]: Missing values in $_SERVER
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16035@lists.php.net to get a copy of this message
From: office at vargapeter dot net Operating system: Any Linux PHP version: 7.2.10 Package: CGI/CLI related Bug Type: Documentation Problem Bug description:Missing values in $_SERVER Description: ------------ 1) When executing 'php -c /path-to-ini-file /path/exec.php' via the system() function in the Apache module the script 'exec.php' doesn't have HOST value in $_SERVER. Running in the OS command line 'php -c /path-to-ini-file /path/exec.php' $_SERVER has HOST value. I consider it inconsistent for the HOST value which is in both cases known. 2) $_SERVER is more or less exactly the section Environment from phpinfo() function when running via system() in a browser tab. This behavior is nowhere documented and fairly surprising. Test script: --------------- foo.php - calling in a browser tab: <?php system("php -c /etc/php7/cli/php.ini /path/exec.php"); ?> exec.php - called a) via system() or directly from command line: <?php print_r($_SERVER); ?> Expected result: ---------------- From command line AND via system() in Browser tab: Array ( ... [HOST] => MY_HOST <---- MISSING [_] => /usr/bin/php [PHP_SELF] => /path/exec.php [SCRIPT_NAME] => /path/exec.php [SCRIPT_FILENAME] => /path/exec.php [PATH_TRANSLATED] => /path/exec.php [DOCUMENT_ROOT] => [REQUEST_TIME_FLOAT] => 1538415804.9271 [REQUEST_TIME] => 1538415804 [argv] => Array ( [0] => /path/exec.php ) [argc] => 1 ) Actual result: -------------- Totally different output; even running exec.php as PHP CLI version. No HOST entry. This is the output from system() in a browser tab: Array ( [APACHE_CONF_INCLUDE_FILES] => [mpm_found] => true [APACHE_CONF_INCLUDE_DIRS] => [SYSCONFIG_FILE] => /etc/sysconfig/apache2 [APACHE_START_TIMEOUT] => 2 [HTTPD_MODULE_IDS] => actions_module alias_module ... [APACHE_SERVERNAME] => [PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin [APACHE_HTTPD_CONF] => [PWD] => /userdata/dev1/faewe.technology [APACHE_SERVERTOKENS] => ProductOnly [NOTIFY_SOCKET] => /run/systemd/notify [APACHE_SERVERADMIN] => [HTTPD_MODULE_PATHS] => /usr/lib64/apache2-prefork/mod_actions.so ... [SHLVL] => 1 [APACHE_ACCESS_LOG] => /var/log/apache2/access_log combined [LC_CTYPE] => en_US.UTF-8 [APACHE_LOGLEVEL] => warn [APACHE_USE_CANONICAL_NAME] => off [APACHE_EXTENDED_STATUS] => off [APACHE_MODULES] => actions ... php7 [APACHE_SERVER_FLAGS] => [HTTPD_MPM] => prefork [APACHE_SERVERSIGNATURE] => off [sysconfig_loaded] => true [APACHE_MPM] => [OLDPWD] => / [_] => /usr/bin/php [PHP_SELF] => /path/exec.php [SCRIPT_NAME] => /path/exec.php [SCRIPT_FILENAME] => /path/exec.php [PATH_TRANSLATED] => /path/exec.php [DOCUMENT_ROOT] => [REQUEST_TIME_FLOAT] => 1538415816.209 [REQUEST_TIME] => 1538415816 [argv] => Array ( [0] => /path/exec.php ) [argc] => 1 ) -- Edit bug report at https://bugs.php.net/bug.php?id=76957&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76957&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76957&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76957&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76957&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76957&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76957&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76957&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76957&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76957&r=support Expected behavior: https://bugs.php.net/fix.php?id=76957&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76957&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76957&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76957&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76957&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76957&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76957&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76957&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76957&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76957&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76957&r=mysqlcfg

« previous php.doc.bugs (#16035) next »