Revert "Add support for mysqli extension"
[lhc/web/wiklou.git] / includes / db / Database.php
index 274bd0c..df2877f 100644 (file)
@@ -717,7 +717,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
        /**
         * Given a DB type, construct the name of the appropriate child class of
         * DatabaseBase. This is designed to replace all of the manual stuff like:
-        *      $class = 'Database' . ucfirst( strtolower( $dbType ) );
+        *      $class = 'Database' . ucfirst( strtolower( $type ) );
         * as well as validate against the canonical list of DB types we have
         *
         * This factory function is mostly useful for when you need to connect to a
@@ -732,43 +732,17 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
         *
         * @param string $dbType A possible DB type
         * @param array $p An array of options to pass to the constructor.
-        *    Valid options are: host, user, password, dbname, flags, tablePrefix, driver
+        *    Valid options are: host, user, password, dbname, flags, tablePrefix
         * @return DatabaseBase subclass or null
         */
        final public static function factory( $dbType, $p = array() ) {
                $canonicalDBTypes = array(
-                       'mysql'    => array( 'mysqli', 'mysql' ),
-                       'postgres' => array(),
-                       'sqlite'   => array(),
-                       'oracle'   => array(),
-                       'mssql'    => array(),
+                       'mysql', 'postgres', 'sqlite', 'oracle', 'mssql'
                );
-
                $dbType = strtolower( $dbType );
-               if ( isset( $canonicalDBTypes[$dbType] ) && $canonicalDBTypes[$dbType] ) {
-                       $driver = isset( $p['driver'] ) ? $p['driver'] : null;
-                       $possibleDrivers = $canonicalDBTypes[$dbType];
-                       if ( $driver ) {
-                               if ( in_array( $driver, $possibleDrivers ) ) {
-                                       $dbType = $driver;
-                               } else {
-                                       throw new MWException( __METHOD__ .
-                                               " cannot construct Database with type '$dbType' and driver '$driver'" );
-                               }
-                       } else {
-                               foreach ( $possibleDrivers as $posDriver ) {
-                                       if ( extension_loaded( $posDriver ) ) {
-                                               $dbType = $posDriver;
-                                               break;
-                                       }
-                               }
-                               throw new MWException( __METHOD__ .
-                                       " no viable database extension found for type '$dbType'" );
-                       }
-               }
-
                $class = 'Database' . ucfirst( $dbType );
-               if ( class_exists( $class ) && is_subclass_of( $class, 'DatabaseBase' ) ) {
+
+               if ( in_array( $dbType, $canonicalDBTypes ) || ( class_exists( $class ) && is_subclass_of( $class, 'DatabaseBase' ) ) ) {
                        return new $class(
                                isset( $p['host'] ) ? $p['host'] : false,
                                isset( $p['user'] ) ? $p['user'] : false,