[php-src] PR #20599: Adds possibility to include called object in exception backtrace
| From: | marc-mabe | Date: | Thu, 27 Nov 2025 08:54:45 +0000 |
| Subject: | [php-src] PR #20599: Adds possibility to include called object in exception backtrace | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-34157@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20599
Author: marc-mabe
This patch adds the ability to populate the called
object into exception backtraces.
Previously, only debug_backtrace() could include the called object in its frames, but
Exception::getTrace() could not. This change aligns Exception::getTrace()
with debug_backtrace() by introducing a new INI directive:
zend.exception_provide_object (boolean)
This directive is analogous to the existing zend.exception_ignore_args option, but
controls whether the object field is included in exception backtraces.
**Behavior:**
* When zend.exception_provide_object = 0 (default), behavior is unchanged: exception traces do not
contain the object.
* When zend.exception_provide_object = 1, exception backtrace includes the called
object (where applicable).
**Defaults:**
* No configuration value provided: zend.exception_provide_object = Off
* php.ini-production: zend.exception_provide_object = Off
* php.ini-development: zend.exception_provide_object = On
**Use cases and considerations:**
This feature is primarily intended for development and debugging.
Provides richer diagnostic information by exposing the actual object on which methods were invoked.
Can help track down state-dependent bugs that depend on specific object properties.
However, it is not recommended for production environments, because:
* It may expose sensitive data held on objects in logs or error output.
* It can increase memory usage and the size of collected traces.
For production systems, zend.exception_provide_object should remain disabled.
**Open questions:**
* Does this need an RFC?
* Could this be considered for a PHP patch release?
* Should zend.exception_provide_object be enabled by default in
run-tests.php (similar to zend.exception_ignore_args=0)