"check if pdo extension and DB specific driver is loaded AND try loading it if not (to be consistent with checks in setup/check_install.php)"

This commit is contained in:
Ralf Becker 2008-08-17 05:41:49 +00:00
parent 7696e91011
commit ca3245043b

View File

@ -1290,9 +1290,23 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
$dsn = $type.':host='.$egw_db->Host.';port='.$egw_db->Port.';dbname='.$egw_db->Database;
break;
}
// check once if pdo extension and DB specific driver is loaded or can be loaded
static $pdo_available;
if (is_null($pdo_available))
{
foreach(array('pdo','pdo_'.$type) as $ext)
{
if (!extension_loaded($ext) && function_exists('dl') && !dl($dl=PHP_SHLIB_PREFIX.$ext.'.'.PHP_SHLIB_SUFFIX))
{
throw new Exception ("PHP extension '$ext' not loaded AND can NOT be loaded via dl('$dl')!");
}
}
$pdo_available = true;
}
try {
self::$pdo = new PDO($dsn,$egw_db->User,$egw_db->Password);
} catch(Exception $e) {
// Exception reveals password, so we ignore the exception and connect again without pw, to get the right exception without pw
self::$pdo = new PDO($dsn,$egw_db->User,'$egw_db->Password');
}