From: jenkins-bot Date: Sat, 3 Aug 2019 23:07:46 +0000 (+0000) Subject: Merge "changes: Avoid use of deprecated method Revision::userCanBitfield()" X-Git-Tag: 1.34.0-rc.0~795 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=69f78bb554ed8d950b3c79690d5a2a07e5c6d6c4;hp=40c88a6ac9f046a64c497f2955e8a3b874374a30 Merge "changes: Avoid use of deprecated method Revision::userCanBitfield()" --- diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index dbf6b2130b..a982de2a7d 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -340,16 +340,6 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { return $out; } - /** - * @private For internal use by SpecialJavaScriptTest - * @since 1.32 - * @return array - * @codeCoverageIgnore - */ - public function getBaseModulesInternal() { - return $this->getBaseModules(); - } - /** * Base modules implicitly available to all modules. * diff --git a/includes/specials/SpecialChangeContentModel.php b/includes/specials/SpecialChangeContentModel.php index d40b331d4f..184cdbb852 100644 --- a/includes/specials/SpecialChangeContentModel.php +++ b/includes/specials/SpecialChangeContentModel.php @@ -107,7 +107,7 @@ class SpecialChangeContentModel extends FormSpecialPage { $fields['pagetitle']['readonly'] = true; $fields += [ 'currentmodel' => [ - 'type' => 'info', + 'type' => 'text', 'name' => 'currentcontentmodel', 'default' => $this->title->getContentModel(), 'label-message' => 'changecontentmodel-current-label', diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index b74ac40d49..c3644ee610 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -1366,28 +1366,34 @@ abstract class Maintenance { } /** - * Returns a database to be used by current maintenance script. It can be set by setDB(). - * If not set, wfGetDB() will be used. - * This function has the same parameters as wfGetDB() + * Returns a database to be used by current maintenance script. + * + * This uses the main LBFactory instance by default unless overriden via setDB(). + * + * This function has the same parameters as LoadBalancer::getConnection(). * * @param int $db DB index (DB_REPLICA/DB_MASTER) * @param string|string[] $groups default: empty array - * @param string|bool $wiki default: current wiki + * @param string|bool $dbDomain default: current wiki * @return IMaintainableDatabase */ - protected function getDB( $db, $groups = [], $wiki = false ) { + protected function getDB( $db, $groups = [], $dbDomain = false ) { if ( $this->mDb === null ) { - return wfGetDB( $db, $groups, $wiki ); + return MediaWikiServices::getInstance() + ->getDBLoadBalancerFactory() + ->getMainLB( $dbDomain ) + ->getMaintenanceConnectionRef( $db, $groups, $dbDomain ); } + return $this->mDb; } /** * Sets database object to be returned by getDB(). * - * @param IDatabase $db + * @param IMaintainableDatabase $db */ - public function setDB( IDatabase $db ) { + public function setDB( IMaintainableDatabase $db ) { $this->mDb = $db; } diff --git a/maintenance/includes/BackupDumper.php b/maintenance/includes/BackupDumper.php index df3b4a1805..08eade934f 100644 --- a/maintenance/includes/BackupDumper.php +++ b/maintenance/includes/BackupDumper.php @@ -30,7 +30,7 @@ require_once __DIR__ . '/../../includes/export/WikiExporter.php'; use MediaWiki\MediaWikiServices; use Wikimedia\Rdbms\LoadBalancer; -use Wikimedia\Rdbms\IDatabase; +use Wikimedia\Rdbms\IMaintainableDatabase; /** * @ingroup Dump @@ -68,7 +68,7 @@ abstract class BackupDumper extends Maintenance { /** * The dependency-injected database to use. * - * @var IDatabase|null + * @var IMaintainableDatabase|null * * @see self::setDB */ @@ -328,7 +328,7 @@ abstract class BackupDumper extends Maintenance { * @todo Fixme: the --server parameter is currently not respected, as it * doesn't seem terribly easy to ask the load balancer for a particular * connection by name. - * @return IDatabase + * @return IMaintainableDatabase */ function backupDb() { if ( $this->forcedDb !== null ) { @@ -337,7 +337,7 @@ abstract class BackupDumper extends Maintenance { $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); $this->lb = $lbFactory->newMainLB(); - $db = $this->lb->getConnection( DB_REPLICA, 'dump' ); + $db = $this->lb->getMaintenanceConnectionRef( DB_REPLICA, 'dump' ); // Discourage the server from disconnecting us if it takes a long time // to read out the big ol' batch query. @@ -350,10 +350,9 @@ abstract class BackupDumper extends Maintenance { * Force the dump to use the provided database connection for database * operations, wherever possible. * - * @param IDatabase|null $db (Optional) the database connection to use. If null, resort to - * use the globally provided ways to get database connections. + * @param IMaintainableDatabase $db The database connection to use */ - function setDB( IDatabase $db = null ) { + function setDB( IMaintainableDatabase $db ) { parent::setDB( $db ); $this->forcedDb = $db; } diff --git a/maintenance/includes/TextPassDumper.php b/maintenance/includes/TextPassDumper.php index f9b3951113..21b92c51c7 100644 --- a/maintenance/includes/TextPassDumper.php +++ b/maintenance/includes/TextPassDumper.php @@ -240,7 +240,7 @@ TEXT } try { - $this->db = $this->lb->getConnection( DB_REPLICA, 'dump' ); + $this->db = $this->lb->getMaintenanceConnectionRef( DB_REPLICA, 'dump' ); } catch ( Exception $e ) { throw new MWException( __METHOD__ . " rotating DB failed to obtain new database (" . $e->getMessage() . ")" ); diff --git a/maintenance/shell.php b/maintenance/shell.php index a67417fc09..f5ebc025ee 100644 --- a/maintenance/shell.php +++ b/maintenance/shell.php @@ -93,8 +93,8 @@ class MediaWikiShell extends Maintenance { } if ( $d > 1 ) { # Set DBO_DEBUG (equivalent of $wgDebugDumpSql) - wfGetDB( DB_MASTER )->setFlag( DBO_DEBUG ); - wfGetDB( DB_REPLICA )->setFlag( DBO_DEBUG ); + $this->getDB( DB_MASTER )->setFlag( DBO_DEBUG ); + $this->getDB( DB_REPLICA )->setFlag( DBO_DEBUG ); } } diff --git a/maintenance/sql.php b/maintenance/sql.php index 3b0607f5fc..21d8b2dd45 100644 --- a/maintenance/sql.php +++ b/maintenance/sql.php @@ -83,8 +83,7 @@ class MwSql extends Maintenance { $index = DB_MASTER; } - /** @var IDatabase $db DB handle for the appropriate cluster/wiki */ - $db = $lb->getConnection( $index, [], $wiki ); + $db = $lb->getMaintenanceConnectionRef( $index, [], $wiki ); if ( $replicaDB != '' && $db->getLBInfo( 'master' ) !== null ) { $this->fatalError( "The server selected ({$db->getServer()}) is not a replica DB." ); } diff --git a/maintenance/storage/orphanStats.php b/maintenance/storage/orphanStats.php index 3866be70d0..60f88ba698 100644 --- a/maintenance/storage/orphanStats.php +++ b/maintenance/storage/orphanStats.php @@ -42,7 +42,7 @@ class OrphanStats extends Maintenance { $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); $lb = $lbFactory->getExternalLB( $cluster ); - return $lb->getConnection( DB_REPLICA ); + return $lb->getMaintenanceConnectionRef( DB_REPLICA ); } public function execute() { diff --git a/maintenance/storage/recompressTracked.php b/maintenance/storage/recompressTracked.php index 6fd53ccd94..92b66792e7 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -22,10 +22,10 @@ * @ingroup Maintenance ExternalStorage */ +use Wikimedia\Rdbms\IMaintainableDatabase; use MediaWiki\Logger\LegacyLogger; use MediaWiki\MediaWikiServices; use MediaWiki\Shell\Shell; -use Wikimedia\Rdbms\IDatabase; $optionsWithArgs = RecompressTracked::getOptionsWithArgs(); require __DIR__ . '/../commandLine.inc'; @@ -275,6 +275,7 @@ class RecompressTracked { /** * Dispatch a command to the next available replica DB. * This may block until a replica DB finishes its work and becomes available. + * @param array ...$args */ function dispatch( ...$args ) { $pipes = $this->replicaPipes; @@ -647,13 +648,13 @@ class RecompressTracked { /** * Gets a DB master connection for the given external cluster name * @param string $cluster - * @return IDatabase + * @return IMaintainableDatabase */ function getExtDB( $cluster ) { $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); $lb = $lbFactory->getExternalLB( $cluster ); - return $lb->getConnection( DB_MASTER ); + return $lb->getMaintenanceConnectionRef( DB_MASTER ); } /** diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php index 385ae6a5a0..d9793b40bc 100644 --- a/maintenance/storage/trackBlobs.php +++ b/maintenance/storage/trackBlobs.php @@ -232,7 +232,7 @@ class TrackBlobs { $pos = $dbw->getMasterPos(); $dbr->masterPosWait( $pos, 100000 ); - $textClause = $this->getTextClause( $this->clusters ); + $textClause = $this->getTextClause(); $startId = 0; $endId = $dbr->selectField( 'text', 'MAX(old_id)', '', __METHOD__ ); $rowsInserted = 0; @@ -325,9 +325,9 @@ class TrackBlobs { $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); $lb = $lbFactory->getExternalLB( $cluster ); try { - $extDB = $lb->getConnection( DB_REPLICA ); + $extDB = $lb->getMaintenanceConnectionRef( DB_REPLICA ); } catch ( DBConnectionError $e ) { - if ( strpos( $e->error, 'Unknown database' ) !== false ) { + if ( strpos( $e->getMessage(), 'Unknown database' ) !== false ) { echo "No database on $cluster\n"; } else { echo "Error on $cluster: " . $e->getMessage() . "\n"; @@ -362,8 +362,8 @@ class TrackBlobs { foreach ( $res as $row ) { gmp_setbit( $actualBlobs, $row->blob_id ); + $startId = $row->blob_id; } - $startId = $row->blob_id; ++$batchesDone; if ( $batchesDone >= $this->reportingInterval ) {