13

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.

7
  • You call fallDeepToHell('from heaven'); at the end again without a try / catch block around. This throws an Exception wich is not caught. Best is to read the backtraced from bottom to top. You see it is engaged by line 22 which is called from the main(). Commented Jan 31, 2020 at 8:42
  • I can't reproduce this, and I always see the arguments - with or without Xdebug loaded. Which version of Xdebug are you running? If you're not on 2.9.1, you should upgrade. Commented Jan 31, 2020 at 9:39
  • @Derick I am using Xdebug v2.9.1 & PHP FPM 7.4 Commented Jan 31, 2020 at 10:16
  • 1
    I tried again with these versions, but it works. Would you mind sharing your phpinfo() output? Or, if possible, provide a docker setup that displays this wrong behaviour? Commented Feb 1, 2020 at 15:15
  • Here is the html of my phpinfo pastebin.com/HtRtaqnJ Commented Feb 2, 2020 at 16:17

1 Answer 1

24

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.

Sign up to request clarification or add additional context in comments.

3 Comments

It claims to be defaulted to off/0 in the PHP but setting the value to 0 again in php.ini did fix the issue for me. This was occurring with sentry-php for me, and this resolved arguments/vars not getting sent to Sentry.
Some SW bundles set it to On "for security", such as Plesk. I found it in Tools & Settings - PHP Settings - Settings for 8.2.29 Dedicated FPM application
The line of code for the lazy: ini_set('zend.exception_ignore_args', 0);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.