ID: 47284 Comment by: dypa at bk dot ru Reported By: the...@php.net Status: Open Bug Type: Scripting Engine problem Operating System: * PHP Version: 5.2CVS-2009-02-10 New Comment:
$ php -r 'class Chained extends Exception { function __construct($message, $cause) { parent::__construct($message); $this->cause= $cause; }}function raise($message, $cause) { throw new Chained($message, new Exception($cause)); } try { raise("Arg", "Cause"); } catch (Exception $e) { var_dump($e->getTrace(), $e->cause->getTrace()); }' array(1) { [0]=> array(4) { ["file"]=> string(17) "Command line code" ["line"]=> int(1) ["function"]=> string(5) "raise" ["args"]=> array(2) { [0]=> string(3) "Arg" [1]=> string(5) "Cause" } } } array(1) { [0]=> array(3) { ["file"]=> string(17) "Command line code" ["line"]=> int(1) ["function"]=> string(5) "raise" } } $ php -v PHP 5.2.6-1+lenny2 with Suhosin-Patch 0.9.6.2 (cli) (built: Jan 26 2009 21:54:14) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies Previous Comments: ------------------------------------------------------------------------ [2009-02-09 21:23:45] the...@php.net Doesn't help, I tried PHP 5.2 from CVS, which yields the same result: == php -v == PHP 5.2.9RC2-dev (cli) (built: Feb 9 2009 08:46:53) (DEBUG) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies == Results == array(1) { [0]=> array(4) { ["file"]=> string(17) "Command line code" ["line"]=> int(1) ["function"]=> string(5) "raise" ["args"]=> array(2) { [0]=> string(3) "Arg" [1]=> string(5) "Cause" } } } array(1) { [0]=> array(3) { ["file"]=> string(17) "Command line code" ["line"]=> int(1) ["function"]=> string(5) "raise" } } ------------------------------------------------------------------------ [2009-02-02 22:38:33] the...@php.net Description: ------------ Exception's stacktraces miss the "args" key in certain situations (whereas debug_backtrace() will report them). Reproduce code: --------------- php -r 'class Chained extends Exception { function __construct($message, $cause) { parent::__construct($message); $this->cause= $cause; }} function raise($message, $cause) { throw new Chained($message, new Exception($cause)); } try { raise("Arg", "Cause"); } catch (Exception $e) { var_dump($e->getTrace(), $e->cause->getTrace()); }' Expected result: ---------------- Twice this: array(1) { [0]=> array(4) { ["file"]=> string(17) "Command line code" ["line"]=> int(1) ["function"]=> string(5) "raise" ["args"]=> array(2) { [0]=> &string(3) "Arg" [1]=> &string(5) "Cause" } } } Actual result: -------------- array(1) { [0]=> array(4) { ["file"]=> string(17) "Command line code" ["line"]=> int(1) ["function"]=> string(5) "raise" ["args"]=> array(2) { [0]=> string(3) "Arg" [1]=> string(5) "Cause" } } } array(1) { [0]=> array(3) { ["file"]=> string(17) "Command line code" ["line"]=> int(1) ["function"]=> string(5) "raise" } } The second array is missing the "args" key. In PHP 5.3, it's present. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47284&edit=1