X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FServiceWiring.php;h=7bdd7c8af106b5372cd6d93f2cb58fb213072e49;hb=e4468a1d6b6;hp=0b4ce4aa3a688f279709e870cf8a4cb1cebaa8ea;hpb=90d6f495bd099d58a3f9fb2ce97f4957f161255f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 0b4ce4aa3a..7bdd7c8af1 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -39,10 +39,12 @@ use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface; use MediaWiki\Auth\AuthManager; +use MediaWiki\BadFileLookup; use MediaWiki\Block\BlockManager; use MediaWiki\Block\BlockRestrictionStore; use MediaWiki\Config\ConfigRepository; use MediaWiki\Config\ServiceOptions; +use MediaWiki\FileBackend\FSFile\TempFSFileFactory; use MediaWiki\Http\HttpRequestFactory; use MediaWiki\Interwiki\ClassicInterwikiLookup; use MediaWiki\Interwiki\InterwikiLookup; @@ -76,6 +78,17 @@ return [ ); }, + 'BadFileLookup' => function ( MediaWikiServices $services ) : BadFileLookup { + return new BadFileLookup( + function () { + return wfMessage( 'bad_image_list' )->inContentLanguage()->plain(); + }, + $services->getLocalServerObjectCache(), + $services->getRepoGroup(), + $services->getTitleParser() + ); + }, + 'BlobStore' => function ( MediaWikiServices $services ) : BlobStore { return $services->getService( '_SqlBlobStore' ); }, @@ -98,7 +111,8 @@ return [ BlockManager::$constructorOptions, $services->getMainConfig() ), $context->getUser(), - $context->getRequest() + $context->getRequest(), + $services->getPermissionManager() ); }, @@ -267,6 +281,55 @@ return [ ); }, + 'LocalisationCache' => function ( MediaWikiServices $services ) : LocalisationCache { + $conf = $services->getMainConfig()->get( 'LocalisationCacheConf' ); + + $logger = LoggerFactory::getInstance( 'localisation' ); + + // Figure out what class to use for the LCStore + $storeArg = []; + $storeArg['directory'] = + $conf['storeDirectory'] ?? $services->getMainConfig()->get( 'CacheDirectory' ); + + if ( !empty( $conf['storeClass'] ) ) { + $storeClass = $conf['storeClass']; + } elseif ( $conf['store'] === 'files' || $conf['store'] === 'file' || + ( $conf['store'] === 'detect' && $storeArg['directory'] ) + ) { + $storeClass = LCStoreCDB::class; + } elseif ( $conf['store'] === 'db' || $conf['store'] === 'detect' ) { + $storeClass = LCStoreDB::class; + $storeArg['server'] = $conf['storeServer'] ?? []; + } elseif ( $conf['store'] === 'array' ) { + $storeClass = LCStoreStaticArray::class; + } else { + throw new MWException( + 'Please set $wgLocalisationCacheConf[\'store\'] to something sensible.' + ); + } + $logger->debug( "LocalisationCache: using store $storeClass" ); + + return new $conf['class']( + new ServiceOptions( + LocalisationCache::$constructorOptions, + // Two of the options are stored in $wgLocalisationCacheConf + $conf, + // In case someone set that config variable and didn't reset all keys, set defaults. + [ + 'forceRecache' => false, + 'manualRecache' => false, + ], + // Some other options come from config itself + $services->getMainConfig() + ), + new $storeClass( $storeArg ), + $logger, + [ function () use ( $services ) { + $services->getResourceLoader()->getMessageBlobStore()->clear(); + } ] + ); + }, + 'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff { $config = $services->getMainConfig(); $cacheId = \ObjectCache::detectLocalServerCache(); @@ -496,17 +559,12 @@ return [ }, 'PermissionManager' => function ( MediaWikiServices $services ) : PermissionManager { - $config = $services->getMainConfig(); return new PermissionManager( + new ServiceOptions( + PermissionManager::$constructorOptions, $services->getMainConfig() + ), $services->getSpecialPageFactory(), $services->getRevisionLookup(), - $config->get( 'WhitelistRead' ), - $config->get( 'WhitelistReadRegexp' ), - $config->get( 'EmailConfirmToEdit' ), - $config->get( 'BlockDisablesLogin' ), - $config->get( 'GroupPermissions' ), - $config->get( 'RevokePermissions' ), - $config->get( 'AvailableRights' ), $services->getNamespaceInfo() ); }, @@ -715,6 +773,10 @@ return [ ); }, + 'TempFSFileFactory' => function ( MediaWikiServices $services ) : TempFSFileFactory { + return new TempFSFileFactory( $services->getMainConfig()->get( 'TmpDirectory' ) ); + }, + 'TitleFormatter' => function ( MediaWikiServices $services ) : TitleFormatter { return $services->getService( '_MediaWikiTitleCodec' ); },