Update more docs and type hints to use IDatabase
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 6 Oct 2015 05:39:37 +0000 (22:39 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Wed, 7 Oct 2015 01:49:52 +0000 (18:49 -0700)
Change-Id: I8c8d85b32a8aba21e14d2a2dde4c25eb509186c1

16 files changed:
includes/CategoryFinder.php
includes/LinkFilter.php
includes/RevisionList.php
includes/SiteStats.php
includes/UserRightsProxy.php
includes/externalstore/ExternalStoreDB.php
includes/filebackend/filejournal/DBFileJournal.php
includes/filebackend/lockmanager/DBLockManager.php
includes/filerepo/ForeignDBRepo.php
includes/filerepo/ForeignDBViaLBRepo.php
includes/jobqueue/JobRunner.php
includes/libs/ObjectFactory.php
includes/objectcache/SqlBagOStuff.php
includes/pager/IndexPager.php
includes/utils/BatchRowIterator.php
includes/utils/BatchRowWriter.php

index 77c43bf..d779141 100644 (file)
@@ -64,7 +64,7 @@ class CategoryFinder {
        /** @var string "AND" or "OR" */
        protected $mode;
 
-       /** @var DatabaseBase Read-DB slave */
+       /** @var IDatabase Read-DB slave */
        protected $dbr;
 
        /**
index 7215cec..802bfbe 100644 (file)
@@ -71,7 +71,7 @@ class LinkFilter {
        }
 
        /**
-        * Make an array to be used for calls to DatabaseBase::buildLike(), which
+        * Make an array to be used for calls to Database::buildLike(), which
         * will match the specified string. There are several kinds of filter entry:
         *     *.domain.com    -  Produces http://com.domain.%, matches domain.com
         *                        and www.domain.com
@@ -89,7 +89,7 @@ class LinkFilter {
         *
         * @param string $filterEntry Domainparts
         * @param string $protocol Protocol (default http://)
-        * @return array Array to be passed to DatabaseBase::buildLike() or false on error
+        * @return array Array to be passed to Database::buildLike() or false on error
         */
        public static function makeLikeArray( $filterEntry, $protocol = 'http://' ) {
                $db = wfGetDB( DB_SLAVE );
index 1df0ca0..4d72c24 100644 (file)
@@ -121,7 +121,7 @@ abstract class RevisionListBase extends ContextSource {
 
        /**
         * Do the DB query to iterate through the objects.
-        * @param IDatabase $db DatabaseBase object to use for the query
+        * @param IDatabase $db DB object to use for the query
         */
        abstract public function doQuery( $db );
 
index 64e5ea0..76e7f7e 100644 (file)
@@ -281,12 +281,12 @@ class SiteStatsInit {
 
        /**
         * Constructor
-        * @param bool|DatabaseBase $database
-        * - Boolean: whether to use the master DB
-        * - DatabaseBase: database connection to use
+        * @param bool|IDatabase $database
+        * - boolean: Whether to use the master DB
+        * - IDatabase: Database connection to use
         */
        public function __construct( $database = false ) {
-               if ( $database instanceof DatabaseBase ) {
+               if ( $database instanceof IDatabase ) {
                        $this->db = $database;
                } else {
                        $this->db = wfGetDB( $database ? DB_MASTER : DB_SLAVE );
@@ -365,10 +365,10 @@ class SiteStatsInit {
         * for the original initStats, but without output.
         *
         * @param IDatabase|bool $database
-        * - Boolean: whether to use the master DB
-        * - DatabaseBase: database connection to use
+        * - boolean: Whether to use the master DB
+        * - IDatabase: Database connection to use
         * @param array $options Array of options, may contain the following values
-        * - activeUsers Boolean: whether to update the number of active users (default: false)
+        * - activeUsers boolean: Whether to update the number of active users (default: false)
         */
        public static function doAllAndCommit( $database, array $options = array() ) {
                $options += array( 'update' => false, 'activeUsers' => false );
index 0d1708f..3a3eb53 100644 (file)
@@ -146,7 +146,7 @@ class UserRightsProxy {
         *
         * @param string $database
         * @param bool $ignoreInvalidDB If true, don't check if $database is in $wgLocalDatabases
-        * @return DatabaseBase|null If invalid selection
+        * @return IDatabase|null If invalid selection
         */
        public static function getDB( $database, $ignoreInvalidDB = false ) {
                global $wgDBname;
index cc70960..83d5f4c 100644 (file)
@@ -116,7 +116,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
         * Get a slave database connection for the specified cluster
         *
         * @param string $cluster Cluster name
-        * @return DatabaseBase
+        * @return IDatabase
         */
        function getSlave( $cluster ) {
                global $wgDefaultExternalStore;
@@ -141,7 +141,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
         * Get a master database connection for the specified cluster
         *
         * @param string $cluster Cluster name
-        * @return DatabaseBase
+        * @return IDatabase
         */
        function getMaster( $cluster ) {
                $wiki = isset( $this->params['wiki'] ) ? $this->params['wiki'] : false;
@@ -268,7 +268,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
         * Helper function for self::batchFetchBlobs for merging master/slave results
         * @param array &$ret Current self::batchFetchBlobs return value
         * @param array &$ids Map from blob_id to requested itemIDs
-        * @param mixed $res DB result from DatabaseBase::select
+        * @param mixed $res DB result from Database::select
         */
        private function mergeBatchResult( array &$ret, array &$ids, $res ) {
                foreach ( $res as $row ) {
index 4f64f02..0ade616 100644 (file)
@@ -27,7 +27,7 @@
  * @since 1.20
  */
 class DBFileJournal extends FileJournal {
-       /** @var DatabaseBase */
+       /** @var IDatabase */
        protected $dbw;
 
        protected $wiki = false; // string; wiki DB name
@@ -174,7 +174,7 @@ class DBFileJournal extends FileJournal {
        /**
         * Get a master connection to the logging DB
         *
-        * @return DatabaseBase
+        * @return IDatabase
         * @throws DBError
         */
        protected function getMasterDB() {
index b81cf3e..9d4f009 100644 (file)
@@ -146,7 +146,7 @@ abstract class DBLockManager extends QuorumLockManager {
         * Get (or reuse) a connection to a lock DB
         *
         * @param string $lockDb
-        * @return DatabaseBase
+        * @return IDatabase
         * @throws DBError
         */
        protected function getConnection( $lockDb ) {
@@ -185,10 +185,10 @@ abstract class DBLockManager extends QuorumLockManager {
         * Do additional initialization for new lock DB connection
         *
         * @param string $lockDb
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @throws DBError
         */
-       protected function initConnection( $lockDb, DatabaseBase $db ) {
+       protected function initConnection( $lockDb, IDatabase $db ) {
        }
 
        /**
@@ -254,9 +254,9 @@ class MySqlLockManager extends DBLockManager {
 
        /**
         * @param string $lockDb
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         */
-       protected function initConnection( $lockDb, DatabaseBase $db ) {
+       protected function initConnection( $lockDb, IDatabase $db ) {
                # Let this transaction see lock rows from other transactions
                $db->query( "SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;" );
        }
index dfdb375..f3a560b 100644 (file)
@@ -72,7 +72,7 @@ class ForeignDBRepo extends LocalRepo {
        }
 
        /**
-        * @return DatabaseBase
+        * @return IDatabase
         */
        function getMasterDB() {
                if ( !isset( $this->dbConn ) ) {
@@ -84,7 +84,7 @@ class ForeignDBRepo extends LocalRepo {
        }
 
        /**
-        * @return DatabaseBase
+        * @return IDatabase
         */
        function getSlaveDB() {
                return $this->getMasterDB();
index f49b716..357f0b9 100644 (file)
@@ -53,14 +53,14 @@ class ForeignDBViaLBRepo extends LocalRepo {
        }
 
        /**
-        * @return DatabaseBase
+        * @return IDatabase
         */
        function getMasterDB() {
                return wfGetDB( DB_MASTER, array(), $this->wiki );
        }
 
        /**
-        * @return DatabaseBase
+        * @return IDatabase
         */
        function getSlaveDB() {
                return wfGetDB( DB_SLAVE, array(), $this->wiki );
index 1304362..7ce731d 100644 (file)
@@ -485,7 +485,7 @@ class JobRunner implements LoggerAwareInterface {
                // Re-ping all masters with transactions. This throws DBError if some
                // connection died while waiting on locks/slaves, triggering a rollback.
                wfGetLBFactory()->forEachLB( function( LoadBalancer $lb ) use ( $fname ) {
-                       $lb->forEachOpenConnection( function( DatabaseBase $conn ) use ( $fname ) {
+                       $lb->forEachOpenConnection( function( IDatabase $conn ) use ( $fname ) {
                                if ( $conn->writesOrCallbacksPending() ) {
                                        $conn->query( "SELECT 1", $fname );
                                }
index 1cb544b..0b9aa7c 100644 (file)
@@ -45,7 +45,7 @@ class ObjectFactory {
         * Values in the arguments collection which are Closure instances will be
         * expanded by invoking them with no arguments before passing the
         * resulting value on to the constructor/callable. This can be used to
-        * pass DatabaseBase instances or other live objects to the
+        * pass IDatabase instances or other live objects to the
         * constructor/callable. This behavior can be suppressed by adding
         * closure_expansion => false to the specification.
         *
index 91189c8..f634df1 100644 (file)
@@ -127,7 +127,7 @@ class SqlBagOStuff extends BagOStuff {
         * Get a connection to the specified database
         *
         * @param int $serverIndex
-        * @return DatabaseBase
+        * @return IDatabase
         * @throws MWException
         */
        protected function getDB( $serverIndex ) {
@@ -482,7 +482,7 @@ class SqlBagOStuff extends BagOStuff {
        }
 
        /**
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @param string $exptime
         * @return bool
         */
@@ -491,7 +491,7 @@ class SqlBagOStuff extends BagOStuff {
        }
 
        /**
-        * @param DatabaseBase $db
+        * @param IDatabase $db
         * @return string
         */
        protected function getMaxDateTime( $db ) {
index 7a5952f..f0e7f3e 100644 (file)
@@ -182,7 +182,7 @@ abstract class IndexPager extends ContextSource implements Pager {
        /**
         * Get the Database object in use
         *
-        * @return DatabaseBase
+        * @return IDatabase
         */
        public function getDatabase() {
                return $this->mDb;
index 59350e6..07cb2bc 100644 (file)
@@ -26,7 +26,7 @@
 class BatchRowIterator implements RecursiveIterator {
 
        /**
-        * @var DatabaseBase $db The database to read from
+        * @var IDatabase $db The database to read from
         */
        protected $db;
 
@@ -58,7 +58,7 @@ class BatchRowIterator implements RecursiveIterator {
 
        /**
         * @var array $fetchColumns List of column names to select from the
-        *  table suitable for use with DatabaseBase::select()
+        *  table suitable for use with IDatabase::select()
         */
        protected $fetchColumns;
 
@@ -98,7 +98,7 @@ class BatchRowIterator implements RecursiveIterator {
 
        /**
         * @param array $condition Query conditions suitable for use with
-        *  DatabaseBase::select
+        *  IDatabase::select
         */
        public function addConditions( array $conditions ) {
                $this->conditions = array_merge( $this->conditions, $conditions );
@@ -106,7 +106,7 @@ class BatchRowIterator implements RecursiveIterator {
 
        /**
         * @param array $condition Query join conditions suitable for use
-        *  with DatabaseBase::select
+        *  with IDatabase::select
         */
        public function addJoinConditions( array $conditions ) {
                $this->joinConditions = array_merge( $this->joinConditions, $conditions );
@@ -114,7 +114,7 @@ class BatchRowIterator implements RecursiveIterator {
 
        /**
         * @param array $columns List of column names to select from the
-        *  table suitable for use with DatabaseBase::select()
+        *  table suitable for use with IDatabase::select()
         */
        public function setFetchColumns( array $columns ) {
                // If it's not the all column selector merge in the primary keys we need
index 377ed85..13cab5b 100644 (file)
@@ -22,7 +22,7 @@
  */
 class BatchRowWriter {
        /**
-        * @var DatabaseBase $db The database to write to
+        * @var IDatabase $db The database to write to
         */
        protected $db;