php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12136 set_error_handler doesn't trap all errors
Submitted: 2001-07-13 05:21 UTC Modified: 2001-07-15 12:51 UTC
From: scott at datalink dot net dot au Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.6 OS: Redhat Linux 7.0
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: scott at datalink dot net dot au
New email:
PHP Version: OS:

 

 [2001-07-13 05:21 UTC] scott at datalink dot net dot au
I believe this is the same bug as bug report 11803, but I think the scope is wider than initially reported.

The bug: set_error_handler does not trap an error if I try to call a method that does not exist.

This is causing grief when a PEAR-style method returns one type of object on success and another on failure.   The code expecting the success will call a non-existant method.

Here's some code to emulate the problem:
<?php

// set up my custom error handler
set_error_handler("handleError");

function handleError($errno, $errstr, $errfile, $errline, $obj)
{
  print "<b>My Error Handler:</b> $errstr on line $errline";
}

// define a really basic class
class Foo
{
  var $i;
}

$myFoo = new Foo();

// call a non-existant property (this calls the errorHandler OK)
print $myFoo->choo;

// now call a non-existant method (this bypasses the errorHandler!!!)
$myFoo->bar();

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-15 12:51 UTC] zeev@php.net
set_error_handler() is not supposed to be able to trap all errors, only recoverable errors.  Currently, a call to an undefined function/method is defined as a non-recoverable error, as in, an error that leaves the engine in an unstable state, and thus, you cannot override this error with a userland error handler.
"This behavior is by design" :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Feb 23 03:01:30 2024 UTC