use CLDRPluralRuleParser\Evaluator;
use CLDRPluralRuleParser\Error as CLDRPluralRuleError;
+use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
/**
*/
private $store;
+ /**
+ * @var \Psr\Log\LoggerInterface
+ */
+ private $logger;
+
/**
* A 2-d associative array, code/key, where presence indicates that the item
* is loaded. Value arbitrary.
*/
public static $allKeys = [
'fallback', 'namespaceNames', 'bookstoreList',
- 'magicWords', 'messages', 'rtl', 'capitalizeAllNouns', 'digitTransformTable',
- 'separatorTransformTable', 'minimumGroupingDigits',
- 'fallback8bitEncoding', 'linkPrefixExtension',
- 'linkTrail', 'linkPrefixCharset', 'namespaceAliases',
- 'dateFormats', 'datePreferences', 'datePreferenceMigrationMap',
- 'defaultDateFormat', 'extraUserToggles', 'specialPageAliases',
- 'imageFiles', 'preloadedMessages', 'namespaceGenderAliases',
- 'digitGroupingPattern', 'pluralRules', 'pluralRuleTypes', 'compiledPluralRules',
+ 'magicWords', 'messages', 'rtl', 'capitalizeAllNouns',
+ 'digitTransformTable', 'separatorTransformTable',
+ 'minimumGroupingDigits', 'fallback8bitEncoding',
+ 'linkPrefixExtension', 'linkTrail', 'linkPrefixCharset',
+ 'namespaceAliases', 'dateFormats', 'datePreferences',
+ 'datePreferenceMigrationMap', 'defaultDateFormat',
+ 'specialPageAliases', 'imageFiles', 'preloadedMessages',
+ 'namespaceGenderAliases', 'digitGroupingPattern', 'pluralRules',
+ 'pluralRuleTypes', 'compiledPluralRules',
];
/**
/**
* Keys for items which are a numbered array.
*/
- public static $mergeableListKeys = [ 'extraUserToggles' ];
+ public static $mergeableListKeys = [];
/**
* Keys for items which contain an array of arrays of equivalent aliases
global $wgCacheDirectory;
$this->conf = $conf;
+ $this->logger = LoggerFactory::getInstance( 'localisation' );
$directory = !empty( $conf['storeDirectory'] ) ? $conf['storeDirectory'] : $wgCacheDirectory;
$storeArg = [];
);
}
}
-
- wfDebugLog( 'caches', static::class . ": using store $storeClass" );
+ $this->logger->debug( static::class . ": using store $storeClass" );
$this->store = new $storeClass( $storeArg );
foreach ( [ 'manualRecache', 'forceRecache' ] as $var ) {
*/
public function isExpired( $code ) {
if ( $this->forceRecache && !isset( $this->recachedLangs[$code] ) ) {
- wfDebug( __METHOD__ . "($code): forced reload\n" );
+ $this->logger->debug( __METHOD__ . "($code): forced reload\n" );
return true;
}
$preload = $this->store->get( $code, 'preload' );
// Different keys may expire separately for some stores
if ( $deps === null || $keys === null || $preload === null ) {
- wfDebug( __METHOD__ . "($code): cache missing, need to make one\n" );
+ $this->logger->debug( __METHOD__ . "($code): cache missing, need to make one\n" );
return true;
}
// anymore (e.g. uninstalled extensions)
// When this happens, always expire the cache
if ( !$dep instanceof CacheDependency || $dep->isExpired() ) {
- wfDebug( __METHOD__ . "($code): cache for $code expired due to " .
+ $this->logger->debug( __METHOD__ . "($code): cache for $code expired due to " .
get_class( $dep ) . "\n" );
return true;
try {
$compiledRules = Evaluator::compile( $rules );
} catch ( CLDRPluralRuleError $e ) {
- wfDebugLog( 'l10n', $e->getMessage() );
+ $this->logger->debug( $e->getMessage() );
return [];
}
# Load the primary localisation from the source file
$data = $this->readSourceFilesAndRegisterDeps( $code, $deps );
if ( $data === false ) {
- wfDebug( __METHOD__ . ": no localisation file for $code, using fallback to en\n" );
+ $this->logger->debug( __METHOD__ . ": no localisation file for $code, using fallback to en\n" );
$coreData['fallback'] = 'en';
} else {
- wfDebug( __METHOD__ . ": got localisation for $code from source\n" );
+ $this->logger->debug( __METHOD__ . ": got localisation for $code from source\n" );
# Merge primary localisation
foreach ( $data as $key => $value ) {
$allData['list'][$key] = array_keys( $allData[$key] );
}
# Run hooks
- $purgeBlobs = true;
- Hooks::run( 'LocalisationCacheRecache', [ $this, $code, &$allData, &$purgeBlobs ] );
+ $unused = true; // Used to be $purgeBlobs, removed in 1.34
+ Hooks::run( 'LocalisationCacheRecache', [ $this, $code, &$allData, &$unused ] );
if ( is_null( $allData['namespaceNames'] ) ) {
throw new MWException( __METHOD__ . ': Localisation data failed sanity check! ' .
# Clear out the MessageBlobStore
# HACK: If using a null (i.e. disabled) storage backend, we
# can't write to the MessageBlobStore either
- if ( $purgeBlobs && !$this->store instanceof LCStoreNull ) {
+ if ( !$this->store instanceof LCStoreNull ) {
$blobStore = MediaWikiServices::getInstance()->getResourceLoader()->getMessageBlobStore();
$blobStore->clear();
}