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

Bug #6226 Loading mysql driver fails
Submitted: 2005-12-12 11:39 UTC
From: petra dot arentzen at pegu dot de Assigned: lsmith
Status: Closed Package: MDB2_Driver_mysqli
PHP Version: 4.3.10 OS: Linux debian 2.6.14
Roadmaps: (Not assigned)    
Subscription  


 [2005-12-12 11:39 UTC] petra dot arentzen at pegu dot de
Description: ------------ MDB2 2.0.0beta6 beta MDB2_Driver_mysql 0.1.1 beta Loading of mysql.php fails if "MDB2.php" is included by include-path, because there is a test if include-file "MDB2/Driver/mysql.php" exists. Because the script's current directory isn't PEAR's main directory (which is in include-path) this must fail and MDB2::factory() will return an error. Maybe this problem applies to other drivers too. Test script: --------------- <? // from liveuser example5 require_once 'MDB2.php'; $dsn = 'mysql://testuser:testpassword@localhost/testdatabase'; $options = array( 'portability' => (MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL), want to use DB as the backend ); $dsn = MDB2::parseDSN($dsn); $database = $dsn['database']; unset($dsn['database']); $manager =& MDB2_Schema::factory($dsn, $options); ?> Commenting out line 317 - 321 in "MDB2.php" solves the problem. Expected result: ---------------- $manager should be a valid MDB2 Object Actual result: -------------- $manager is an Error Object

Comments

 [2005-12-12 11:41 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-12-12 12:16 UTC] petra dot arentzen at pegu dot de
Of course I had installed the mysql driver. The problem ist not that the include does not work - it's the test if the file exists before including it. The include would work but the code will not be executed because the previous test failes. /usr/share/php/MDB2.php: function &factory($dsn, $options = false) { $dsninfo = MDB2::parseDSN($dsn); if (!array_key_exists('phptype', $dsninfo)) { $err =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'no RDBMS driver specified'); return $err; } $class_name = 'MDB2_Driver_'.$dsninfo['phptype']; if (!class_exists($class_name)) { $file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php'; # if (!MDB2::fileExists($file_name)) { # $err =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, # 'unable to find: '.$file_name); # return $err; # } if (!include_once($file_name)) { $err =& MDB2::raiseError(MDB2_ERROR_NOT_FOUND, null, null, 'unable to load driver class: '. $file_name); return $err; } } $db =& new $class_name(); $db->setDSN($dsninfo); $err = MDB2::setOptions($db, $options); if (PEAR::isError($err)) { return $err; } return $db; } The lines with the leading '#' which I have filled in on my local file are causing the trouble.
 [2005-12-12 12:57 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-12-12 13:43 UTC] petra dot arentzen at pegu dot de
And I don't understand why you don't understand. It's not the first time I am using PEAR. I worked e.g with DB, DB_DataObject for more than three years. I'm sure that my Include-Path ist set correctly. No other pear application had ever had trouble with it. It seems that the (imho) useless test for the existence of the file before including it causes the trouble. So if I comment out this test the code works. In this case the code with the <code> if (!include_once($file_name)) { </code> works fine because my include-path is set correcly. Now I've told all I can tell about this bug/ trouble/ problem and if you are telling me further that it is my fail then I can't change it. I've tried my very best ;-)
 [2005-12-12 13:47 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-12-12 16:20 UTC] petra dot arentzen at pegu dot de
Your hint about safe_mode leads me some steps further. I've debugged my script again and again. The problem seems to be the PHP-function is_readable(). Here's what I figured out: safe_mode off/ user: petra - works fine safe_mode on/ user: petra - fails safe_mode on/ user: root - workes fine This seems to be very similar to the following bug http://bugs.php.net/bug.php?id=31618 This bug was reported for php 5 cvs version. Perhaps it's an old bug which had survived since 4.3.10 or even earlier. So it seems not to be a problem of MDB2. But perhaps it makes sense to remove calling fileExists().
 [2005-12-12 17:04 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-12-12 17:36 UTC] petra dot arentzen at pegu dot de
Ok, thank you. I think I can live with that.
 [2005-12-13 10:28 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!