php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30504 When using a custom error handler, a failed require() produces only E_WARNING
Submitted: 2004-10-21 01:19 UTC Modified: 2004-10-21 09:16 UTC
From: danieltalsky at gmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.0.1 OS: FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: danieltalsky at gmail dot com
New email:
PHP Version: OS:

 

 [2004-10-21 01:19 UTC] danieltalsky at gmail dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-21 09:16 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 08:01:30 2025 UTC