Expand PHP Stack Trace Arguments
Asked Answered
E

2

7

On a stack trace returned from a PHP application in development, long string arguments to a function are truncated when display on the error page:

Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO "tb...', Array)

How can I expand the query argument so the full text is visible? The server is running PHP 5.3.3.

Eustoliaeutectic answered 22/12, 2010 at 18:17 Comment(1)
This is the same question, thanks for the link. I did not come across that when I searched before my post.Eustoliaeutectic
C
5

Use debug_backtrace instead. It will give you the whole trace and doesn't trim arguments as far as I know.

On a second thought: You might get away with it by using

try {
   ...
} catch (Exception $e)
   var_dump($e->getTrace());
}

instead.

Choosey answered 22/12, 2010 at 18:19 Comment(1)
Thanks, the var_dump did the trick. I do not think debug_backtrace will work unless I am misunderstanding it; I cannot modify the file where the exception originates. Is there some way to get var_dump to not produce ellipses? I think it is truncating some data I need. EDIT: The other topic provides an alternative solution that should fix the ellipsis issue.Eustoliaeutectic
B
4

Starting with PHP 8.0 it is possible to actually raise the limit at which arguments will be truncated.

You can change the newly introduced php.ini setting zend.exception_string_param_max_len and set it to any value between 0 and 1000000, the default being 15.

This only affects stack traces generated using getTraceAsString() or by casting an exception to a string (e.g., by printing it).

More information is available here or in the corresponding RFC.

Bartolome answered 13/6, 2021 at 1:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.