|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25714 static calls of PEAR::setErrorHandling within classes
Submitted: 2003-10-01 09:57 UTC Modified: 2003-10-02 08:46 UTC
From: kalkbrenner at jobpilot dot com Assigned:
Status: Not a bug Package: PEAR related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
42 + 39 = ?
Subscribe to this entry?

 [2003-10-01 09:57 UTC] kalkbrenner at jobpilot dot com
If you call PEAR::setErrorHandling(...) staticly to change the global error handling temporarily within a method of a class, it won't work if you aterwards call a method of another class which itself calls a method of another class that extends PEAR and raises an error. (confusing, but see example)

Exactly this happens if you want to change the error handling before you call DB::connect($dsn) within a method of your own class, because DB::connect intantiates p.e. DB_mysql and calls DB_mysql::connect which raises en error if it runs into problems.

The check for isset($this) in PEAR::setErrorHandling doesn't face this situation. If you call var_dump($this) in PEAR::setErrorHandling when running my example, you'll see that it returns the Instigator. This is a known issue about PHP.
Extending the check to see if the value of $this inherits PEAR isn't a solution because classes like Instigator might extend PEAR as well.

Markus Kalkbrenner

Reproduce code:

class Instigator
   function doSomething() {
      PEAR::setErrorHandling(PEAR_ERROR_DIE); // won't work

class Killer
   function doSomething() {
      $victim = & new Victim();
      print "He's still alive!";

class Victim extends PEAR
   function doSomething() {
      return $this->raiseError("I'm dead!", 0);

$instigator = new Instigator();
print "<br>first try: ";
PEAR::setErrorHandling(PEAR_ERROR_DIE); // works
print "<br>second try: ";


Expected result:
first try: He's still alive!
second try: I'm dead!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-01 17:21 UTC]
have you tried this with PEAR 1.3b1?  I see:

first try: I'm dead!

If you still see the error, then please let me know, otherwise I will mark it bogus.

Incidentally, all new PEAR-related bugs should be opened at
 [2003-10-02 03:19 UTC] kalkbrenner at jobpilot dot com
You're right! I upgraded to 1.3b1 and everything works like it should be. So it seems that the bug will be fixed in the next stable version.

Thanks for verifying my bug report!
 [2003-10-02 08:46 UTC]
since it works in 1.3b1, bogusify
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 22:01:27 2024 UTC