X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fstorage%2ForphanStats.php;h=219b47c44407f2c9eaafca409882a9f6a684c129;hb=69892e932e012ab3a80e90072a33c26ef7e6e052;hp=21f50f5cb5d0df691bfe2a1636431fcc67e9898a;hpb=0fd1a6b62b31be3abd51ca89c98897c8f5b1fd75;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/storage/orphanStats.php b/maintenance/storage/orphanStats.php index 21f50f5cb5..219b47c444 100644 --- a/maintenance/storage/orphanStats.php +++ b/maintenance/storage/orphanStats.php @@ -23,6 +23,8 @@ require_once __DIR__ . '/../Maintenance.php'; +use MediaWiki\MediaWikiServices; + /** * Maintenance script that shows some statistics on the blob_orphans table, * created with trackBlobs.php. @@ -36,22 +38,23 @@ class OrphanStats extends Maintenance { "Show some statistics on the blob_orphans table, created with trackBlobs.php" ); } - protected function &getDB( $cluster, $groups = array(), $wiki = false ) { - $lb = wfGetLBFactory()->getExternalLB( $cluster ); + protected function &getDB( $cluster, $groups = [], $wiki = false ) { + $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory(); + $lb = $lbFactory->getExternalLB( $cluster ); - return $lb->getConnection( DB_SLAVE ); + return $lb->getConnection( DB_REPLICA ); } public function execute() { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); if ( !$dbr->tableExists( 'blob_orphans' ) ) { - $this->error( "blob_orphans doesn't seem to exist, need to run trackBlobs.php first", true ); + $this->fatalError( "blob_orphans doesn't seem to exist, need to run trackBlobs.php first" ); } - $res = $dbr->select( 'blob_orphans', '*', false, __METHOD__ ); + $res = $dbr->select( 'blob_orphans', '*', '', __METHOD__ ); $num = 0; $totalSize = 0; - $hashes = array(); + $hashes = []; $maxSize = 0; foreach ( $res as $boRow ) { @@ -59,7 +62,7 @@ class OrphanStats extends Maintenance { $blobRow = $extDB->selectRow( 'blobs', '*', - array( 'blob_id' => $boRow->bo_blob_id ), + [ 'blob_id' => $boRow->bo_blob_id ], __METHOD__ ); @@ -80,5 +83,5 @@ class OrphanStats extends Maintenance { } } -$maintClass = "OrphanStats"; +$maintClass = OrphanStats::class; require_once RUN_MAINTENANCE_IF_MAIN;