php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30711 set_error_handler messes output from debug_backtrace()
Submitted: 2004-11-07 12:15 UTC Modified: 2005-01-19 03:16 UTC
From: iris dot cdm at seznam dot cz Assigned:
Status: Closed Package: Output Control
PHP Version: 4.3.8 OS: Windows XP Proffesional SP2
Private report: No CVE-ID: None
 [2004-11-07 12:15 UTC] iris dot cdm at seznam dot cz
Description:
------------
It looks like when we use custom error handler, the output from debug_backtrace() differs in important parts than with default error handler used.


Other environment:
Apache 1.3
Zend Engine 1.3.0

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

function __error_handler($errno, $errstr, $errfile, $errline,$errcontext) { #{{{
    echo '<pre>'; var_dump(debug_backtrace()); die();
} #}}}

set_error_handler('__error_handler');

function wantString($string) {
    return(wantNumber(12345));
}

function wantNumber($number) {
    trigger_error('ok thats error message');
}

wantString('this is a string');

?>

Expected result:
----------------
Expecting output from debug_backtrace with function arguments associated to proper function.

i.e. (edited few lines from "Actual result")
[2]=>
  array(4) {
    ["file"]=>
    string(51) "d:\_www-nechranene\vyvoj\main-include\test-dbtr.php"
    ["line"]=>
    int(10)
    ["function"]=>
    string(10) "wantnumber"
    ["args"]=>
    &array(1) {
        ["number"]=>
        int(12345)
  }

Actual result:
--------------
Function wantNumber was called with number argument, but here we have it with string?

array(4) {
  [0]=>
  array(2) {
    ["function"]=>
    string(15) "__error_handler"
    ["args"]=>
    array(5) {
      [0]=>
      &#8747;(1024)
      [1]=>
      &string(22) "ok thats error message"
      [2]=>
      &string(51) "d:\_www-nechranene\vyvoj\main-include\test-dbtr.php"
      [3]=>
      &#8747;(14)
      [4]=>
      &array(1) {
        ["number"]=>
        int(12345)
      }
    }
  }
  [1]=>
  array(3) {
    ["file"]=>
    string(51) "d:\_www-nechranene\vyvoj\main-include\test-dbtr.php"
    ["line"]=>
    int(14)
    ["function"]=>
    string(13) "trigger_error"
  }
  [2]=>
  array(4) {
    ["file"]=>
    string(51) "d:\_www-nechranene\vyvoj\main-include\test-dbtr.php"
    ["line"]=>
    int(10)
    ["function"]=>
    string(10) "wantnumber"
    ["args"]=>
    array(1) {
      [0]=>
      &string(22) "ok thats error message"
    }
  }
  [3]=>
  array(3) {
    ["file"]=>
    string(51) "d:\_www-nechranene\vyvoj\main-include\test-dbtr.php"
    ["line"]=>
    int(17)
    ["function"]=>
    string(10) "wantstring"
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-01 09:15 UTC] john_mash02 at yahoo dot co dot uk
It's almost a month ago and no one from PHP developers does not know???

Johny
 [2005-01-19 03:16 UTC] sniper@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Dec 04 02:03:36 2021 UTC