Make Database into abstract class DatabaseBase
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 12 Jun 2009 17:59:04 +0000 (17:59 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 12 Jun 2009 17:59:04 +0000 (17:59 +0000)
All other databases were changed to extend DatabaseBase instead of
Database.  Database was kept as an alias for DatabaseMysql for
compatibility.  Existing explicit references to Database that I could
find were changed to DatabaseMysql for the sake of clarity.

Should cause no functional changes.

includes/AutoLoader.php
includes/db/Database.php
includes/db/DatabaseIbm_db2.php
includes/db/DatabaseMssql.php
includes/db/DatabaseOracle.php
includes/db/DatabasePostgres.php
includes/db/DatabaseSqlite.php
t/inc/Database.t
tests/MediaWiki_TestCase.php

index a43ed3f..62db995 100644 (file)
@@ -303,6 +303,7 @@ $wgAutoloadLocalClasses = array(
        'Blob' => 'includes/db/Database.php',
        'ChronologyProtector' => 'includes/db/LBFactory.php',
        'Database' => 'includes/db/Database.php',
+       'DatabaseBase' => 'includes/db/Database.php',
        'DatabaseMssql' => 'includes/db/DatabaseMssql.php',
        'DatabaseMysql' => 'includes/db/Database.php',
        'DatabaseOracle' => 'includes/db/DatabaseOracle.php',
index 40dc2e8..e96e584 100644 (file)
@@ -19,7 +19,7 @@ define( 'DEADLOCK_DELAY_MAX', 1500000 );
  * Database abstraction object
  * @ingroup Database
  */
-class Database {
+abstract class DatabaseBase {
 
 #------------------------------------------------------------------------------
 # Variables
@@ -307,7 +307,7 @@ class Database {
        }
 
        /**
-        * Same as new Database( ... ), kept for backward compatibility
+        * Same as new DatabaseMysql( ... ), kept for backward compatibility
         * @param $server String: database server host
         * @param $user String: database user name
         * @param $password String: database user password
@@ -317,7 +317,7 @@ class Database {
         */
        static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 )
        {
-               return new Database( $server, $user, $password, $dbName, $failFunction, $flags );
+               return new DatabaseMysql( $server, $user, $password, $dbName, $failFunction, $flags );
        }
 
        /**
@@ -2426,10 +2426,15 @@ class Database {
  * @ingroup Database
  * @see Database
  */
-class DatabaseMysql extends Database {
+class DatabaseMysql extends DatabaseBase {
        # Inherit all
 }
 
+/**
+ * Legacy support: Database == DatabaseMysql
+ */
+class Database extends DatabaseMysql {}
+
 /******************************************************************************
  * Utility classes
  *****************************************************************************/
index 6f7b675..7fdfd3a 100644 (file)
@@ -102,7 +102,7 @@ class IBM_DB2Blob {
  * Primary database interface
  * @ingroup Database
  */
-class DatabaseIbm_db2 extends Database {
+class DatabaseIbm_db2 extends DatabaseBase {
        /*
         * Inherited members
        protected $mLastQuery = '';
index 524fa07..66f6757 100644 (file)
@@ -10,7 +10,7 @@
 /**
  * @ingroup Database
  */
-class DatabaseMssql extends Database {
+class DatabaseMssql extends DatabaseBase {
 
        var $mAffectedRows;
        var $mLastResult;
index 0d3effe..fbfcbee 100644 (file)
@@ -153,7 +153,7 @@ class ORAField {
 /**
  * @ingroup Database
  */
-class DatabaseOracle extends Database {
+class DatabaseOracle extends DatabaseBase {
        var $mInsertId = NULL;
        var $mLastResult = NULL;
        var $numeric_version = NULL;
index 3a2212a..d477834 100644 (file)
@@ -68,7 +68,7 @@ END;
 /**
  * @ingroup Database
  */
-class DatabasePostgres extends Database {
+class DatabasePostgres extends DatabaseBase {
        var $mInsertId = NULL;
        var $mLastResult = NULL;
        var $numeric_version = NULL;
index 525e54b..5907b46 100644 (file)
@@ -10,7 +10,7 @@
 /**
  * @ingroup Database
  */
-class DatabaseSqlite extends Database {
+class DatabaseSqlite extends DatabaseBase {
 
        var $mAffectedRows;
        var $mLastResult;
index 3907779..edff163 100644 (file)
@@ -12,7 +12,7 @@ require 'includes/Setup.php';
 
 plan( 9 );
 
-$db = new Database( $wgDBserver, $wgDBuser, $wgDBpassword );
+$db = new DatabaseMysql( $wgDBserver, $wgDBuser, $wgDBpassword );
 
 cmp_ok( $db->addQuotes( NULL ), '==',
        'NULL', 'Add quotes to NULL' );
index 387fe01..2692398 100644 (file)
@@ -8,7 +8,7 @@ abstract class MediaWiki_TestCase extends PHPUnit_Framework_TestCase {
        protected function buildTestDatabase( $tables ) {
                global $testOptions, $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
                $wgDBprefix = 'parsertest_';
-               $db = new Database(
+               $db = new DatabaseMysql(
                        $wgDBserver,
                        $wgDBadminuser,
                        $wgDBadminpassword,