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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 22 04:01:31 2024 UTC