X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=blobdiff_plain;f=maintenance%2FcleanupImages.php;h=69281810e648ea88aeb1d505888ca92b46a2f774;hb=decea359af57a0208b2f68cfbc0c1f88732d39b4;hp=c8f393d8412c21b991160e2efd58317401fa99ba;hpb=f9d7d3b8561dab3ddfd8798a77a5b72e03ac8c2b;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php index c8f393d841..69281810e6 100644 --- a/maintenance/cleanupImages.php +++ b/maintenance/cleanupImages.php @@ -25,6 +25,8 @@ * @ingroup Maintenance */ +use MediaWiki\MediaWikiServices; + require_once __DIR__ . '/cleanupTable.inc'; /** @@ -32,7 +34,7 @@ require_once __DIR__ . '/cleanupTable.inc'; * * @ingroup Maintenance */ -class ImageCleanup extends TableCleanup { +class CleanupImages extends TableCleanup { protected $defaultParams = [ 'table' => 'image', 'conds' => [], @@ -40,14 +42,15 @@ class ImageCleanup extends TableCleanup { 'callback' => 'processRow', ]; + /** @var LocalRepo|null */ + private $repo; + public function __construct() { parent::__construct(); $this->addDescription( 'Script to clean up broken, unparseable upload filenames' ); } protected function processRow( $row ) { - global $wgContLang; - $source = $row->img_name; if ( $source == '' ) { // Ye olde empty rows. Just kill them. @@ -64,11 +67,13 @@ class ImageCleanup extends TableCleanup { // We also have some HTML entities there $cleaned = Sanitizer::decodeCharReferences( $cleaned ); + $contLang = MediaWikiServices::getInstance()->getContentLanguage(); + // Some are old latin-1 - $cleaned = $wgContLang->checkTitleEncoding( $cleaned ); + $cleaned = $contLang->checkTitleEncoding( $cleaned ); // Many of remainder look like non-normalized unicode - $cleaned = $wgContLang->normalize( $cleaned ); + $cleaned = $contLang->normalize( $cleaned ); $title = Title::makeTitleSafe( NS_FILE, $cleaned ); @@ -109,8 +114,12 @@ class ImageCleanup extends TableCleanup { } } + /** + * @param string $name + * @return string + */ private function filePath( $name ) { - if ( !isset( $this->repo ) ) { + if ( $this->repo === null ) { $this->repo = RepoGroup::singleton()->getLocalRepo(); } @@ -146,7 +155,7 @@ class ImageCleanup extends TableCleanup { * if the target title exists in the image table, or if both the * original and target titles exist in the page table, append * increasing version numbers until the target title exists in - * neither. (See also bug 16916.) + * neither. (See also T18916.) */ $version = 0; $final = $new; @@ -220,5 +229,5 @@ class ImageCleanup extends TableCleanup { } } -$maintClass = "ImageCleanup"; +$maintClass = CleanupImages::class; require_once RUN_MAINTENANCE_IF_MAIN;