From:             danieltalsky at gmail dot com
Operating system: FreeBSD
PHP version:      5.0.1
PHP Bug Type:     Output Control
Bug description:  When using a custom error handler, a failed require() produces only 
E_WARNING

Description:
------------
Unexpected behaviors when using a custom error reporting function.

1. a failed require() reports a E_WARNING (instead of the expected
E_ERROR) and then uses the default PHP fatal error (it appear TWICE)

3. calling a bogus function like foobar() DOES create a fatal error, but
uses the default PHP error output and never reaches my custom handler

Note: This is a CLI script.

Reproduce code:
---------------
  function pv_shell_error_logger(
    $errno, $errstr, $errfile, $errline){

    switch ($errno){
      case E_ERROR:
        print ('E_ERROR');
      break;

      case E_WARNING:
        print ('E_WARNING');
      break;
    }
    return true;
  }

  // set to the user defined error handler
  set_error_handler("pv_shell_error_logger",
    (E_ERROR|E_WARNING|E_PARSE));

  // Test1 prints 'E_WARNING' but also stops code execution
  require('this should produce a fatal error');

  // Test2 uses PHP's default error handler
  foobar('this should use the custom error handler');

Expected result:
----------------
There's two test cases here...

Test1: the require() statement prints out E_WARNING, but stops program
execution

Test2: the foobar() function throws a default PHP fatal error and stops
program execution

Actual result:
--------------
Test1: should print E_ERROR and continue execution unless there is an
exit()/die() in the custom handler

Test2: same

-- 
Edit bug report at http://bugs.php.net/?id=30504&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30504&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30504&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30504&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30504&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30504&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30504&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30504&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30504&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30504&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30504&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30504&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30504&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30504&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30504&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30504&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30504&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30504&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30504&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30504&r=mysqlcfg

Reply via email to