X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FrebuildImages.php;h=8fceedb28cbff3cc4359641d22ab65f42efa1a8c;hb=5d743b03814d2e36abc45f0d9e048d6390b01084;hp=6aa1f37a8c5582b8ace97661e18729cff900eadc;hpb=4cb9c1a24bde6e29c5e8f05c7cd1de54ffdd342a;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php index 6aa1f37a8c..8fceedb28c 100644 --- a/maintenance/rebuildImages.php +++ b/maintenance/rebuildImages.php @@ -32,6 +32,8 @@ require_once __DIR__ . '/Maintenance.php'; +use Wikimedia\Rdbms\IMaintainableDatabase; + /** * Maintenance script to update image metadata records. * @@ -40,7 +42,7 @@ require_once __DIR__ . '/Maintenance.php'; class ImageBuilder extends Maintenance { /** - * @var Database + * @var IMaintainableDatabase */ protected $dbw; @@ -61,7 +63,8 @@ class ImageBuilder extends Maintenance { $this->dbw = $this->getDB( DB_MASTER ); $this->dryrun = $this->hasOption( 'dry-run' ); if ( $this->dryrun ) { - $GLOBALS['wgReadOnly'] = 'Dry run mode, image upgrades are suppressed'; + MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode() + ->setReason( 'Dry run mode, image upgrades are suppressed' ); } if ( $this->hasOption( 'missing' ) ) { @@ -122,12 +125,14 @@ class ImageBuilder extends Maintenance { flush(); } - function buildTable( $table, $key, $callback ) { + function buildTable( $table, $key, $queryInfo, $callback ) { $count = $this->dbw->selectField( $table, 'count(*)', '', __METHOD__ ); $this->init( $count, $table ); $this->output( "Processing $table...\n" ); - $result = $this->getDB( DB_REPLICA )->select( $table, '*', [], __METHOD__ ); + $result = $this->getDB( DB_REPLICA )->select( + $queryInfo['tables'], $queryInfo['fields'], [], __METHOD__, [], $queryInfo['joins'] + ); foreach ( $result as $row ) { $update = call_user_func( $callback, $row, null ); @@ -142,7 +147,7 @@ class ImageBuilder extends Maintenance { function buildImage() { $callback = [ $this, 'imageCallback' ]; - $this->buildTable( 'image', 'img_name', $callback ); + $this->buildTable( 'image', 'img_name', LocalFile::getQueryInfo(), $callback ); } function imageCallback( $row, $copy ) { @@ -154,7 +159,8 @@ class ImageBuilder extends Maintenance { } function buildOldImage() { - $this->buildTable( 'oldimage', 'oi_archive_name', [ $this, 'oldimageCallback' ] ); + $this->buildTable( 'oldimage', 'oi_archive_name', OldLocalFile::getQueryInfo(), + [ $this, 'oldimageCallback' ] ); } function oldimageCallback( $row, $copy ) {