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

PHP 5.2.6 (cli) (built: May  8 2008 16:50:48)

Output:
array(3) {
  [0]=>
  array(4) {
    ["file"]=>
    string(26) "/home/jmcgraw/test_old.php"
    ["line"]=>
    int(10)
    ["function"]=>
    string(13) "handle_errors"
    ["args"]=>
    array(0) {
    }
  }
  [1]=>
  array(4) {
    ["file"]=>
    string(26) "/home/jmcgraw/test_old.php"
    ["line"]=>
    int(14)
    ["function"]=>
    string(1) "A"
    ["args"]=>
    array(1) {
      [0]=>
      string(6) "foobar"
    }
  }
  [2]=>
  array(3) {
    ["file"]=>
    string(26) "/home/jmcgraw/test_old.php"
    ["line"]=>
    int(18)
    ["function"]=>
    string(1) "B"
  }
}

PHP 5.2.7-dev (cli) (built: Aug 27 2008 12:47:06)

Output:
array(3) {
  [0]=>
  array(4) {
    ["file"]=>
    string(22) "/home/jmcgraw/test_new.php"
    ["line"]=>
    int(10)
    ["function"]=>
    string(13) "handle_errors"
    ["args"]=>
    array(0) {
    }
  }
  [1]=>
  array(4) {
    ["file"]=>
    string(22) "/home/jmcgraw/test_new.php"
    ["line"]=>
    int(14)
    ["function"]=>
    string(1) "A"
    ["args"]=>
    array(1) {
      [0]=>
      string(6) "foobar"
    }
  }
  [2]=>
  array(3) {
    ["file"]=>
    string(22) "/home/jmcgraw/test_new.php"
    ["line"]=>
    int(18)
    ["function"]=>
    string(1) "B"
  }
}

Result:
Latest snapshot does NOT solve problem.


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

[2008-08-26 22:36:18] [EMAIL PROTECTED]

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



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

[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