X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FrebuildLocalisationCache.php;h=8a519e7178f8b449e07a41a96ce93491cd753f44;hb=03d2f3006048bc404b40b02838bd9fb9b563cced;hp=48602de0f46c63b2f6fef17b33920e4a6f53ebe8;hpb=3a2853e218acb586a00f2e59638de4176aee287f;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/rebuildLocalisationCache.php b/maintenance/rebuildLocalisationCache.php index 48602de0f4..8a519e7178 100644 --- a/maintenance/rebuildLocalisationCache.php +++ b/maintenance/rebuildLocalisationCache.php @@ -29,6 +29,10 @@ * @ingroup Maintenance */ +use MediaWiki\Config\ServiceOptions; +use MediaWiki\Logger\LoggerFactory; +use MediaWiki\MediaWikiServices; + require_once __DIR__ . '/Maintenance.php'; /** @@ -58,7 +62,7 @@ class RebuildLocalisationCache extends Maintenance { } public function execute() { - global $wgLocalisationCacheConf; + global $wgLocalisationCacheConf, $wgCacheDirectory; $force = $this->hasOption( 'force' ); $threads = $this->getOption( 'threads', 1 ); @@ -77,13 +81,25 @@ class RebuildLocalisationCache extends Maintenance { $conf = $wgLocalisationCacheConf; $conf['manualRecache'] = false; // Allow fallbacks to create CDB files - if ( $force ) { - $conf['forceRecache'] = true; - } + $conf['forceRecache'] = $force || !empty( $conf['forceRecache'] ); if ( $this->hasOption( 'outdir' ) ) { $conf['storeDirectory'] = $this->getOption( 'outdir' ); } - $lc = new LocalisationCacheBulkLoad( $conf ); + // XXX Copy-pasted from ServiceWiring.php. Do we need a factory for this one caller? + $lc = new LocalisationCacheBulkLoad( + new ServiceOptions( + LocalisationCache::$constructorOptions, + $conf, + MediaWikiServices::getInstance()->getMainConfig() + ), + LocalisationCache::getStoreFromConf( $conf, $wgCacheDirectory ), + LoggerFactory::getInstance( 'localisation' ), + [ function () { + MediaWikiServices::getInstance()->getResourceLoader() + ->getMessageBlobStore()->clear(); + } ], + MediaWikiServices::getInstance()->getLanguageNameUtils() + ); $allCodes = array_keys( Language::fetchLanguageNames( null, 'mwfile' ) ); if ( $this->hasOption( 'lang' ) ) { @@ -92,7 +108,7 @@ class RebuildLocalisationCache extends Maintenance { explode( ',', $this->getOption( 'lang' ) ) ); # Bailed out if nothing is left if ( count( $codes ) == 0 ) { - $this->error( 'None of the languages specified exists.', 1 ); + $this->fatalError( 'None of the languages specified exists.' ); } } else { # By default get all languages @@ -177,5 +193,5 @@ class RebuildLocalisationCache extends Maintenance { } } -$maintClass = "RebuildLocalisationCache"; +$maintClass = RebuildLocalisationCache::class; require_once RUN_MAINTENANCE_IF_MAIN;