facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.18k stars 2.99k forks source link

ini_get('display_errors') always returns '1' #6967

Open ldct opened 8 years ago

ldct commented 8 years ago

HHVM Version

3.12.0

Standalone code, or other way to reproduce the problem

➜  hhvm -c /dev/null -d display_errors=0 -m debug
Welcome to HipHop Debugger!
Type "help" or "?" for a complete list of commands.

Note: no server specified, debugging local scripts only.
If you want to connect to a server, launch with "-h" or use:
  [m]achine [c]onnect <servername>

hphpd> p float(1);
p float(1);
Hit fatal : Call to undefined function float()
    #0 at [:1]
    #1 include(), called at [:1]

null
hphpd> p ini_get('display_errors');
p ini_get('display_errors');
"1"
hphpd> ^Dquit

Expected result

The -d display_errors=0 flag should have set the display_errors directive to 0, so ini_get('display_errors') should return "0". Also, the fatal error should not be printed.

What zend does:

➜ php -c /dev/null -d display_errors=0 -a      
Interactive shell

php > float(1);
php > var_dump(ini_get('display_errors'));
string(0) "0"

Actual result

ini_get('display_errors') returns "1" and fatal error is displayed

Also, it seems that it always return "1" no matter how I try to set it to off (in zend that includes =false, =0, =Off, ='', ="")

robations commented 7 years ago

In my experience, not only fatal errors, also notices, warnings are displayed etc:

# /etc/hhvm/php.ini
display_errors=0
<?php
# test.php
echo ini_get('display_errors') . "\n";
ini_set('display_errors', 0);
$arr = [];
echo $arr['test'];
echo ini_get('display_errors') . "\n";

Sample output:

1
Notice: Undefined index: test in test.php on line 6
0

Expected output:

0
0
fredemmott commented 7 years ago
fredemmott-fb:hhtest fredemmott$ echo '<?php var_dump(ini_get("display_errors"));' | hhvm -ddisplay_errors=0 /dev/stdin
<jemalloc>: Invalid conf pair: metadata_thp:false
string(1) "1"
fredemmott-fb:hhtest fredemmott$ echo '<?php var_dump(ini_get("display_errors"));' | hhvm -ddisplay_errors=stdout /dev/stdin
<jemalloc>: Invalid conf pair: metadata_thp:false
string(6) "stdout"
fredemmott-fb:hhtest fredemmott$ echo '<?php var_dump(ini_get("display_errors"));' | hhvm -ddisplay_errors=off /dev/stdin
<jemalloc>: Invalid conf pair: metadata_thp:false
string(1) "1"
fredemmott-fb:hhtest fredemmott$ echo '<?php var_dump(ini_get("display_errors"));' | hhvm -ddisplay_errors=0 /dev/stdin
<jemalloc>: Invalid conf pair: metadata_thp:false
string(1) "1"
fredemmott-fb:hhtest fredemmott$ echo '<?php var_dump(ini_get("display_errors"));' | hhvm -ddisplay_errors=stderr /dev/stdin
<jemalloc>: Invalid conf pair: metadata_thp:false
string(6) "stderr"