Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP missing function arguments in exception stack trace

I am working to evolve my own error handler for my php apps and I need to send a pretty Exception report to the user on development server. So, when it catches an Exception, it have to parse the exception stack trace to show function, line arguments, etc. But, I no more have the arguments in function calls.

I think this is caused by XDebug and I tried to change the value of xdebug.collect_params to fix it but without any success. In fact, this config only changes the display of xdebug default report that now have the function call parameters.

I made a test script to test it so I let you see.

<?php
$config = 'xdebug.collect_params';
echo "Current value of $config is<br />\n";
var_dump(ini_get($config));

ini_set($config, 3);

function fallDeepToHell($param) {
    echo 'Param is : ' . $param . "<br>\n";
    throw new Exception();
}

try {
    fallDeepToHell('from heaven');
} catch(Exception $e) {
    var_dump($e->getTrace());
    var_dump($e->getTraceAsString());
}
fallDeepToHell('from heaven');

The result on my development server is

enter image description here

I am using PHP 7.4 with FPM.

My php.ini changes:

max_execution_time = 30
memory_limit = 128M
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
html_errors = On
post_max_size = 100M
upload_max_filesize = 49M
date.timezone = Europe/Paris

;[mail function]
mail.add_x_header = On

;[Session]
session.gc_divisor = 1000
session.gc_maxlifetime = 43200

My XDebug settings are only about remote things.

like image 735
Loenix Avatar asked Jan 31 '20 08:01

Loenix


1 Answers

I had the same problem, it turned out to be the new zend.exception_ignore_args INI directive introduced in PHP 7.4.

zend.exception_ignore_args is a new INI directive for including or excluding arguments from stack traces generated from exceptions.

like image 175
Korikulum Avatar answered Oct 20 '22 00:10

Korikulum