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

Bug #13370 options are set after driver is loaded
Submitted: 2008-03-11 00:51 UTC Modified: 2008-03-11 13:41 UTC
From: ifeghali Assigned: quipo
Status: Closed Package: MDB2 (version CVS)
PHP Version: 5.2.5 OS: Mac OS 10.5
Roadmaps: (Not assigned)    
Subscription  


 [2008-03-11 00:51 UTC] ifeghali (Igor Feghali)
Description: ------------ In MDB2::factory the user options are set only after the database driver is loaded. Some drivers like the MySQL one relies on some options (use_transactions, default_table_type etc.) at construction time. This make those drivers to get the default options instead of the ones set by user. Test script: --------------- <?php require_once 'MDB2.php'; $dsn = 'mysql://root@localhost/information_schema'; $options = array( 'use_transactions' => false ); $db =& MDB2::factory($dsn, $options); var_dump($db->options['use_transactions']); var_dump($db->supports('transactions')); ?> Expected result: ---------------- bool(false) bool(true) * will only show this result if you are running a recent MySQL server version * Actual result: -------------- bool(false) bool(false)

Comments

 [2008-03-11 10:16 UTC] ifeghali (Igor Feghali)
MDB2::factory($dsn, array( 'use_transactions' => false )); function &factory($dsn, $options = false) { ... $class_name = 'MDB2_Driver_'.$dsninfo['phptype']; $debug = (!empty($options['debug'])); /* Here we Load the database Driver */ $err = MDB2::loadClass($class_name, $debug); ... /* Here we instantiate it */ /* use_transactions = true (MDB2.php:1181) */ $db =& new $class_name(); $db->setDSN($dsninfo); /* Now we set user options */ $err = MDB2::setOptions($db, $options); /* use_transactions = false, but too late. the database driver already read its value when it was true */ if (PEAR::isError($err)) { return $err; } return $db; }
 [2008-03-11 12:56 UTC] ifeghali (Igor Feghali)
PS: switch "Expected Result" with "Actual Result"
 [2008-03-11 13:33 UTC] ifeghali (Igor Feghali)
the patch provided by email fix this issue. you can commit and close this bug. thank you.
 [2008-03-11 13:41 UTC] quipo (Lorenzo Alberton)
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.