Home » Database » MDB2 » Bug #3724
error while including on demand module
Details
| Submitted | 2005-03-06 22:18 UTC |
|---|---|
| From | akorthaus at web dot de |
| Status | Wont fix |
| Package | MDB2 |
| PHP Version | 5.0.3 |
| OS | Linux 2.4.28 (Gentoo) |
| Roadmaps | (Not assigned) |
Comments
[2005-03-06 22:18 UTC] akorthaus at web dot de
Description:
------------
I used a cvs-snapshot from 13.02.2005. Now I installed beta3 and my scripts don't work anymore.
A debug Backtrace:
object(MDB2_Error)[3]
public 'error_message_prefix' => ''
public 'mode' => 16
public 'level' => 1024
public 'code' => -34
public 'message' => 'MDB2 Error: error while including on demand module'
public 'userinfo' => '[Error message: unable to find module: MDB2/Driver/extended/mysql.php]
'
public 'backtrace' =>
array
0 =>
array
'file' => '/usr/lib/php/MDB2.php'
'line' => 813
'function' => 'PEAR_Error'
'class' => 'MDB2_Error'
'type' => '->'
'args' =>
array
0 => 'MDB2 Error: error while including on demand module'
1 => -34
2 => 16
3 => 'PEAR_errorHandling'
4 => '[Error message: unable to find module: MDB2/Driver/extended/mysql.php]
'
1 =>
array
'file' => '/usr/lib/php/PEAR.php'
'line' => 540
'function' => 'MDB2_Error'
'class' => 'MDB2_Error'
'type' => '->'
'args' =>
array
0 => -34
1 => 16
2 => 'PEAR_errorHandling'
3 => '[Error message: unable to find module: MDB2/Driver/extended/mysql.php]
'
2 =>
array
'file' => '/usr/lib/php/MDB2.php'
'line' => 1172
'function' => 'raiseError'
'class' => 'MDB2_Driver_mysql'
'type' => '->'
'args' =>
array
0 => null
1 => -34
2 => null
3 => null
4 => '[Error message: unable to find module: MDB2/Driver/extended/mysql.php]
'
5 => 'MDB2_Error'
6 => true
3 =>
array
'file' => '/usr/lib/php/MDB2.php'
'line' => 1456
'function' => 'raiseError'
'class' => 'MDB2_Driver_mysql'
'type' => '->'
'args' =>
array
0 => -34
1 => null
2 => null
3 => 'unable to find module: MDB2/Driver/extended/mysql.php'
4 =>
array
'file' => '/var/www/localhost/includes/db.module.php'
'line' => 40
'function' => 'loadModule'
'class' => 'MDB2_Driver_mysql'
'type' => '->'
'args' =>
array
0 => 'extended'
Reproduce code:
---------------
line 40 of '/var/www/localhost/includes/db.module.php':
$db->loadModule('extended');
line 1454 of '/usr/lib/php/MDB2.php':
if (!class_exists($class_name) && !MDB2::fileExists($file_name)) {
return $this->raiseError(MDB2_ERROR_LOADMODULE, null, null,
'unable to find module: '.$file_name);
}
src: http://cvs.php.net/co.php/pear/MDB2/MDB2.php?r=1.83#1454
I put in the following code before line 1454 of '/usr/lib/php/MDB2.php':
var_dump($file_name);
var_dump($class_name);
output:
'MDB2/Driver/extended/mysql.php'
'MDB2_Driver_extended_mysql'
Actual result:
--------------
file 'MDB2/Driver/extended/mysql.php' and class 'MDB2_Driver_extended_mysql' do not exist (as far as I can see)
[2005-03-06 23:04 UTC] akorthaus at web dot de
The problem was introduced with version 1.81 of MDB2.php "ont force the module name to ucfirst() in loadModule()"
http://cvs.php.net/diff.php/pear/MDB2/MDB2.php?r1=1.80&r2=1.81&ty=h
If I add these ucfirst() calls again
--- MDB2.php_orig 2005-03-06 23:54:02.000000000 +0100
+++ MDB2.php 2005-03-06 23:54:42.000000000 +0100
@@ -1445,10 +1445,10 @@
if (!isset($this->{$property})) {
$version = false;
- $class_name = 'MDB2_'.$module;
+ $class_name = 'MDB2_'.ucfirst($module);
$file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php';
if (!class_exists($class_name) && !MDB2::fileExists($file_name)) {
- $class_name = 'MDB2_Driver_'.$module.'_'.$this->phptype;
+ $class_name = 'MDB2_Driver_'.($module).'_'.$this->phptype;
$file_name = str_replace('_', DIRECTORY_SEPARATOR, $class_name).'.php';
$version = true;
if (!class_exists($class_name) && !MDB2::fileExists($file_name)) {
everything works fine. But I think the better alternative would be to change
$db->loadModule('extended');
to
$db->loadModule('Extended');
in my scripts, which also works fine (without the "undo-patch").
[2005-03-06 23:26 UTC] smith at backendmedia dot com
Yes I missed mentioning this in the changelog.
You need to do:
$mdb->loadModule('Extended');
instead of
$mdb->loadModule('extended');
I am planning on working on this stuff some more and adding __call() support fairly soon.