Move DatabaseBase to a class alias for type-hints
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 28 Sep 2016 23:08:15 +0000 (16:08 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 29 Sep 2016 06:09:03 +0000 (06:09 +0000)
Change-Id: Ib6bbbd751358cbc2f2d2767c80721d3d8f142c0d

autoload.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/DatabaseBase.php [deleted file]
includes/libs/rdbms/database/DatabaseMysqlBase.php
includes/libs/rdbms/database/DatabasePostgres.php
includes/libs/rdbms/database/DatabaseSqlite.php
includes/utils/AutoloadGenerator.php

index dfb0bf6..8e019b8 100644 (file)
@@ -317,7 +317,7 @@ $wgAutoloadLocalClasses = [
        'DBUnexpectedError' => __DIR__ . '/includes/libs/rdbms/exception/DBUnexpectedError.php',
        'DataUpdate' => __DIR__ . '/includes/deferred/DataUpdate.php',
        'Database' => __DIR__ . '/includes/libs/rdbms/database/Database.php',
-       'DatabaseBase' => __DIR__ . '/includes/libs/rdbms/database/DatabaseBase.php',
+       'DatabaseBase' => __DIR__ . '/includes/libs/rdbms/database/Database.php',
        'DatabaseDomain' => __DIR__ . '/includes/libs/rdbms/database/DatabaseDomain.php',
        'DatabaseInstaller' => __DIR__ . '/includes/installer/DatabaseInstaller.php',
        'DatabaseLag' => __DIR__ . '/maintenance/lag.php',
index 2b058e9..4f1f38e 100644 (file)
@@ -3426,3 +3426,5 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                }
        }
 }
+
+class_alias( 'Database', 'DatabaseBase' );
diff --git a/includes/libs/rdbms/database/DatabaseBase.php b/includes/libs/rdbms/database/DatabaseBase.php
deleted file mode 100644 (file)
index 71e5f93..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-/**
- * @defgroup Database Database
- *
- * This file deals with database interface functions
- * and query specifics/optimisations.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Database
- */
-
-/**
- * Database abstraction object
- * @ingroup Database
- */
-abstract class DatabaseBase extends Database {
-       // Backwards-compatibility alias for type-hints
-}
index c31b9f9..d654429 100644 (file)
@@ -29,7 +29,7 @@
  * @since 1.22
  * @see Database
  */
-abstract class DatabaseMysqlBase extends DatabaseBase {
+abstract class DatabaseMysqlBase extends Database {
        /** @var MysqlMasterPos */
        protected $lastKnownReplicaPos;
        /** @var string Method to detect replica DB lag */
index a69a5fa..f58628e 100644 (file)
@@ -24,7 +24,7 @@
 /**
  * @ingroup Database
  */
-class DatabasePostgres extends DatabaseBase {
+class DatabasePostgres extends Database {
        /** @var int|bool */
        protected $port;
 
index 156e525..3ccf3f0 100644 (file)
@@ -25,7 +25,7 @@
 /**
  * @ingroup Database
  */
-class DatabaseSqlite extends DatabaseBase {
+class DatabaseSqlite extends Database {
        /** @var bool Whether full text is enabled */
        private static $fulltextEnabled = null;
 
index 395ce37..319b5d4 100644 (file)
@@ -160,6 +160,7 @@ class AutoloadGenerator {
         *
         * @param {string} $commandName Command name to include in comment
         * @param {string} $filename of PHP file to put autoload information in.
+        * @return string
         */
        protected function generatePHPAutoload( $commandName, $filename ) {
                // No existing JSON file found; update/generate PHP file
@@ -290,6 +291,10 @@ EOD;
                foreach ( glob( $this->basepath . '/*.php' ) as $file ) {
                        $this->readFile( $file );
                }
+
+               // Legacy aliases
+               $this->forceClassPath( 'DatabaseBase',
+                       $this->basepath . '/includes/libs/rdbms/database/Database.php' );
        }
 }