|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-10-01 19:08 UTC] requinix@php.net
-Status: Open
+Status: Feedback
[2018-10-01 19:08 UTC] requinix@php.net
[2018-10-02 08:32 UTC] office at vargapeter dot net
-Status: Feedback
+Status: Open
[2018-10-02 08:32 UTC] office at vargapeter dot net
[2018-10-02 08:36 UTC] office at vargapeter dot net
[2018-10-02 08:54 UTC] gabri dot ns at gmail dot com
[2018-10-02 14:13 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2018-10-02 14:13 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 15 03:00:01 2025 UTC |
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 )