X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FrebuildImages.php;h=a8fb9a3bd06e00689601ae881c2080f697bda78d;hb=253bb35735775ca100272320cb2c74107b1998c4;hp=6aa1f37a8c5582b8ace97661e18729cff900eadc;hpb=9964ca1a390c446397dcd466916ffed356cdc3c9;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php index 6aa1f37a8c..a8fb9a3bd0 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,12 @@ class ImageBuilder extends Maintenance { flush(); } - function buildTable( $table, $key, $callback ) { + function buildTable( $table, $key, $fields, $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( $table, $fields, [], __METHOD__ ); foreach ( $result as $row ) { $update = call_user_func( $callback, $row, null ); @@ -142,7 +145,7 @@ class ImageBuilder extends Maintenance { function buildImage() { $callback = [ $this, 'imageCallback' ]; - $this->buildTable( 'image', 'img_name', $callback ); + $this->buildTable( 'image', 'img_name', LocalFile::selectFields(), $callback ); } function imageCallback( $row, $copy ) { @@ -154,7 +157,8 @@ class ImageBuilder extends Maintenance { } function buildOldImage() { - $this->buildTable( 'oldimage', 'oi_archive_name', [ $this, 'oldimageCallback' ] ); + $this->buildTable( 'oldimage', 'oi_archive_name', OldLocalFile::selectFields(), + [ $this, 'oldimageCallback' ] ); } function oldimageCallback( $row, $copy ) {