Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129473 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 92DB01A00BC for ; Sat, 29 Nov 2025 07:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1764400473; bh=CqMgZUHC0lgzyjpwCsPlJrlPFGafypCeU/sO70cTOTg=; h=Date:To:From:Subject:From; b=KaLnEPeMbcNLmYzSpOkJRhzSk0xV04EEEZ2Z7BndqNM8f3gPDfDDQZuUcKiXzfViE LQhJ0i8PSMbsjVTAQnlKUFZFB5tGILWnegWQv5gYBvEB3EHYbk3sC4D+JJ343uQocn WiMNwtFvC834mT/D99msDhfLfsF3KgO1hCCvJbnbl3AWtuTkHI9b85l8lib6A4s+Ow XsDPEQIqpT7fUNsGJxqjYIluaS26+JleoDsrPTSZYUD2nmGqjBZrqp3Lir85gQCGum eLOvCR75SPKmbSEbXrBFxtno61WJsUl+TbxHT1t6pgqEfZgpbRBEez2676NHPyW3Z/ 8Z9h+aVPmx4ew== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7A9B0180057 for ; Sat, 29 Nov 2025 07:14:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_40,DKIM_INVALID, DKIM_SIGNED,DMARC_QUAR,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RDNS_NONE, SPF_HELO_PASS,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mout-p-102.mailbox.org (unknown [80.241.56.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 29 Nov 2025 07:14:24 +0000 (UTC) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4dJLxp46nZz9tSw for ; Sat, 29 Nov 2025 08:14:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mabe.berlin; s=MBO0001; t=1764400446; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=GkvaAz5ZatcGGhbmp+ulqiriMeD2pq2SVWRnSAPTYXw=; b=G0X4wIABLSmDW+amU682l80RvQmAHyPU7kiqZX02wJUge524uRMIKziGvqpWJcZSthKnit y0Tv6PZeqEtlYg9I7ls0jFwG2cGYNJm/Amn+YDAcUOrw5tfpN/MBMRQmqq6fN20wsTlXsS RYiw2qK9Becsq0H83HlRpOTrgYqf5LJ/0Mixu6ObU60ZRB1JasN1F9jCx6RfURaQ+xHLHz UrHKc6V/2+Koyw3JLQ3CMDWqRYVoBjR94vjr1ZPuTNGTOCDhno5IHcbWsbOw/ASaXh4UMf oHkT6/JEX8/EfsIoB6xrN5DaLFhzTN/vogLznS9NBwsovZlLcAnvmcne1KRQGg== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of marc@mabe.berlin designates 2001:67c:2050:b231:465::202 as permitted sender) smtp.mailfrom=marc@mabe.berlin Content-Type: multipart/alternative; boundary="------------qwTC6gLgPRKNk4Y08yr6meMS" Message-ID: <6f3167c3-b6e7-4f25-8154-ce20de7d3e82@mabe.berlin> Date: Sat, 29 Nov 2025 08:14:05 +0100 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 To: PHP internals Content-Language: en-US Subject: [PHP-DEV] Possibility to include called object in exception backtrace X-Rspamd-Queue-Id: 4dJLxp46nZz9tSw From: marc@mabe.berlin ("Marc B.") This is a multi-part message in MIME format. --------------qwTC6gLgPRKNk4Y08yr6meMS Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi all, I have opened a simple PR to add the possibility to include called object in exception backtrace. https://github.com/php/php-src/pull/20599 This needs a discussion here to see if there are objections. About the patch: The 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. Additionally, I added a note to zend.exception_ignore_args and zend.exception_provide_object as this increases the refcount of the objects, and therefore may delay object destruction. Marc --------------qwTC6gLgPRKNk4Y08yr6meMS Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi all,

I have opened a simple PR to add the possibility to include called object in exception backtrace.

https://github.com/php/php-src/pull/20599

This needs a discussion here to see if there are objections.

About the patch:

The 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.

Additionally, I added a note to zend.exception_ignore_args and zend.exception_provide_object as this increases the refcount of the objects, and therefore may delay object destruction.

Marc

--------------qwTC6gLgPRKNk4Y08yr6meMS--