X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FrebuildImages.php;h=c0de33412e0f562921191525d8b6f8bc0bcd77ab;hb=f35af6b719bd4b5c1119d5926daf69e8304e37d9;hp=a8fb9a3bd06e00689601ae881c2080f697bda78d;hpb=4be80912c8a2217344bddde64824f93d19d094db;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php index a8fb9a3bd0..c0de33412e 100644 --- a/maintenance/rebuildImages.php +++ b/maintenance/rebuildImages.php @@ -32,6 +32,7 @@ require_once __DIR__ . '/Maintenance.php'; +use MediaWiki\MediaWikiServices; use Wikimedia\Rdbms\IMaintainableDatabase; /** @@ -125,12 +126,14 @@ class ImageBuilder extends Maintenance { flush(); } - function buildTable( $table, $key, $fields, $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, $fields, [], __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 ); @@ -145,7 +148,7 @@ class ImageBuilder extends Maintenance { function buildImage() { $callback = [ $this, 'imageCallback' ]; - $this->buildTable( 'image', 'img_name', LocalFile::selectFields(), $callback ); + $this->buildTable( 'image', 'img_name', LocalFile::getQueryInfo(), $callback ); } function imageCallback( $row, $copy ) { @@ -157,7 +160,7 @@ class ImageBuilder extends Maintenance { } function buildOldImage() { - $this->buildTable( 'oldimage', 'oi_archive_name', OldLocalFile::selectFields(), + $this->buildTable( 'oldimage', 'oi_archive_name', OldLocalFile::getQueryInfo(), [ $this, 'oldimageCallback' ] ); } @@ -191,11 +194,10 @@ class ImageBuilder extends Maintenance { } function addMissingImage( $filename, $fullpath ) { - global $wgContLang; - $timestamp = $this->dbw->timestamp( $this->getRepo()->getFileTimestamp( $fullpath ) ); - $altname = $wgContLang->checkTitleEncoding( $filename ); + $altname = MediaWikiServices::getInstance()->getContentLanguage()-> + checkTitleEncoding( $filename ); if ( $altname != $filename ) { if ( $this->dryrun ) { $filename = $altname; @@ -231,5 +233,5 @@ class ImageBuilder extends Maintenance { } } -$maintClass = 'ImageBuilder'; +$maintClass = ImageBuilder::class; require_once RUN_MAINTENANCE_IF_MAIN;