php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28054 debug_backtrace() bug
Submitted: 2004-04-19 09:05 UTC Modified: 2005-06-23 10:27 UTC
Votes:5
Avg. Score:4.6 ± 0.5
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: misu200 at yahoo dot com Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-06-19 OS: *
Private report: No CVE-ID: None
 [2004-04-19 09:05 UTC] misu200 at yahoo dot com
Description:
------------
I set my own error handle function and then i try to include a non-existent file (aga.php).The problem is when i make a
var_dump(debug_backtrace()) in my error handle function it shows me wrong results.

Reproduce code:
---------------
<?php

function ourErrorHandler($errNo, $errStr, $errFile, $errLine)
{

echo "<PRE>";
var_dump(debug_backtrace());
echo "</PRE>";
}


// set the user error handler to be the above 

$oldErrorHandler = set_error_handler("ourErrorHandler", error_reporting());

require_once("aga.php");

?>

Expected result:
----------------
array(2) {
  [0]=>
  array(3) {
    ["file"]=>
    string(28) "/var/www/html/dir1/file2.php"
    ["line"]=>
    int(15)
    ["function"]=>
    string(15) "ourErrorHandler"
  }
  [1]=>
  array(4) {
    ["file"]=>
    string(28) "/var/www/html/dir1/file2.php"
    ["line"]=>
    int(15)
    ["args"]=>
    array(1) {
     [0]=>
     string(28) "aga.php" < - this should be here
    }
    ["function"]=>
    string(12) "require_once"
  }
}

Actual result:
--------------
array(2) {
  [0]=>
  array(3) {
    ["file"]=>
    string(28) "/var/www/html/dir1/file2.php"
    ["line"]=>
    int(15)
    ["function"]=>
    string(15) "ourErrorHandler"
  }
  [1]=>
  array(4) {
    ["file"]=>
    string(28) "/var/www/html/dir1/file2.php"
    ["line"]=>
    int(15)
    ["args"]=>
    array(1) {
     [0]=>
     string(28) "/var/www/html/dir1/file2.php" <- is wrong
    }
    ["function"]=>
    string(12) "require_once"
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-19 16:45 UTC] olivier dot bichler at laposte dot net
And there is an other problem : why the arguments $errNo, $errStr, $errFile, $errLine are not present in the result of debug_backtrace() ?
I have the same problem...
 [2004-04-19 20:12 UTC] derick@php.net
Assigning to the engine guru, Andi.
 [2005-05-17 14:29 UTC] stas@php.net
The problem here is that error handler call does not provide necessary information for recovering the arguments. This is because include does not preserve the argument and backtrace bases on the fact that code executed after include() is necessarily the included file - which is not the case if include fails, of course. 
 [2005-06-23 10:27 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_0.
Arguments to ourErrorHandler() are shown.
Argument to require_once() are not shown in case of error, because require_once() is internal function and its argument cannot be restored.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 02:01:30 2024 UTC