ID:               45895
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jmcgraw1 at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: CentOS
 PHP Version:      5.2.6
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi




Previous Comments:
------------------------------------------------------------------------

[2008-08-22 21:52:57] jmcgraw1 at gmail dot com

Description:
------------
Throwing an exception within set_error_handler() produces an exception
which produces a messed up backtrace. Each entry within the backtrace
contains the 'args' for the previous call, with the most immediate entry
missing its 'args'. In the case of my example below the string 'foobar'
should be in the array 'args' for the call to B(), not A().

Reproduce code:
---------------
function handle_errors() {
        throw new ErrorException();
}

set_error_handler('handle_errors', E_ALL);

function A() {
        $foo->bar; // Purposely cause error
}

function B($c) {
        A();
}

try {
        B('foobar');
} catch (Exception $e) {
        var_dump($e->getTrace());
}

Expected result:
----------------
array(3) {
  [0]=>
  array(4) {
    ["file"]=>
    string(42) "/home/public/pdt/framework/html/error.php"
    ["line"]=>
    int(10)
    ["function"]=>
    string(13) "handle_errors"
    ["args"]=>
    array(0) {
    }
  }
  [1]=>
  array(4) {
    ["file"]=>
    string(42) "/home/public/pdt/framework/html/error.php"
    ["line"]=>
    int(14)
    ["function"]=>
    string(1) "A"
  }
  [2]=>
  array(3) {
    ["file"]=>
    string(42) "/home/public/pdt/framework/html/error.php"
    ["line"]=>
    int(18)
    ["function"]=>
    string(1) "B"
    ["args"]=>
    array(1) {
      [0]=>
      string(6) "foobar"
    }
  }
}


Actual result:
--------------
array(3) {
  [0]=>
  array(4) {
    ["file"]=>
    string(42) "/home/public/pdt/framework/html/error.php"
    ["line"]=>
    int(10)
    ["function"]=>
    string(13) "handle_errors"
    ["args"]=>
    array(0) {
    }
  }
  [1]=>
  array(4) {
    ["file"]=>
    string(42) "/home/public/pdt/framework/html/error.php"
    ["line"]=>
    int(14)
    ["function"]=>
    string(1) "A"
    ["args"]=>
    array(1) {
      [0]=>
      string(6) "foobar"
    }
  }
  [2]=>
  array(3) {
    ["file"]=>
    string(42) "/home/public/pdt/framework/html/error.php"
    ["line"]=>
    int(18)
    ["function"]=>
    string(1) "B"
  }
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45895&edit=1

Reply via email to