From 7c07943eab6e3654ae3ccd3081f4cc74d48e5876 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 5 Oct 2015 22:39:37 -0700 Subject: [PATCH] Update more docs and type hints to use IDatabase Change-Id: I8c8d85b32a8aba21e14d2a2dde4c25eb509186c1 --- includes/CategoryFinder.php | 2 +- includes/LinkFilter.php | 4 ++-- includes/RevisionList.php | 2 +- includes/SiteStats.php | 14 +++++++------- includes/UserRightsProxy.php | 2 +- includes/externalstore/ExternalStoreDB.php | 6 +++--- includes/filebackend/filejournal/DBFileJournal.php | 4 ++-- includes/filebackend/lockmanager/DBLockManager.php | 10 +++++----- includes/filerepo/ForeignDBRepo.php | 4 ++-- includes/filerepo/ForeignDBViaLBRepo.php | 4 ++-- includes/jobqueue/JobRunner.php | 2 +- includes/libs/ObjectFactory.php | 2 +- includes/objectcache/SqlBagOStuff.php | 6 +++--- includes/pager/IndexPager.php | 2 +- includes/utils/BatchRowIterator.php | 10 +++++----- includes/utils/BatchRowWriter.php | 2 +- 16 files changed, 38 insertions(+), 38 deletions(-) diff --git a/includes/CategoryFinder.php b/includes/CategoryFinder.php index 77c43bf089..d779141052 100644 --- a/includes/CategoryFinder.php +++ b/includes/CategoryFinder.php @@ -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; /** diff --git a/includes/LinkFilter.php b/includes/LinkFilter.php index 7215cec922..802bfbe948 100644 --- a/includes/LinkFilter.php +++ b/includes/LinkFilter.php @@ -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 ); diff --git a/includes/RevisionList.php b/includes/RevisionList.php index 1df0ca0a98..4d72c24a5a 100644 --- a/includes/RevisionList.php +++ b/includes/RevisionList.php @@ -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 ); diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 64e5ea027b..76e7f7eb9f 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -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 ); diff --git a/includes/UserRightsProxy.php b/includes/UserRightsProxy.php index 0d1708f314..3a3eb53873 100644 --- a/includes/UserRightsProxy.php +++ b/includes/UserRightsProxy.php @@ -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; diff --git a/includes/externalstore/ExternalStoreDB.php b/includes/externalstore/ExternalStoreDB.php index cc70960fe3..83d5f4ca53 100644 --- a/includes/externalstore/ExternalStoreDB.php +++ b/includes/externalstore/ExternalStoreDB.php @@ -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 ) { diff --git a/includes/filebackend/filejournal/DBFileJournal.php b/includes/filebackend/filejournal/DBFileJournal.php index 4f64f0222f..0ade6164f2 100644 --- a/includes/filebackend/filejournal/DBFileJournal.php +++ b/includes/filebackend/filejournal/DBFileJournal.php @@ -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() { diff --git a/includes/filebackend/lockmanager/DBLockManager.php b/includes/filebackend/lockmanager/DBLockManager.php index b81cf3e497..9d4f0090d4 100644 --- a/includes/filebackend/lockmanager/DBLockManager.php +++ b/includes/filebackend/lockmanager/DBLockManager.php @@ -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;" ); } diff --git a/includes/filerepo/ForeignDBRepo.php b/includes/filerepo/ForeignDBRepo.php index dfdb37537c..f3a560b4db 100644 --- a/includes/filerepo/ForeignDBRepo.php +++ b/includes/filerepo/ForeignDBRepo.php @@ -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(); diff --git a/includes/filerepo/ForeignDBViaLBRepo.php b/includes/filerepo/ForeignDBViaLBRepo.php index f49b716fec..357f0b92f8 100644 --- a/includes/filerepo/ForeignDBViaLBRepo.php +++ b/includes/filerepo/ForeignDBViaLBRepo.php @@ -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 ); diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 130436293a..7ce731df38 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -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 ); } diff --git a/includes/libs/ObjectFactory.php b/includes/libs/ObjectFactory.php index 1cb544b8b8..0b9aa7ca60 100644 --- a/includes/libs/ObjectFactory.php +++ b/includes/libs/ObjectFactory.php @@ -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. * diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index 91189c8145..f634df1244 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -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 ) { diff --git a/includes/pager/IndexPager.php b/includes/pager/IndexPager.php index 7a5952f167..f0e7f3e809 100644 --- a/includes/pager/IndexPager.php +++ b/includes/pager/IndexPager.php @@ -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; diff --git a/includes/utils/BatchRowIterator.php b/includes/utils/BatchRowIterator.php index 59350e6fe9..07cb2bcd0e 100644 --- a/includes/utils/BatchRowIterator.php +++ b/includes/utils/BatchRowIterator.php @@ -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 diff --git a/includes/utils/BatchRowWriter.php b/includes/utils/BatchRowWriter.php index 377ed852d5..13cab5bd2b 100644 --- a/includes/utils/BatchRowWriter.php +++ b/includes/utils/BatchRowWriter.php @@ -22,7 +22,7 @@ */ class BatchRowWriter { /** - * @var DatabaseBase $db The database to write to + * @var IDatabase $db The database to write to */ protected $db; -- 2.20.1