For r60757: implement Database::getType() explicitly in each subclass, to make Roan...
authorTim Starling <tstarling@users.mediawiki.org>
Fri, 8 Jan 2010 00:31:24 +0000 (00:31 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Fri, 8 Jan 2010 00:31:24 +0000 (00:31 +0000)
includes/db/Database.php
includes/db/DatabaseIbm_db2.php
includes/db/DatabaseMssql.php
includes/db/DatabaseMysql.php
includes/db/DatabaseOracle.php
includes/db/DatabasePostgres.php
includes/db/DatabaseSqlite.php

index ef1abfc..28c3c94 100644 (file)
@@ -287,13 +287,7 @@ abstract class DatabaseBase {
        /**
         * Get the type of the DBMS, as it appears in $wgDBtype.
         */
-       function getType() {
-               if ( preg_match( '/^Database(\w+)$/', get_class( $this ), $m ) ) {
-                       return strtolower( $m[1] );
-               } else {
-                       throw new MWException( get_class( $this ) .'::getType: unable to determine type.' );
-               }
-       }
+       abstract function getType();
 
 #------------------------------------------------------------------------------
 # Other functions
index cc95b17..ef412d5 100644 (file)
@@ -391,7 +391,10 @@ class DatabaseIbm_db2 extends DatabaseBase {
                        return $this->mDBname;
                }
        }
-       
+
+       function getType() {
+               return 'ibm_db2';
+       }
        
        ######################################
        # Setup
index e81c8ad..6b1206b 100644 (file)
@@ -45,6 +45,10 @@ class DatabaseMssql extends DatabaseBase {
 
        }
 
+       function getType() {
+               return 'mssql';
+       }
+
        /**
         * todo: check if these should be true like parent class
         */
index d632e42..5ae4a22 100644 (file)
@@ -7,6 +7,10 @@
  * @see Database
  */
 class DatabaseMysql extends DatabaseBase {
+       function getType() {
+               return 'mysql';
+       }
+
        /*private*/ function doQuery( $sql ) {
                if( $this->bufferResults() ) {
                        $ret = mysql_query( $sql, $this->mConn );
index fe72d6b..2b5290e 100644 (file)
@@ -192,6 +192,10 @@ class DatabaseOracle extends DatabaseBase {
                wfRunHooks( 'DatabaseOraclePostInit', array( &$this ) );
        }
 
+       function getType() {
+               return 'oracle';
+       }
+
        function cascadingDeletes() {
                return true;
        }
index e1424b6..9a834ba 100644 (file)
@@ -84,6 +84,10 @@ class DatabasePostgres extends DatabaseBase {
 
        }
 
+       function getType() {
+               return 'postgres';
+       }
+
        function cascadingDeletes() {
                return true;
        }
index 8ad2aca..457d895 100644 (file)
@@ -32,6 +32,10 @@ class DatabaseSqlite extends DatabaseBase {
                $this->open( $server, $user, $password, $dbName );
        }
 
+       function getType() {
+               return 'sqlite';
+       }
+
        /**
         * @todo: check if it should be true like parent class
         */