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
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: 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

Pull Requests

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: Sun Dec 01 01:01:29 2024 UTC