Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.15

Bug #3990 PEAR_Error PEAR_EXCEPTION broken
Submitted: 2005-03-29 09:21 UTC
From: bugs at niluje dot net Assigned: cellog
Status: Closed Package: PEAR
PHP Version: 5.0.3 OS: linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


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:
MUST BE VALID
Solve the problem : 18 - 1 = ?

 
 [2005-03-29 09:21 UTC] bugs at niluje dot net
Description: ------------ line 863 : $e->PEAR_Error = $this; causes segfault $e->PEAR_Error = clone $this; whould fix the problem, but $e->PEAR_Error would be empty anyway We know Exception with PEAR_Exception is a nasty hack mainly because the Exception should be raised in the code where the error happends, however it's not necessary to print a warning every time. here is the patch : *** PEAR.php.orig 2005-03-29 10:38:55.119321377 +0200 --- PEAR.php 2005-03-29 11:16:25.025498559 +0200 *************** *** 859,866 **** } } if ($this->mode & PEAR_ERROR_EXCEPTION) { ! trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_ErrorStack for exceptions", E_USER_WARNING); ! eval('$e = new Exception($this->message, $this->code);$e->PEAR_Error = $this;throw($e);'); } } --- 859,865 ---- } } if ($this->mode & PEAR_ERROR_EXCEPTION) { ! eval('$e = new Exception($this->message." :: ".$this->userinfo, $this->code); throw($e);'); } }

Comments

 [2005-03-29 09:26 UTC] bugs at niluje dot net
the textarea cuts the patch, here are the lines : 861 if ($this->mode & PEAR_ERROR_EXCEPTION) { 862 eval('$e = new Exception($this->message." :: ".$this->userinfo, $this->code); throw($e);'); 863 } 864 }
 [2005-03-29 13:38 UTC] cellog
PEAR_EXCEPTION is deprecated, use the PEAR_Exception class if you want exceptions in your project. <?php function PEAR_ErrorToPEAR_Exception($err) { if ($err->getCode) { throw new PEAR_Exception($err->getMessage(), $err->getCode(); } throw new PEAR_Exception($err->getMessage()); } PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'PEAR_ErrorToPEAR_Exception'); ?>
 [2005-03-29 13:51 UTC] bugs at niluje dot net
since PEAR_ERROR_EXCEPTION is broken you might want to do more than just generate a warning. maybe remove the code and comment the correct way of doing it.
 [2005-03-29 13:53 UTC] cellog
good point
 [2005-04-02 23:37 UTC] cellog
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.