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

Bug #5766 DB.php doesn't check connection errors w/patch
Submitted: 2005-10-24 14:50 UTC
From: tacker Assigned: datenpunk
Status: Closed Package: DB_NestedSet
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2005-10-24 14:50 UTC] tacker
Description: ------------ If the connection cannot be established, a fatal error is thrown. Fatal error: Call to undefined method DB_Error::setFetchMode() in /usr/share/php/DB/NestedSet/DB.php on line 51 This patch fixes this. --- /usr/share/php/DB/NestedSet/DB.php 2005-10-24 16:47:12.000000000 +0200 +++ /usr/share/php/DB/NestedSet/DB.php.newe 2005-10-24 16:47:24.000000000 +0200 @@ -48,6 +48,9 @@ $this->_debugMessage('DB_NestedSet_DB($dsn, $params = array())'); $this->DB_NestedSet($params); $this->db = & $this->_db_Connect($dsn); + if ($this->_isDBError($this->db)) { + return false; + } $this->db->setFetchMode(DB_FETCHMODE_ASSOC); } // }}} Expected result: ---------------- return false or throw a PEAR::Error Actual result: -------------- Fatal error: Call to undefined method DB_Error::setFetchMode() in /usr/share/php/DB/NestedSet/DB.php on line 51

Comments

 [2005-10-26 00:01 UTC] datenpunk at php dot net
I can't reproduce this. If I provide wrong credentials I get a "Fatal error: DB Error: insufficient permissions in /usr/share/php/PEAR.php on line 846" which is somehow an expected result. I think your PEAR::DB is set to ignore such errors and I am not sure how this is done. Could you please provide some hints (PEAR::DB params you used) on that. Thanks a lot -- Daniel Khan
 [2005-10-26 08:59 UTC] tacker
This happens if you are using a custom error handler. Test case: <?php error_reporting(E_ALL); // Uncomment the error section to reproduce /* set_error_handler('error_handler'); function error_handler() { } */ require_once 'DB/NestedSet.php'; $dsn = 'mysql://user:password@localhost/willnotwork'; $fields = array( 'id' => 'id', 'root_id' => 'rootid', 'l_id' => 'l', 'r_id' => 'r', 'norder' => 'norder', 'level' => 'level', 'name' => 'name', 'parent' => 'parent', ); DB_NestedSet::factory('DB', $dsn, $fields); ?>
 [2006-01-08 21:30 UTC] datenpunk at php dot net
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.