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

Bug #9800 Blank Page when mysql fails to load.
Submitted: 2007-01-11 08:49 UTC
From: pprocacci at bellsouth dot net Assigned: quipo
Status: Closed Package: MDB2 (version 2.3.0)
PHP Version: 5.2.0 OS: FreeBSD 6.1
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 : 45 - 7 = ?

 
 [2007-01-11 08:49 UTC] pprocacci at bellsouth dot net (Paul Procacci)
Description: ------------ Tested Operating Systems: FreeBSD 4.11 FreeBSD 6.1 Tested Versions of PHP: 5.2.0. 4.3.10 INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET: ========================================= PACKAGE VERSION STATE Archive_Tar 1.3.2 stable Console_Getopt 1.2.1 stable HTTP_Session 0.5.5 beta MDB2 2.3.0 stable MDB2_Driver_mysqli 1.3.0 stable PEAR 1.4.11 stable XML_Parser 1.2.8 stable XML_RPC 1.5.1 stable This problem presents itself with either of the two drivers that I've had the luxury to test, namely mysql or mysqli. I haven't tested it with other drivers. I've done a bit of debugging, and have discovered why the page is blank, but unfortunately my OOP skills are like.....well, lets just say I'm a procedural type of guy. When making the initial connection to the database via the drivers method "connect", if the extension that is necessary to make that connection doesn't exist, then pear handles the dynamic loading of the shared module provided it's present via PEAR::loadExtension(). While debugging, I lost track of exactly what happens next, but I ended up in the class method "errorInfo" in either the mysql or mysqli drivers, which then in turn halts execution of the script with no output at the following line: $native_code = @mysqli_errno(); My guess is that MDB2 isn't handling the 'false' value properly that being returned by PEAR::loadExtension(), but I'm no expert and don't want to mislead anyone. Thanks for taking a peek. Test script: --------------- A test script is impossible due to the nature of revealing usernames and passwords, however sudo code will work. <?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors", 1); $db =& MDB2::factory("mysqli://user:pass@unix(/tmp/mysql.sock)/db"); //Insert Error checking....doesn't bomb here. $row =& $db->queryRow($query); // Never returns print "Never gets run"; ?> Expected result: ---------------- Using the sudo-code.... If the driver for the database isn't present either statically and/or if PEAR can't load that module, then I would expect the application to give a bit of information as to why rather than given no output at all. Actual result: -------------- Well, this is the only way to demonstrate it and it's not going to tell you much. Note: myhost.net doesn't actually exist. fileserv# telnet dev.myhost.net 80 Trying 65.17.210.244... Connected to dev.myhost.net. Escape character is '^]'. GET / HTTP/1.1 connection: close host: dev.myhost.net HTTP/1.1 200 OK Date: Thu, 11 Jan 2007 08:56:12 GMT Server: Apache/1.3.33 (Unix) mod_throttle/3.1.2 PHP/4.3.10 FrontPage/5.0.2.2623 mod_ssl/2.8.22 OpenSSL/0.9.7d X-Powered-By: PHP/4.3.10 Connection: close Transfer-Encoding: chunked Content-Type: text/html 0 Connection closed by foreign host.

Comments

 [2007-01-11 09:10 UTC] pprocacci at bellsouth dot net
Doing more debugging here: After the failure of loading the extension, an error gets raised: mysqli.php:394 $this->raiseError(MDB2_ERROR_NOT_FOUND, ...) The following elseif statements gets executed within that method: MDB2.php:1409 } elseif (isset($this->connection)) { and then..... MDB2.php:1414 list($code, $native_errno, $native_msg) = $this->errorInfo($code); where $this is the driver being used (i.e. MDB2_Driver_mysqli). and then it bombs on the line given: mysqli.php:125 $native_code = @mysqli_errno(); I hope that helps.
 [2007-01-11 09:22 UTC] pprocacci at bellsouth dot net
Yeah, I know another comment: define('MDB2_ERROR_NOT_FOUND', -4); You are raising MDB2_ERROR_NOT_FOUND which has a value of -4, but the following will always return false in this case: MDB2.php:1398 if (PEAR::isError($code)) { because PEAR::isError returns: return $data->getCode() == $code; define('PEAR_ERROR_TRIGGER', 4); -4 != 4 Gong to bed....hopefully I get some constructive feekback without having to modify the source files! Thanks
 [2007-01-11 10:06 UTC] quipo (Lorenzo Alberton)
Thanks for the excellent analysis. Fixed in CVS.