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

Bug #9101 PEAR_Exception::getCauseMessage() failure with a nested Exception
Submitted: 2006-10-20 07:25 UTC
From: aharvey at optimiser dot com Assigned: cellog
Status: Closed Package: PEAR (version 1.4.11)
PHP Version: 5_2 CVS-2006-10-20 OS: Linux (Ubuntu 6.06)
Roadmaps: (Not assigned)    
Subscription  


 [2006-10-20 07:25 UTC] aharvey at optimiser dot com (Adam Harvey)
Description: ------------ PEAR_Exception::__toString() throws a fatal error when the PEAR_Exception has a nested Exception. Note that a nested PEAR_Exception works, the failure only occurs when the nested exception inherits from Exception but not PEAR_Exception. Test script: --------------- <?php require_once 'PEAR/Exception.php'; try { throw new PEAR_Exception('Test exception.', new Exception('Nested exception.')); } catch (PEAR_Exception $e) { echo $e->__toString()."\n"; } ?> The patch at http://www.adamharvey.name/patches/PEAR_Exception-getCauseMessage.patch seems to fix the problem, but not being an expert on PEAR's internals, I don't know if that's actually the right solution. Expected result: ---------------- PEAR_Exception: Test exception. in /tmp/exception.php on line 7 Exception: Nested exception. in /tmp/exception.php on line 5 #0 {main} Actual result: -------------- Fatal error: Call to a member function getMessage() on a non-object in /usr/share/pear/PEAR/Exception.php on line 246 Call Stack: 0.0004 1. {main}() /tmp/exception.php:0 0.0028 2. PEAR_Exception->__toString() /tmp/exception.php:7 0.0028 3. PEAR_Exception->toText() /usr/share/pear/PEAR/Exception.php:305 0.0028 4. PEAR_Exception->getCauseMessage() /usr/share/pear/PEAR/Exception.php:365

Comments

 [2006-10-20 07:30 UTC] aharvey (Adam Harvey)
Fixed summary to reflect the real culprit in getCauseMessage(), not __toString(). Sorry about the mistake.
 [2006-10-30 03:48 UTC] cellog (Greg Beaver)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.