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

Bug #19058 spl_autoload_register() and PEAR::isError
Submitted: 2011-11-19 22:26 UTC
From: jack331 Assigned:
Status: Duplicate Package: MDB2 (version 2.5.0b3)
PHP Version: 5.3.8 OS: winxp sp3
Roadmaps: 2.5.0b4    
Subscription  


 [2011-11-19 22:26 UTC] jack331 (Jacques Deyrieux)
Description: ------------ Hi, When i use spl_autoload_register(), when i use $mdb2->quote('hello','text'); the MDB2::isError function use function is_a($data) and trigger a call to spl_autoload_register() with string value as classname ;-) below code for check Test script: --------------- class c_autoloader { public function __construct() { spl_autoload_register(array($this, 'loader')); } private function loader($className) { echo 'Trying to load ', $className, ' via ', __METHOD__, "()<br />\n"; $a = debug_backtrace(false); print_r($a); include($className . '.php'); } } $autoloader = new c_autoloader(); function dbConnect($dsn) { $options = array( 'debug' => 2, 'result_buffering' => false, ); $mdb2 =& MDB2::connect($dsn, $options); if (PEAR::isError($mdb2)) { die('connexion:'.$mdb2->getMessage()); } $mdb2->setFetchMode(MDB2_FETCHMODE_ASSOC); return $mdb2; } $mdb2 = dbConnect('your dsn'); $username = 'myusername'; $sql = 'SELECT * FROM users WHERE username='.$mdb2->quote($username); $stmt = $mdb2->query($sql); Expected result: ---------------- in fact, to block this, it's really easy with if check in replacement of original. gettype($data)=='object' check if this var is an object function isError($data, $code = null) { if (!gettype($data)=='object' || !is_a($data, 'PEAR_Error')) { return false; } Actual result: -------------- Array ( [0] => Array ( [function] => loader [class] => c_autoloader [type] => -> [args] => Array ( [0] => jdeyrieux ) ) [1] => Array ( [function] => spl_autoload_call [args] => Array ( [0] => jdeyrieux ) ) [2] => Array ( [file] => I:\Travail\home\pear\PEAR.php [line] => 252 [function] => is_a [args] => Array ( [0] => jdeyrieux [1] => PEAR_Error ) ) [3] => Array ( [file] => I:\Travail\home\pear\MDB2\Driver\Datatype\Common.php [line] => 1230 [function] => isError [class] => PEAR [type] => -> [args] => Array ( [0] => jdeyrieux ) ) [4] => Array ( [file] => I:\Travail\home\pear\MDB2\Driver\Datatype\Common.php [line] => 1176 [function] => _quoteText [class] => MDB2_Driver_Datatype_Common [type] => -> [args] => Array ( [0] => jdeyrieux [1] => 1 [2] => ) ) [5] => Array ( [file] => I:\Travail\home\pear\MDB2.php [line] => 3056 [function] => quote [class] => MDB2_Driver_Datatype_Common [type] => -> [args] => Array ( [0] => jdeyrieux [1] => text [2] => 1 [3] => ) )

Comments

 [2011-11-21 17:51 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Duplicate
Bug #18826