MediaWiki  master
ServiceWiring.php
Go to the documentation of this file.
1 <?php
47 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
119 use Wikimedia\ObjectFactory;
120 use Wikimedia\Services\RecursiveServiceDependencyException;
122 
123 return [
124  'ActorMigration' => function ( MediaWikiServices $services ) : ActorMigration {
125  return new ActorMigration( SCHEMA_COMPAT_NEW );
126  },
127 
128  'AuthManager' => function ( MediaWikiServices $services ) : AuthManager {
129  $authManager = new AuthManager(
130  RequestContext::getMain()->getRequest(),
131  $services->getMainConfig(),
132  $services->getObjectFactory(),
133  $services->getPermissionManager(),
134  $services->getHookContainer()
135  );
136  $authManager->setLogger( LoggerFactory::getInstance( 'authentication' ) );
137  return $authManager;
138  },
139 
140  'BadFileLookup' => function ( MediaWikiServices $services ) : BadFileLookup {
141  return new BadFileLookup(
142  function () {
143  return wfMessage( 'bad_image_list' )->inContentLanguage()->plain();
144  },
145  $services->getLocalServerObjectCache(),
146  $services->getRepoGroup(),
147  $services->getTitleParser(),
148  $services->getHookContainer()
149  );
150  },
151 
152  'BlobStore' => function ( MediaWikiServices $services ) : BlobStore {
153  return $services->getService( '_SqlBlobStore' );
154  },
155 
156  'BlobStoreFactory' => function ( MediaWikiServices $services ) : BlobStoreFactory {
157  return new BlobStoreFactory(
158  $services->getDBLoadBalancerFactory(),
159  $services->getExternalStoreAccess(),
160  $services->getMainWANObjectCache(),
161  new ServiceOptions( BlobStoreFactory::CONSTRUCTOR_OPTIONS,
162  $services->getMainConfig() )
163  );
164  },
165 
166  'BlockErrorFormatter' => function ( MediaWikiServices $services ) : BlockErrorFormatter {
167  return new BlockErrorFormatter();
168  },
169 
170  'BlockManager' => function ( MediaWikiServices $services ) : BlockManager {
171  return new BlockManager(
172  new ServiceOptions(
173  BlockManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
174  ),
175  $services->getPermissionManager(),
176  LoggerFactory::getInstance( 'BlockManager' ),
177  $services->getHookContainer()
178  );
179  },
180 
181  'BlockPermissionCheckerFactory' => function (
182  MediaWikiServices $services
185  $services->getPermissionManager()
186  );
187  },
188 
189  'BlockRestrictionStore' => function ( MediaWikiServices $services ) : BlockRestrictionStore {
190  return new BlockRestrictionStore(
191  $services->getDBLoadBalancer()
192  );
193  },
194 
195  'ChangeTagDefStore' => function ( MediaWikiServices $services ) : NameTableStore {
196  return $services->getNameTableStoreFactory()->getChangeTagDef();
197  },
198 
199  'CommentStore' => function ( MediaWikiServices $services ) : CommentStore {
200  return new CommentStore(
201  $services->getContentLanguage(),
203  );
204  },
205 
206  'ConfigFactory' => function ( MediaWikiServices $services ) : ConfigFactory {
207  // Use the bootstrap config to initialize the ConfigFactory.
208  $registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' );
209  $factory = new ConfigFactory();
210 
211  foreach ( $registry as $name => $callback ) {
212  $factory->register( $name, $callback );
213  }
214  return $factory;
215  },
216 
217  'ConfigRepository' => function ( MediaWikiServices $services ) : ConfigRepository {
218  return new ConfigRepository( $services->getConfigFactory() );
219  },
220 
221  'ConfiguredReadOnlyMode' => function ( MediaWikiServices $services ) : ConfiguredReadOnlyMode {
222  $config = $services->getMainConfig();
223  return new ConfiguredReadOnlyMode(
224  $config->get( 'ReadOnly' ),
225  $config->get( 'ReadOnlyFile' )
226  );
227  },
228 
229  'ContentHandlerFactory' => function ( MediaWikiServices $services ) : IContentHandlerFactory {
230  $contentHandlerConfig = $services->getMainConfig()->get( 'ContentHandlers' );
231 
232  return new ContentHandlerFactory(
233  $contentHandlerConfig,
234  $services->getObjectFactory(),
235  $services->getHookContainer(),
236  LoggerFactory::getInstance( 'ContentHandler' )
237  );
238  },
239 
240  'ContentLanguage' => function ( MediaWikiServices $services ) : Language {
241  return $services->getLanguageFactory()->getLanguage(
242  $services->getMainConfig()->get( 'LanguageCode' ) );
243  },
244 
245  'ContentModelChangeFactory' => function ( MediaWikiServices $services ) : ContentModelChangeFactory {
246  return $services->getService( '_PageCommandFactory' );
247  },
248 
249  'ContentModelStore' => function ( MediaWikiServices $services ) : NameTableStore {
250  return $services->getNameTableStoreFactory()->getContentModels();
251  },
252 
253  'ContributionsLookup' => function ( MediaWikiServices $services ) : ContributionsLookup {
254  return new ContributionsLookup( $services->getRevisionStore() );
255  },
256 
257  'CryptHKDF' => function ( MediaWikiServices $services ) : CryptHKDF {
258  $config = $services->getMainConfig();
259 
260  $secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
261  if ( !$secret ) {
262  throw new RuntimeException( "Cannot use MWCryptHKDF without a secret." );
263  }
264 
265  // In HKDF, the context can be known to the attacker, but this will
266  // keep simultaneous runs from producing the same output.
267  $context = [ microtime(), getmypid(), gethostname() ];
268 
269  // Setup salt cache. Use APC, or fallback to the main cache if it isn't setup
270  $cache = $services->getLocalServerObjectCache();
271  if ( $cache instanceof EmptyBagOStuff ) {
273  }
274 
275  return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm' ), $cache, $context );
276  },
277 
278  'DatabaseBlockStore' => function ( MediaWikiServices $services ) : DatabaseBlockStore {
279  return new DatabaseBlockStore(
280  new ServiceOptions(
281  DatabaseBlockStore::CONSTRUCTOR_OPTIONS,
282  $services->getMainConfig()
283  ),
284  LoggerFactory::getInstance( 'DatabaseBlockStore' ),
285  $services->getActorMigration(),
286  $services->getBlockRestrictionStore(),
287  $services->getCommentStore(),
288  $services->getHookContainer(),
289  $services->getDBLoadBalancer(),
290  $services->getReadOnlyMode()
291  );
292  },
293 
294  'DateFormatterFactory' => function ( MediaWikiServices $services ) : DateFormatterFactory {
295  return new DateFormatterFactory();
296  },
297 
298  'DBLoadBalancer' => function ( MediaWikiServices $services ) : Wikimedia\Rdbms\ILoadBalancer {
299  // just return the default LB from the DBLoadBalancerFactory service
300  return $services->getDBLoadBalancerFactory()->getMainLB();
301  },
302 
303  'DBLoadBalancerFactory' =>
304  function ( MediaWikiServices $services ) : Wikimedia\Rdbms\LBFactory {
305  $mainConfig = $services->getMainConfig();
306 
307  try {
308  $stash = $services->getMainObjectStash();
309  } catch ( RecursiveServiceDependencyException $e ) {
310  $stash = new EmptyBagOStuff(); // T141804: handle cases like CACHE_DB
311  }
312 
313  if ( $stash instanceof EmptyBagOStuff ) {
314  // Use process cache if the main stash is disabled or there was recursion
315  $stash = new HashBagOStuff( [ 'maxKeys' => 100 ] );
316  }
317 
318  try {
319  $wanCache = $services->getMainWANObjectCache();
320  } catch ( RecursiveServiceDependencyException $e ) {
321  $wanCache = WANObjectCache::newEmpty(); // T141804: handle cases like CACHE_DB
322  }
323 
325  $mainConfig->get( 'LBFactoryConf' ),
326  new ServiceOptions( MWLBFactory::APPLY_DEFAULT_CONFIG_OPTIONS, $mainConfig ),
327  $services->getConfiguredReadOnlyMode(),
328  $services->getLocalServerObjectCache(),
329  $stash,
330  $wanCache
331  );
332 
333  $class = MWLBFactory::getLBFactoryClass( $lbConf );
334  $instance = new $class( $lbConf );
335 
336  MWLBFactory::setDomainAliases( $instance );
337 
338  return $instance;
339  },
340 
341  'Emailer' => function ( MediaWikiServices $services ) : IEmailer {
342  return new Emailer();
343  },
344 
345  'EventRelayerGroup' => function ( MediaWikiServices $services ) : EventRelayerGroup {
346  return new EventRelayerGroup( $services->getMainConfig()->get( 'EventRelayerConfig' ) );
347  },
348 
349  'ExternalStoreAccess' => function ( MediaWikiServices $services ) : ExternalStoreAccess {
350  return new ExternalStoreAccess(
351  $services->getExternalStoreFactory(),
352  LoggerFactory::getInstance( 'ExternalStore' )
353  );
354  },
355 
356  'ExternalStoreFactory' => function ( MediaWikiServices $services ) : ExternalStoreFactory {
357  $config = $services->getMainConfig();
358  $writeStores = $config->get( 'DefaultExternalStore' );
359 
360  return new ExternalStoreFactory(
361  $config->get( 'ExternalStores' ),
362  ( $writeStores !== false ) ? (array)$writeStores : [],
363  $services->getDBLoadBalancer()->getLocalDomainID(),
364  LoggerFactory::getInstance( 'ExternalStore' )
365  );
366  },
367 
368  'FileBackendGroup' => function ( MediaWikiServices $services ) : FileBackendGroup {
369  $mainConfig = $services->getMainConfig();
370 
372  $fallbackWikiId = WikiMap::getWikiIdFromDbDomain( $ld );
373  // If the local wiki ID and local domain ID do not match, probably due to a non-default
374  // schema, issue a warning. A non-default schema indicates that it might be used to
375  // disambiguate different wikis.
376  $legacyDomainId = strlen( $ld->getTablePrefix() )
377  ? "{$ld->getDatabase()}-{$ld->getTablePrefix()}"
378  : $ld->getDatabase();
379  if ( $ld->getSchema() !== null && $legacyDomainId !== $fallbackWikiId ) {
380  wfWarn(
381  "Legacy default 'domainId' is '$legacyDomainId' but wiki ID is '$fallbackWikiId'."
382  );
383  }
384 
385  $cache = $services->getLocalServerObjectCache();
386  if ( $cache instanceof EmptyBagOStuff ) {
387  $cache = new HashBagOStuff();
388  }
389 
390  return new FileBackendGroup(
392  [ 'fallbackWikiId' => $fallbackWikiId ] ),
393  $services->getConfiguredReadOnlyMode(),
394  $cache,
395  $services->getMainWANObjectCache(),
396  $services->getMimeAnalyzer(),
397  $services->getLockManagerGroupFactory(),
398  $services->getTempFSFileFactory(),
399  $services->getObjectFactory()
400  );
401  },
402 
403  'GenderCache' => function ( MediaWikiServices $services ) : GenderCache {
404  $nsInfo = $services->getNamespaceInfo();
405  // Database layer may be disabled, so processing without database connection
406  $dbLoadBalancer = $services->isServiceDisabled( 'DBLoadBalancer' )
407  ? null
408  : $services->getDBLoadBalancer();
409  return new GenderCache( $nsInfo, $dbLoadBalancer, $services->get( '_DefaultOptionsLookup' ) );
410  },
411 
412  'GlobalIdGenerator' => function ( MediaWikiServices $services ) : GlobalIdGenerator {
413  $mainConfig = $services->getMainConfig();
414 
415  return new GlobalIdGenerator(
416  $mainConfig->get( 'TmpDirectory' ),
417  // Ignore APC-like caches in CLI mode since there is no meaningful persistence.
418  // This avoids having counters restart with each script run. The ID generator
419  // will fallback to using the disk in those cases.
420  $mainConfig->get( 'CommandLineMode' )
421  ? new EmptyBagOStuff()
422  : $services->getLocalServerObjectCache(),
423  function ( $command ) {
424  return wfShellExec( $command );
425  }
426  );
427  },
428 
429  'HookContainer' => function ( MediaWikiServices $services ) : HookContainer {
430  $extRegistry = ExtensionRegistry::getInstance();
431  $extDeprecatedHooks = $extRegistry->getAttribute( 'DeprecatedHooks' );
432  $deprecatedHooks = new DeprecatedHooks( $extDeprecatedHooks );
433  $hookRegistry = new GlobalHookRegistry( $extRegistry, $deprecatedHooks );
434  return new HookContainer(
435  $hookRegistry,
436  $services->getObjectFactory()
437  );
438  },
439 
440  'HtmlCacheUpdater' => function ( MediaWikiServices $services ) : HtmlCacheUpdater {
441  $config = $services->getMainConfig();
442 
443  return new HtmlCacheUpdater(
444  $services->getHookContainer(),
445  $config->get( 'CdnReboundPurgeDelay' ),
446  $config->get( 'UseFileCache' ),
447  $config->get( 'CdnMaxAge' )
448  );
449  },
450 
451  'HttpRequestFactory' =>
452  function ( MediaWikiServices $services ) : HttpRequestFactory {
453  return new HttpRequestFactory(
454  new ServiceOptions(
455  HttpRequestFactory::CONSTRUCTOR_OPTIONS,
456  $services->getMainConfig()
457  ),
458  LoggerFactory::getInstance( 'http' )
459  );
460  },
461 
462  'InterwikiLookup' => function ( MediaWikiServices $services ) : InterwikiLookup {
463  $config = $services->getMainConfig();
464  return new ClassicInterwikiLookup(
465  $services->getContentLanguage(),
466  $services->getMainWANObjectCache(),
467  $services->getHookContainer(),
468  $config->get( 'InterwikiExpiry' ),
469  $config->get( 'InterwikiCache' ),
470  $config->get( 'InterwikiScopes' ),
471  $config->get( 'InterwikiFallbackSite' )
472  );
473  },
474 
475  'JobRunner' => function ( MediaWikiServices $services ) : JobRunner {
476  return new JobRunner(
477  new ServiceOptions( JobRunner::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
478  $services->getDBLoadBalancerFactory(),
480  $services->getReadOnlyMode(),
481  $services->getLinkCache(),
482  $services->getStatsdDataFactory(),
483  LoggerFactory::getInstance( 'runJobs' )
484  );
485  },
486 
487  'LanguageConverterFactory' => function ( MediaWikiServices $services ) : LanguageConverterFactory {
488  $usePigLatinVariant = $services->getMainConfig()->get( 'UsePigLatinVariant' );
489  return new LanguageConverterFactory( $usePigLatinVariant, function () use ( $services ) {
490  return $services->getContentLanguage();
491  } );
492  },
493 
494  'LanguageFactory' => function ( MediaWikiServices $services ) : LanguageFactory {
495  return new LanguageFactory(
496  new ServiceOptions( LanguageFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
497  $services->getLocalisationCache(),
498  $services->getLanguageNameUtils(),
499  $services->getLanguageFallback(),
500  $services->getLanguageConverterFactory(),
501  $services->getHookContainer()
502  );
503  },
504 
505  'LanguageFallback' => function ( MediaWikiServices $services ) : LanguageFallback {
506  return new LanguageFallback(
507  $services->getMainConfig()->get( 'LanguageCode' ),
508  $services->getLocalisationCache(),
509  $services->getLanguageNameUtils()
510  );
511  },
512 
513  'LanguageNameUtils' => function ( MediaWikiServices $services ) : LanguageNameUtils {
514  return new LanguageNameUtils(
515  new ServiceOptions(
516  LanguageNameUtils::CONSTRUCTOR_OPTIONS,
517  $services->getMainConfig()
518  ),
519  $services->getHookContainer()
520  );
521  },
522 
523  'LinkBatchFactory' => function ( MediaWikiServices $services ) : LinkBatchFactory {
524  return new LinkBatchFactory(
525  $services->getLinkCache(),
526  $services->getTitleFormatter(),
527  $services->getContentLanguage(),
528  $services->getGenderCache(),
529  $services->getDBLoadBalancer()
530  );
531  },
532 
533  'LinkCache' => function ( MediaWikiServices $services ) : LinkCache {
534  return new LinkCache(
535  $services->getTitleFormatter(),
536  $services->getMainWANObjectCache(),
537  $services->getNamespaceInfo()
538  );
539  },
540 
541  'LinkRenderer' => function ( MediaWikiServices $services ) : LinkRenderer {
542  if ( defined( 'MW_NO_SESSION' ) ) {
543  return $services->getLinkRendererFactory()->create();
544  } else {
545  // Normally information from the current request would not be passed in here;
546  // this is an exception. (See also the class documentation.)
547  return $services->getLinkRendererFactory()->createForUser(
548  RequestContext::getMain()->getUser()
549  );
550  }
551  },
552 
553  'LinkRendererFactory' => function ( MediaWikiServices $services ) : LinkRendererFactory {
554  return new LinkRendererFactory(
555  $services->getTitleFormatter(),
556  $services->getLinkCache(),
557  $services->getNamespaceInfo(),
558  $services->getSpecialPageFactory(),
559  $services->getHookContainer()
560  );
561  },
562 
563  'LocalisationCache' => function ( MediaWikiServices $services ) : LocalisationCache {
564  $conf = $services->getMainConfig()->get( 'LocalisationCacheConf' );
565 
566  $logger = LoggerFactory::getInstance( 'localisation' );
567 
569  $conf, $services->getMainConfig()->get( 'CacheDirectory' ) );
570  $logger->debug( 'LocalisationCache using store ' . get_class( $store ) );
571 
572  return new $conf['class'](
573  new ServiceOptions(
574  LocalisationCache::CONSTRUCTOR_OPTIONS,
575  // Two of the options are stored in $wgLocalisationCacheConf
576  $conf,
577  // In case someone set that config variable and didn't reset all keys, set defaults.
578  [
579  'forceRecache' => false,
580  'manualRecache' => false,
581  ],
582  // Some other options come from config itself
583  $services->getMainConfig()
584  ),
585  $store,
586  $logger,
587  [ function () use ( $services ) {
588  // NOTE: Make sure we use the same cache object that is assigned in the
589  // constructor of the MessageBlobStore class used by ResourceLoader.
590  // T231866: Avoid circular dependency via ResourceLoader.
591  MessageBlobStore::clearGlobalCacheEntry( $services->getMainWANObjectCache() );
592  } ],
593  $services->getLanguageNameUtils(),
594  $services->getHookContainer()
595  );
596  },
597 
598  'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
600  },
601 
602  'LockManagerGroupFactory' => function ( MediaWikiServices $services ) : LockManagerGroupFactory {
603  return new LockManagerGroupFactory(
605  $services->getMainConfig()->get( 'LockManagers' ),
606  $services->getDBLoadBalancerFactory()
607  );
608  },
609 
610  'MagicWordFactory' => function ( MediaWikiServices $services ) : MagicWordFactory {
611  return new MagicWordFactory(
612  $services->getContentLanguage(),
613  $services->getHookContainer()
614  );
615  },
616 
617  'MainConfig' => function ( MediaWikiServices $services ) : Config {
618  // Use the 'main' config from the ConfigFactory service.
619  return $services->getConfigFactory()->makeConfig( 'main' );
620  },
621 
622  'MainObjectStash' => function ( MediaWikiServices $services ) : BagOStuff {
623  $mainConfig = $services->getMainConfig();
624 
625  $id = $mainConfig->get( 'MainStash' );
626  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$id] ) ) {
627  throw new UnexpectedValueException(
628  "Cache type \"$id\" is not present in \$wgObjectCaches." );
629  }
630 
631  $params = $mainConfig->get( 'ObjectCaches' )[$id];
632 
633  $store = ObjectCache::newFromParams( $params, $mainConfig );
634  $store->getLogger()->debug( 'MainObjectStash using store {class}', [
635  'class' => get_class( $store )
636  ] );
637 
638  return $store;
639  },
640 
641  'MainWANObjectCache' => function ( MediaWikiServices $services ) : WANObjectCache {
642  $mainConfig = $services->getMainConfig();
643 
644  $wanId = $mainConfig->get( 'MainWANCache' );
645  $wanParams = $mainConfig->get( 'WANObjectCaches' )[$wanId] ?? null;
646  if ( !$wanParams ) {
647  throw new UnexpectedValueException(
648  "wgWANObjectCaches must have \"$wanId\" set (via wgMainWANCache)"
649  );
650  }
651 
652  $cacheId = $wanParams['cacheId'];
653  $wanClass = $wanParams['class'];
654  unset( $wanParams['cacheId'] );
655  unset( $wanParams['class'] );
656 
657  $storeParams = $mainConfig->get( 'ObjectCaches' )[$cacheId] ?? null;
658  if ( !$storeParams ) {
659  throw new UnexpectedValueException(
660  "wgObjectCaches must have \"$cacheId\" set (via wgWANObjectCaches)"
661  );
662  }
663  $store = ObjectCache::newFromParams( $storeParams, $mainConfig );
664  $logger = $store->getLogger();
665  $logger->debug( 'MainWANObjectCache using store {class}', [
666  'class' => get_class( $store )
667  ] );
668 
669  $wanParams['cache'] = $store;
670  $wanParams['logger'] = $logger;
671  $wanParams['secret'] = $wanParams['secret'] ?? $mainConfig->get( 'SecretKey' );
672  if ( !$mainConfig->get( 'CommandLineMode' ) ) {
673  // Send the statsd data post-send on HTTP requests; avoid in CLI mode (T181385)
674  $wanParams['stats'] = $services->getStatsdDataFactory();
675  // Let pre-emptive refreshes happen post-send on HTTP requests
676  $wanParams['asyncHandler'] = [ DeferredUpdates::class, 'addCallableUpdate' ];
677  }
678 
679  $instance = new $wanClass( $wanParams );
680 
681  '@phan-var WANObjectCache $instance';
682  return $instance;
683  },
684 
685  'MediaHandlerFactory' => function ( MediaWikiServices $services ) : MediaHandlerFactory {
686  return new MediaHandlerFactory(
687  $services->getMainConfig()->get( 'MediaHandlers' )
688  );
689  },
690 
691  'MergeHistoryFactory' => function ( MediaWikiServices $services ) : MergeHistoryFactory {
692  return $services->getService( '_PageCommandFactory' );
693  },
694 
695  'MessageCache' => function ( MediaWikiServices $services ) : MessageCache {
696  $mainConfig = $services->getMainConfig();
697  $clusterCache = ObjectCache::getInstance( $mainConfig->get( 'MessageCacheType' ) );
698  $srvCache = $mainConfig->get( 'UseLocalMessageCache' )
699  ? $services->getLocalServerObjectCache()
700  : new EmptyBagOStuff();
701 
702  $logger = LoggerFactory::getInstance( 'MessageCache' );
703  $logger->debug( 'MessageCache using store {class}', [
704  'class' => get_class( $clusterCache )
705  ] );
706 
707  return new MessageCache(
708  $services->getMainWANObjectCache(),
709  $clusterCache,
710  $srvCache,
711  $services->getContentLanguage(),
712  $services->getLanguageConverterFactory()->getLanguageConverter(),
713  $logger,
714  [ 'useDB' => $mainConfig->get( 'UseDatabaseMessages' ) ],
715  $services->getLanguageFactory(),
716  $services->getLocalisationCache(),
717  $services->getLanguageNameUtils(),
718  $services->getLanguageFallback(),
719  $services->getHookContainer()
720  );
721  },
722 
723  'MessageFormatterFactory' => function ( MediaWikiServices $services ) : IMessageFormatterFactory {
724  return new MessageFormatterFactory();
725  },
726 
727  'MimeAnalyzer' => function ( MediaWikiServices $services ) : MimeAnalyzer {
728  $logger = LoggerFactory::getInstance( 'Mime' );
729  $mainConfig = $services->getMainConfig();
730  $hookRunner = new HookRunner( $services->getHookContainer() );
731  $params = [
732  'typeFile' => $mainConfig->get( 'MimeTypeFile' ),
733  'infoFile' => $mainConfig->get( 'MimeInfoFile' ),
734  'xmlTypes' => $mainConfig->get( 'XMLMimeTypes' ),
735  'guessCallback' =>
736  function ( $mimeAnalyzer, &$head, &$tail, $file, &$mime )
737  use ( $logger, $hookRunner ) {
738  // Also test DjVu
739  $deja = new DjVuImage( $file );
740  if ( $deja->isValid() ) {
741  $logger->info( "Detected $file as image/vnd.djvu\n" );
742  $mime = 'image/vnd.djvu';
743 
744  return;
745  }
746  // Some strings by reference for performance - assuming well-behaved hooks
747  $hookRunner->onMimeMagicGuessFromContent(
748  $mimeAnalyzer, $head, $tail, $file, $mime );
749  },
750  'extCallback' => function ( $mimeAnalyzer, $ext, &$mime ) use ( $hookRunner ) {
751  // Media handling extensions can improve the MIME detected
752  $hookRunner->onMimeMagicImproveFromExtension( $mimeAnalyzer, $ext, $mime );
753  },
754  'initCallback' => function ( $mimeAnalyzer ) use ( $hookRunner ) {
755  // Allow media handling extensions adding MIME-types and MIME-info
756  $hookRunner->onMimeMagicInit( $mimeAnalyzer );
757  },
758  'logger' => $logger
759  ];
760 
761  if ( $params['infoFile'] === 'includes/mime.info' ) {
762  $params['infoFile'] = MimeAnalyzer::USE_INTERNAL;
763  }
764 
765  if ( $params['typeFile'] === 'includes/mime.types' ) {
766  $params['typeFile'] = MimeAnalyzer::USE_INTERNAL;
767  }
768 
769  $detectorCmd = $mainConfig->get( 'MimeDetectorCommand' );
770  if ( $detectorCmd ) {
771  $factory = $services->getShellCommandFactory();
772  $params['detectCallback'] = function ( $file ) use ( $detectorCmd, $factory ) {
773  $result = $factory->create()
774  // $wgMimeDetectorCommand can contain commands with parameters
775  ->unsafeParams( $detectorCmd )
776  ->params( $file )
777  ->execute();
778  return $result->getStdout();
779  };
780  }
781 
782  return new MimeAnalyzer( $params );
783  },
784 
785  'MovePageFactory' => function ( MediaWikiServices $services ) : MovePageFactory {
786  return $services->getService( '_PageCommandFactory' );
787  },
788 
789  'NamespaceInfo' => function ( MediaWikiServices $services ) : NamespaceInfo {
790  return new NamespaceInfo(
791  new ServiceOptions( NamespaceInfo::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
792  $services->getHookContainer()
793  );
794  },
795 
796  'NameTableStoreFactory' => function ( MediaWikiServices $services ) : NameTableStoreFactory {
797  return new NameTableStoreFactory(
798  $services->getDBLoadBalancerFactory(),
799  $services->getMainWANObjectCache(),
800  LoggerFactory::getInstance( 'NameTableSqlStore' )
801  );
802  },
803 
804  'ObjectFactory' => function ( MediaWikiServices $services ) : ObjectFactory {
805  return new ObjectFactory( $services );
806  },
807 
808  'OldRevisionImporter' => function ( MediaWikiServices $services ) : OldRevisionImporter {
810  true,
811  LoggerFactory::getInstance( 'OldRevisionImporter' ),
812  $services->getDBLoadBalancer(),
813  $services->getRevisionStore(),
814  $services->getSlotRoleRegistry()
815  );
816  },
817 
818  'PageEditStash' => function ( MediaWikiServices $services ) : PageEditStash {
819  $config = $services->getMainConfig();
820 
821  return new PageEditStash(
823  $services->getDBLoadBalancer(),
824  LoggerFactory::getInstance( 'StashEdit' ),
825  $services->getStatsdDataFactory(),
826  $services->getHookContainer(),
827  defined( 'MEDIAWIKI_JOB_RUNNER' ) || $config->get( 'CommandLineMode' )
828  ? PageEditStash::INITIATOR_JOB_OR_CLI
829  : PageEditStash::INITIATOR_USER
830  );
831  },
832 
833  'PageProps' => function ( MediaWikiServices $services ) : PageProps {
834  return new PageProps(
835  $services->getLinkBatchFactory(),
836  $services->getDBLoadBalancer()
837  );
838  },
839 
840  'Parser' => function ( MediaWikiServices $services ) : Parser {
841  return $services->getParserFactory()->create();
842  },
843 
844  'ParserCache' => function ( MediaWikiServices $services ) : ParserCache {
845  $config = $services->getMainConfig();
846  $cache = ObjectCache::getInstance( $config->get( 'ParserCacheType' ) );
847  wfDebugLog( 'caches', 'parser: ' . get_class( $cache ) );
848 
849  return new ParserCache(
850  $cache,
851  $config->get( 'CacheEpoch' ),
852  $services->getHookContainer(),
853  $services->getStatsdDataFactory()
854  );
855  },
856 
857  'ParserFactory' => function ( MediaWikiServices $services ) : ParserFactory {
858  $options = new ServiceOptions( Parser::CONSTRUCTOR_OPTIONS,
859  // 'class'
860  // Note that this value is ignored by ParserFactory and is always
861  // Parser::class for legacy reasons; we'll introduce a new
862  // mechanism for selecting an alternate parser in the future
863  // (T236809)
864  $services->getMainConfig()->get( 'ParserConf' ),
865  // Make sure to have defaults in case someone overrode ParserConf with something silly
866  [ 'class' => Parser::class ],
867  // Plus a bunch of actual config options
868  $services->getMainConfig()
869  );
870 
871  return new ParserFactory(
872  $options,
873  $services->getMagicWordFactory(),
874  $services->getContentLanguage(),
875  wfUrlProtocols(),
876  $services->getSpecialPageFactory(),
877  $services->getLinkRendererFactory(),
878  $services->getNamespaceInfo(),
879  LoggerFactory::getInstance( 'Parser' ),
880  $services->getBadFileLookup(),
881  $services->getLanguageConverterFactory(),
882  $services->getHookContainer()
883  );
884  },
885 
886  'PasswordFactory' => function ( MediaWikiServices $services ) : PasswordFactory {
887  $config = $services->getMainConfig();
888  return new PasswordFactory(
889  $config->get( 'PasswordConfig' ),
890  $config->get( 'PasswordDefault' )
891  );
892  },
893 
894  'PasswordReset' => function ( MediaWikiServices $services ) : PasswordReset {
895  $options = new ServiceOptions( PasswordReset::CONSTRUCTOR_OPTIONS, $services->getMainConfig() );
896  return new PasswordReset(
897  $options,
898  $services->getAuthManager(),
899  $services->getPermissionManager(),
900  $services->getDBLoadBalancer(),
901  LoggerFactory::getInstance( 'authentication' ),
902  $services->getHookContainer()
903  );
904  },
905 
906  'PerDbNameStatsdDataFactory' =>
907  function ( MediaWikiServices $services ) : StatsdDataFactoryInterface {
908  $config = $services->getMainConfig();
909  $wiki = $config->get( 'DBname' );
911  $services->getStatsdDataFactory(),
912  $wiki
913  );
914  },
915 
916  'PermissionManager' => function ( MediaWikiServices $services ) : PermissionManager {
917  return new PermissionManager(
918  new ServiceOptions(
919  PermissionManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
920  ),
921  $services->getSpecialPageFactory(),
922  $services->getRevisionLookup(),
923  $services->getNamespaceInfo(),
924  $services->getBlockErrorFormatter(),
925  $services->getHookContainer()
926  );
927  },
928 
929  'PreferencesFactory' => function ( MediaWikiServices $services ) : PreferencesFactory {
930  $factory = new DefaultPreferencesFactory(
931  new ServiceOptions(
932  DefaultPreferencesFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
933  $services->getContentLanguage(),
934  $services->getAuthManager(),
935  $services->getLinkRendererFactory()->create(),
936  $services->getNamespaceInfo(),
937  $services->getPermissionManager(),
938  $services->getLanguageConverterFactory()->getLanguageConverter(),
939  $services->getLanguageNameUtils(),
940  $services->getHookContainer()
941  );
942  $factory->setLogger( LoggerFactory::getInstance( 'preferences' ) );
943 
944  return $factory;
945  },
946 
947  'ProxyLookup' => function ( MediaWikiServices $services ) : ProxyLookup {
948  $mainConfig = $services->getMainConfig();
949  return new ProxyLookup(
950  $mainConfig->get( 'CdnServers' ),
951  $mainConfig->get( 'CdnServersNoPurge' )
952  );
953  },
954 
955  'ReadOnlyMode' => function ( MediaWikiServices $services ) : ReadOnlyMode {
956  return new ReadOnlyMode(
957  $services->getConfiguredReadOnlyMode(),
958  $services->getDBLoadBalancer()
959  );
960  },
961 
962  'RepoGroup' => function ( MediaWikiServices $services ) : RepoGroup {
963  $config = $services->getMainConfig();
964  return new RepoGroup(
965  $config->get( 'LocalFileRepo' ),
966  $config->get( 'ForeignFileRepos' ),
967  $services->getMainWANObjectCache()
968  );
969  },
970 
971  'ResourceLoader' => function ( MediaWikiServices $services ) : ResourceLoader {
972  // @todo This should not take a Config object, but it's not so easy to remove because it
973  // exposes it in a getter, which is actually used.
974  global $IP;
975  $config = $services->getMainConfig();
976 
977  $rl = new ResourceLoader(
978  $config,
979  LoggerFactory::getInstance( 'resourceloader' ),
980  $config->get( 'ResourceLoaderUseObjectCacheForDeps' )
981  ? new KeyValueDependencyStore( $services->getMainObjectStash() )
982  : new SqlModuleDependencyStore( $services->getDBLoadBalancer() )
983  );
984 
985  $extRegistry = ExtensionRegistry::getInstance();
986  // Attribute has precedence over config
987  $modules = $extRegistry->getAttribute( 'ResourceModules' )
988  + $config->get( 'ResourceModules' );
989  $moduleSkinStyles = $extRegistry->getAttribute( 'ResourceModuleSkinStyles' )
990  + $config->get( 'ResourceModuleSkinStyles' );
991 
992  $rl->setModuleSkinStyles( $moduleSkinStyles );
993  $rl->addSource( $config->get( 'ResourceLoaderSources' ) );
994 
995  // Core modules, then extension/skin modules
996  $rl->register( include "$IP/resources/Resources.php" );
997  $rl->register( $modules );
998  $hookRunner = new HookRunner( $services->getHookContainer() );
999  $hookRunner->onResourceLoaderRegisterModules( $rl );
1000 
1001  $msgPosterAttrib = $extRegistry->getAttribute( 'MessagePosterModule' );
1002  $rl->register( 'mediawiki.messagePoster', [
1003  'localBasePath' => '',
1004  'debugRaw' => false,
1005  'scripts' => array_merge(
1006  [
1007  "$IP/resources/src/mediawiki.messagePoster/factory.js",
1008  "$IP/resources/src/mediawiki.messagePoster/MessagePoster.js",
1009  "$IP/resources/src/mediawiki.messagePoster/WikitextMessagePoster.js",
1010  ],
1011  $msgPosterAttrib['scripts'] ?? []
1012  ),
1013  'dependencies' => array_merge(
1014  [
1015  'oojs',
1016  'mediawiki.api',
1017  'mediawiki.ForeignApi',
1018  ],
1019  $msgPosterAttrib['dependencies'] ?? []
1020  ),
1021  'targets' => [ 'desktop', 'mobile' ],
1022  ] );
1023 
1024  if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
1025  $rl->registerTestModules();
1026  }
1027 
1028  return $rl;
1029  },
1030 
1031  'RevisionFactory' => function ( MediaWikiServices $services ) : RevisionFactory {
1032  return $services->getRevisionStore();
1033  },
1034 
1035  'RevisionLookup' => function ( MediaWikiServices $services ) : RevisionLookup {
1036  return $services->getRevisionStore();
1037  },
1038 
1039  'RevisionRenderer' => function ( MediaWikiServices $services ) : RevisionRenderer {
1040  $renderer = new RevisionRenderer(
1041  $services->getDBLoadBalancer(),
1042  $services->getSlotRoleRegistry()
1043  );
1044 
1045  $renderer->setLogger( LoggerFactory::getInstance( 'SaveParse' ) );
1046  return $renderer;
1047  },
1048 
1049  'RevisionStore' => function ( MediaWikiServices $services ) : RevisionStore {
1050  return $services->getRevisionStoreFactory()->getRevisionStore();
1051  },
1052 
1053  'RevisionStoreFactory' => function ( MediaWikiServices $services ) : RevisionStoreFactory {
1054  $config = $services->getMainConfig();
1055 
1056  if ( $config->has( 'MultiContentRevisionSchemaMigrationStage' ) ) {
1057  if ( $config->get( 'MultiContentRevisionSchemaMigrationStage' ) !== SCHEMA_COMPAT_NEW ) {
1058  throw new UnexpectedValueException(
1059  'The MultiContentRevisionSchemaMigrationStage setting is no longer supported!'
1060  );
1061  }
1062  }
1063 
1064  $store = new RevisionStoreFactory(
1065  $services->getDBLoadBalancerFactory(),
1066  $services->getBlobStoreFactory(),
1067  $services->getNameTableStoreFactory(),
1068  $services->getSlotRoleRegistry(),
1069  $services->getMainWANObjectCache(),
1070  $services->getCommentStore(),
1071  $services->getActorMigration(),
1072  LoggerFactory::getInstance( 'RevisionStore' ),
1073  $services->getContentHandlerFactory(),
1074  $services->getHookContainer()
1075  );
1076 
1077  return $store;
1078  },
1079 
1080  'SearchEngineConfig' => function ( MediaWikiServices $services ) : SearchEngineConfig {
1081  // @todo This should not take a Config object, but it's not so easy to remove because it
1082  // exposes it in a getter, which is actually used.
1083  return new SearchEngineConfig(
1084  $services->getMainConfig(),
1085  $services->getContentLanguage(),
1086  $services->getHookContainer(),
1087  ExtensionRegistry::getInstance()->getAttribute( 'SearchMappings' )
1088  );
1089  },
1090 
1091  'SearchEngineFactory' => function ( MediaWikiServices $services ) : SearchEngineFactory {
1092  return new SearchEngineFactory(
1093  $services->getSearchEngineConfig(),
1094  $services->getHookContainer()
1095  );
1096  },
1097 
1098  'ShellCommandFactory' => function ( MediaWikiServices $services ) : CommandFactory {
1099  $config = $services->getMainConfig();
1100 
1101  $limits = [
1102  'time' => $config->get( 'MaxShellTime' ),
1103  'walltime' => $config->get( 'MaxShellWallClockTime' ),
1104  'memory' => $config->get( 'MaxShellMemory' ),
1105  'filesize' => $config->get( 'MaxShellFileSize' ),
1106  ];
1107  $cgroup = $config->get( 'ShellCgroup' );
1108  $restrictionMethod = $config->get( 'ShellRestrictionMethod' );
1109 
1110  $factory = new CommandFactory( $limits, $cgroup, $restrictionMethod );
1111  $factory->setLogger( LoggerFactory::getInstance( 'exec' ) );
1112  $factory->logStderr();
1113 
1114  return $factory;
1115  },
1116 
1117  'SiteLookup' => function ( MediaWikiServices $services ) : SiteLookup {
1118  // Use SiteStore as the SiteLookup as well. This was originally separated
1119  // to allow for a cacheable read-only interface, but this was never used.
1120  // SiteStore has caching (see below).
1121  return $services->getSiteStore();
1122  },
1123 
1124  'SiteStore' => function ( MediaWikiServices $services ) : SiteStore {
1125  $rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() );
1126 
1127  $cache = $services->getLocalServerObjectCache();
1128  if ( $cache instanceof EmptyBagOStuff ) {
1130  }
1131 
1132  return new CachingSiteStore( $rawSiteStore, $cache );
1133  },
1134 
1136  'SkinFactory' => function ( MediaWikiServices $services ) : SkinFactory {
1137  $factory = new SkinFactory(
1138  $services->getObjectFactory(),
1139  (array)$services->getMainConfig()->get( 'SkipSkins' )
1140  );
1141 
1142  $names = $services->getMainConfig()->get( 'ValidSkinNames' );
1143 
1144  foreach ( $names as $name => $skin ) {
1145  if ( is_array( $skin ) ) {
1146  $spec = $skin;
1147  $displayName = $skin['displayname'] ?? $name;
1148  } else {
1149  $displayName = $skin;
1150  $spec = [
1151  'class' => "Skin$skin"
1152  ];
1153  }
1154  $factory->register( $name, $displayName, $spec );
1155  }
1156 
1157  // Register a hidden "fallback" skin
1158  $factory->register( 'fallback', 'Fallback', [
1159  'class' => SkinFallback::class,
1160  'args' => [
1161  [
1162  'styles' => [ 'mediawiki.skinning.interface' ],
1163  'templateDirectory' => __DIR__ . '/skins/templates/fallback',
1164  ]
1165  ]
1166  ] );
1167  // Register a hidden skin for api output
1168  $factory->register( 'apioutput', 'ApiOutput', [
1169  'class' => SkinApi::class,
1170  'args' => [
1171  [
1172  'styles' => [ 'mediawiki.skinning.interface' ],
1173  'templateDirectory' => __DIR__ . '/skins/templates/apioutput',
1174  ]
1175  ]
1176  ] );
1177 
1178  return $factory;
1179  },
1180 
1181  'SlotRoleRegistry' => function ( MediaWikiServices $services ) : SlotRoleRegistry {
1182  $config = $services->getMainConfig();
1183  $contentHandlerFactory = $services->getContentHandlerFactory();
1184 
1185  $registry = new SlotRoleRegistry(
1186  $services->getSlotRoleStore()
1187  );
1188 
1189  $registry->defineRole( 'main', function () use ( $config, $contentHandlerFactory ) {
1190  return new MainSlotRoleHandler(
1191  $config->get( 'NamespaceContentModels' ),
1192  $contentHandlerFactory
1193  );
1194  } );
1195 
1196  return $registry;
1197  },
1198 
1199  'SlotRoleStore' => function ( MediaWikiServices $services ) : NameTableStore {
1200  return $services->getNameTableStoreFactory()->getSlotRoles();
1201  },
1202 
1203  'SpamChecker' => function ( MediaWikiServices $services ) : SpamChecker {
1204  return new SpamChecker(
1205  (array)$services->getMainConfig()->get( 'SpamRegex' ),
1206  (array)$services->getMainConfig()->get( 'SummarySpamRegex' )
1207  );
1208  },
1209 
1210  'SpecialPageFactory' => function ( MediaWikiServices $services ) : SpecialPageFactory {
1211  return new SpecialPageFactory(
1212  new ServiceOptions(
1213  SpecialPageFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
1214  $services->getContentLanguage(),
1215  $services->getObjectFactory(),
1216  $services->getHookContainer()
1217  );
1218  },
1219 
1220  'StatsdDataFactory' => function ( MediaWikiServices $services ) : IBufferingStatsdDataFactory {
1221  return new BufferingStatsdDataFactory(
1222  rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' )
1223  );
1224  },
1225 
1226  'TalkPageNotificationManager' => function (
1227  MediaWikiServices $services
1229  return new TalkPageNotificationManager(
1230  new ServiceOptions(
1231  TalkPageNotificationManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
1232  ),
1233  $services->getDBLoadBalancer(),
1234  $services->getReadOnlyMode(),
1235  $services->getRevisionLookup()
1236  );
1237  },
1238 
1239  'TempFSFileFactory' => function ( MediaWikiServices $services ) : TempFSFileFactory {
1240  return new TempFSFileFactory( $services->getMainConfig()->get( 'TmpDirectory' ) );
1241  },
1242 
1243  'TitleFactory' => function ( MediaWikiServices $services ) : TitleFactory {
1244  return new TitleFactory();
1245  },
1246 
1247  'TitleFormatter' => function ( MediaWikiServices $services ) : TitleFormatter {
1248  return $services->getService( '_MediaWikiTitleCodec' );
1249  },
1250 
1251  'TitleParser' => function ( MediaWikiServices $services ) : TitleParser {
1252  return $services->getService( '_MediaWikiTitleCodec' );
1253  },
1254 
1255  'UploadRevisionImporter' => function ( MediaWikiServices $services ) : UploadRevisionImporter {
1257  $services->getMainConfig()->get( 'EnableUploads' ),
1258  LoggerFactory::getInstance( 'UploadRevisionImporter' )
1259  );
1260  },
1261 
1262  'UserEditTracker' => function ( MediaWikiServices $services ) : UserEditTracker {
1263  $jobQueueGroup = JobQueueGroup::singleton();
1264 
1265  return new UserEditTracker(
1266  $services->getActorMigration(),
1267  $services->getDBLoadBalancer(),
1268  $jobQueueGroup
1269  );
1270  },
1271 
1272  'UserFactory' => function ( MediaWikiServices $services ) : UserFactory {
1273  return new UserFactory( $services->getUserNameUtils() );
1274  },
1275 
1276  'UserGroupManager' => function ( MediaWikiServices $services ) : UserGroupManager {
1277  return $services->getUserGroupManagerFactory()->getUserGroupManager();
1278  },
1279 
1280  'UserGroupManagerFactory' => function ( MediaWikiServices $services ) : UserGroupManagerFactory {
1281  return new UserGroupManagerFactory(
1282  new ServiceOptions(
1283  UserGroupManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
1284  ),
1285  $services->getConfiguredReadOnlyMode(),
1286  $services->getDBLoadBalancerFactory(),
1287  $services->getHookContainer(),
1288  $services->getUserEditTracker(),
1289  LoggerFactory::getInstance( 'UserGroupManager' ),
1290  [ function ( UserIdentity $user ) use ( $services ) {
1291  $services->getPermissionManager()->invalidateUsersRightsCache( $user );
1292  User::newFromIdentity( $user )->invalidateCache();
1293  } ]
1294  );
1295  },
1296 
1297  'UserNameUtils' => function ( MediaWikiServices $services ) : UserNameUtils {
1298  $messageFormatterFactory = new MessageFormatterFactory( Message::FORMAT_PLAIN );
1299  return new UserNameUtils(
1300  new ServiceOptions(
1301  UserNameUtils::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
1302  ),
1303  $services->getContentLanguage(),
1304  LoggerFactory::getInstance( 'UserNameUtils' ),
1305  $services->getTitleParser(),
1306  $messageFormatterFactory->getTextFormatter(
1307  $services->getContentLanguage()->getCode()
1308  ),
1309  $services->getHookContainer()
1310  );
1311  },
1312 
1313  'UserOptionsLookup' => function ( MediaWikiServices $services ) : UserOptionsLookup {
1314  return $services->getUserOptionsManager();
1315  },
1316 
1317  'UserOptionsManager' => function ( MediaWikiServices $services ) : UserOptionsManager {
1318  return new UserOptionsManager(
1319  new ServiceOptions( UserOptionsManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
1320  $services->get( '_DefaultOptionsLookup' ),
1321  $services->getLanguageConverterFactory(),
1322  $services->getDBLoadBalancer(),
1323  LoggerFactory::getInstance( 'UserOptionsManager' ),
1324  $services->getHookContainer()
1325  );
1326  },
1327 
1328  'VirtualRESTServiceClient' =>
1329  function ( MediaWikiServices $services ) : VirtualRESTServiceClient {
1330  $config = $services->getMainConfig()->get( 'VirtualRestConfig' );
1331 
1332  $vrsClient = new VirtualRESTServiceClient(
1333  $services->getHttpRequestFactory()->createMultiClient() );
1334  foreach ( $config['paths'] as $prefix => $serviceConfig ) {
1335  $class = $serviceConfig['class'];
1336  // Merge in the global defaults
1337  $constructArg = $serviceConfig['options'] ?? [];
1338  $constructArg += $config['global'];
1339  // Make the VRS service available at the mount point
1340  $vrsClient->mount( $prefix, [ 'class' => $class, 'config' => $constructArg ] );
1341  }
1342 
1343  return $vrsClient;
1344  },
1345 
1346  'WatchedItemQueryService' =>
1347  function ( MediaWikiServices $services ) : WatchedItemQueryService {
1348  return new WatchedItemQueryService(
1349  $services->getDBLoadBalancer(),
1350  $services->getCommentStore(),
1351  $services->getActorMigration(),
1352  $services->getWatchedItemStore(),
1353  $services->getPermissionManager(),
1354  $services->getHookContainer(),
1355  $services->getMainConfig()->get( 'WatchlistExpiry' )
1356  );
1357  },
1358 
1359  'WatchedItemStore' => function ( MediaWikiServices $services ) : WatchedItemStore {
1360  $store = new WatchedItemStore(
1362  $services->getMainConfig() ),
1363  $services->getDBLoadBalancerFactory(),
1365  $services->getMainObjectStash(),
1366  new HashBagOStuff( [ 'maxKeys' => 100 ] ),
1367  $services->getReadOnlyMode(),
1368  $services->getNamespaceInfo(),
1369  $services->getRevisionLookup(),
1370  $services->getHookContainer()
1371  );
1372  $store->setStatsdDataFactory( $services->getStatsdDataFactory() );
1373 
1374  if ( $services->getMainConfig()->get( 'ReadOnlyWatchedItemStore' ) ) {
1375  $store = new NoWriteWatchedItemStore( $store );
1376  }
1377 
1378  return $store;
1379  },
1380 
1381  'WatchlistNotificationManager' =>
1382  function ( MediaWikiServices $services ) : WatchlistNotificationManager {
1383  return new WatchlistNotificationManager(
1384  new ServiceOptions(
1385  WatchlistNotificationManager::CONSTRUCTOR_OPTIONS,
1386  $services->getMainConfig()
1387  ),
1388  $services->getHookContainer(),
1389  $services->getPermissionManager(),
1390  $services->getReadOnlyMode(),
1391  $services->getRevisionLookup(),
1392  $services->getTalkPageNotificationManager(),
1393  $services->getWatchedItemStore()
1394  );
1395  },
1396 
1397  'WikiPageFactory' => function ( MediaWikiServices $services ) : WikiPageFactory {
1398  return new WikiPageFactory(
1399  $services->getTitleFactory(),
1400  new HookRunner( $services->getHookContainer() ),
1401  $services->getDBLoadBalancer()
1402  );
1403  },
1404 
1405  'WikiRevisionOldRevisionImporterNoUpdates' =>
1406  function ( MediaWikiServices $services ) : ImportableOldRevisionImporter {
1407  return new ImportableOldRevisionImporter(
1408  false,
1409  LoggerFactory::getInstance( 'OldRevisionImporter' ),
1410  $services->getDBLoadBalancer(),
1411  $services->getRevisionStore(),
1412  $services->getSlotRoleRegistry()
1413  );
1414  },
1415 
1416  '_DefaultOptionsLookup' => function ( MediaWikiServices $services ) : DefaultOptionsLookup {
1417  return new DefaultOptionsLookup(
1418  new ServiceOptions( DefaultOptionsLookup::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
1419  $services->getContentLanguage(),
1420  $services->getHookContainer()
1421  );
1422  },
1423 
1424  '_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) : MediaWikiTitleCodec {
1425  return new MediaWikiTitleCodec(
1426  $services->getContentLanguage(),
1427  $services->getGenderCache(),
1428  $services->getMainConfig()->get( 'LocalInterwikis' ),
1429  $services->getInterwikiLookup(),
1430  $services->getNamespaceInfo()
1431  );
1432  },
1433 
1434  '_PageCommandFactory' => function ( MediaWikiServices $services ) : PageCommandFactory {
1435  return new PageCommandFactory(
1436  new ServiceOptions( PageCommandFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
1437  $services->getDBLoadBalancer(),
1438  $services->getNamespaceInfo(),
1439  $services->getWatchedItemStore(),
1440  $services->getPermissionManager(),
1441  $services->getRepoGroup(),
1442  $services->getContentHandlerFactory(),
1443  $services->getRevisionStore(),
1444  $services->getSpamChecker(),
1445  $services->getHookContainer()
1446  );
1447  },
1448 
1449  '_SqlBlobStore' => function ( MediaWikiServices $services ) : SqlBlobStore {
1450  return $services->getBlobStoreFactory()->newSqlBlobStore();
1451  },
1452 
1454  // NOTE: When adding a service here, don't forget to add a getter function
1455  // in the MediaWikiServices class. The convenience getter should just call
1456  // $this->getService( 'FooBarService' ).
1458 
1459 ];
PasswordReset\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: PasswordReset.php:71
EventRelayerGroup
Factory class for spawning EventRelayer objects using configuration.
Definition: EventRelayerGroup.php:26
LinkCache
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition: LinkCache.php:34
MediaWiki\Block\BlockPermissionCheckerFactory
Factory class for BlockPermissionChecker.
Definition: BlockPermissionCheckerFactory.php:32
MediaWikiTitleCodec
A codec for MediaWiki page titles.
Definition: MediaWikiTitleCodec.php:39
WikiMap\getCurrentWikiDbDomain
static getCurrentWikiDbDomain()
Definition: WikiMap.php:293
UploadRevisionImporter
Definition: UploadRevisionImporter.php:6
Wikimedia\UUID\GlobalIdGenerator
Class for getting statistically unique IDs without a central coordinator.
Definition: GlobalIdGenerator.php:36
FileBackendGroup
Class to handle file backend registration.
Definition: FileBackendGroup.php:37
ObjectCache\getLocalClusterInstance
static getLocalClusterInstance()
Get the main cluster-local cache object.
Definition: ObjectCache.php:272
MessageBlobStore\clearGlobalCacheEntry
static clearGlobalCacheEntry(WANObjectCache $cache)
Invalidate cache keys for all known modules.
Definition: MessageBlobStore.php:189
MagicWordFactory
A factory that stores information about MagicWords, and creates them on demand with caching.
Definition: MagicWordFactory.php:37
HashBagOStuff
Simple store for keeping values in an associative array for the current process.
Definition: HashBagOStuff.php:32
ImportableOldRevisionImporter
Definition: ImportableOldRevisionImporter.php:12
MediaWiki\Interwiki\ClassicInterwikiLookup
InterwikiLookup implementing the "classic" interwiki storage (hardcoded up to MW 1....
Definition: ClassicInterwikiLookup.php:48
EmptyBagOStuff
A BagOStuff object with no objects in it.
Definition: EmptyBagOStuff.php:29
Revision\MainSlotRoleHandler
A SlotRoleHandler for the main slot.
Definition: MainSlotRoleHandler.php:42
MediaWiki\Block\BlockManager
A service class for checking blocks.
Definition: BlockManager.php:46
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:155
MediaWiki\BadFileLookup
Definition: BadFileLookup.php:13
MimeAnalyzer
Implements functions related to MIME types such as detection and mapping to file extension.
Definition: MimeAnalyzer.php:33
Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:81
ObjectCache\makeLocalServerCache
static makeLocalServerCache()
Create a new BagOStuff instance for local-server caching.
Definition: ObjectCache.php:299
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:51
MediaWiki\Block\BlockErrorFormatter
A service class for getting formatted information about a block.
Definition: BlockErrorFormatter.php:34
MediaWiki\Http\HttpRequestFactory
Factory creating MWHttpRequest objects.
Definition: HttpRequestFactory.php:38
MediaWiki\Languages\LanguageFactory
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: LanguageFactory.php:42
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:41
MediaWiki\SpecialPage\SpecialPageFactory
Factory for handling the special page list and generating SpecialPage objects.
Definition: SpecialPageFactory.php:65
ReadOnlyMode
A service class for fetching the wiki's current read-only mode.
Definition: ReadOnlyMode.php:11
MediaWiki\FileBackend\LockManager\LockManagerGroupFactory
Service to construct LockManagerGroups.
Definition: LockManagerGroupFactory.php:11
CachingSiteStore
Definition: CachingSiteStore.php:31
Message\MessageFormatterFactory
The MediaWiki-specific implementation of IMessageFormatterFactory.
Definition: MessageFormatterFactory.php:12
MIGRATION_NEW
const MIGRATION_NEW
Definition: Defines.php:308
MediaWiki\HookContainer\DeprecatedHooks
Definition: DeprecatedHooks.php:27
GenderCache
Caches user genders when needed to use correct namespace aliases.
Definition: GenderCache.php:36
DjVuImage
Support for detecting/validating DjVu image files and getting some basic file metadata (resolution et...
Definition: DjVuImage.php:38
MediaWiki\Languages\LanguageFallback
Definition: LanguageFallback.php:31
ConfiguredReadOnlyMode
A read-only mode service which does not depend on LoadBalancer.
Definition: ConfiguredReadOnlyMode.php:9
CommentStore
Handle database storage of comments such as edit summaries and log reasons.
Definition: CommentStore.php:42
$file
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
BagOStuff
Class representing a cache/ephemeral data store.
Definition: BagOStuff.php:71
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1219
MediaWiki\Linker\LinkRendererFactory
Factory to create LinkRender objects.
Definition: LinkRendererFactory.php:34
SearchEngineFactory
Factory class for SearchEngine.
Definition: SearchEngineFactory.php:13
Revision\RevisionFactory
Service for constructing revision objects.
Definition: RevisionFactory.php:38
User\newFromIdentity
static newFromIdentity(UserIdentity $identity)
Returns a User object corresponding to the given UserIdentity.
Definition: User.php:594
ActorMigration
This class handles the logic for the actor table migration and should always be used in lieu of direc...
Definition: ActorMigration.php:39
MediaWiki\Block\DatabaseBlockStore
Definition: DatabaseBlockStore.php:44
MWLBFactory\setDomainAliases
static setDomainAliases(ILBFactory $lbFactory)
Definition: MWLBFactory.php:321
MediaWiki\Languages\LanguageConverterFactory
An interface for creating language converters.
Definition: LanguageConverterFactory.php:44
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:988
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:32
SiteLookup
Definition: SiteLookup.php:28
Revision\RevisionLookup
Service for looking up page revisions.
Definition: RevisionLookup.php:38
WatchedItemStore\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: WatchedItemStore.php:31
ExternalStoreAccess
Key/value blob storage for a collection of storage medium types (e.g.
Definition: ExternalStoreAccess.php:22
MediaHandlerFactory
Class to construct MediaHandler objects.
Definition: MediaHandlerFactory.php:29
MediaWiki\User\TalkPageNotificationManager
Manages user talk page notifications.
Definition: TalkPageNotificationManager.php:35
MediaWiki\Languages\LanguageNameUtils
A service that provides utilities to do with language names and codes.
Definition: LanguageNameUtils.php:42
SiteStore
Definition: SiteStore.php:29
MediaWiki\User\DefaultOptionsLookup
A service class to control default user options.
Definition: DefaultOptionsLookup.php:35
ExtensionRegistry\getInstance
static getInstance()
Definition: ExtensionRegistry.php:136
WANObjectCache\newEmpty
static newEmpty()
Get an instance that wraps EmptyBagOStuff.
Definition: WANObjectCache.php:348
Config
Interface for configuration instances.
Definition: Config.php:30
MediaWiki\User\UserGroupManager
Managers user groups.
Definition: UserGroupManager.php:51
ObjectCache\newFromParams
static newFromParams(array $params, Config $conf=null)
Create a new cache object from parameters.
Definition: ObjectCache.php:143
Page\MergeHistoryFactory
Definition: MergeHistoryFactory.php:31
BagOStuff\get
get( $key, $flags=0)
Get an item with the given key.
WANObjectCache\get
get( $key, &$curTTL=null, array $checkKeys=[], &$info=null)
Fetch the value of a key from cache.
Definition: WANObjectCache.php:402
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:25
MediaWiki\Logger\LoggerFactory
PSR-3 logger instance factory.
Definition: LoggerFactory.php:45
MediaWiki\Storage\PageEditStash
Class for managing stashed edits used by the page updater classes.
Definition: PageEditStash.php:46
DateFormatterFactory
Definition: DateFormatterFactory.php:3
MediaWiki\User\WatchlistNotificationManager
WatchlistNotificationManager service.
Definition: WatchlistNotificationManager.php:40
LocalisationCache\getStoreFromConf
static getStoreFromConf(array $conf, $fallbackCacheDir)
Return a suitable LCStore as specified by the given configuration.
Definition: LocalisationCache.php:207
WikiMap\getWikiIdFromDbDomain
static getWikiIdFromDbDomain( $domain)
Get the wiki ID of a database domain.
Definition: WikiMap.php:269
CryptHKDF
Definition: CryptHKDF.php:33
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:38
MWLBFactory\applyDefaultConfig
static applyDefaultConfig(array $lbConf, ServiceOptions $options, ConfiguredReadOnlyMode $readOnlyMode, BagOStuff $srvCache, BagOStuff $mainStash, WANObjectCache $wanCache)
Definition: MWLBFactory.php:73
WatchedItemQueryService
Definition: WatchedItemQueryService.php:23
ProxyLookup
Definition: ProxyLookup.php:27
VirtualRESTServiceClient
Virtual HTTP service client loosely styled after a Virtual File System.
Definition: VirtualRESTServiceClient.php:45
$modules
$modules
Definition: HTMLFormElement.php:15
MediaWiki\Interwiki\InterwikiLookup
Service interface for looking up Interwiki records.
Definition: InterwikiLookup.php:32
MediaWiki\Content\ContentHandlerFactory
Definition: ContentHandlerFactory.php:44
ObjectCache\getInstance
static getInstance( $id)
Get a cached instance of the specified type of cache object.
Definition: ObjectCache.php:78
BufferingStatsdDataFactory
A factory for application metric data.
Definition: BufferingStatsdDataFactory.php:35
MWLBFactory\getLBFactoryClass
static getLBFactoryClass(array $config)
Decide which LBFactory class to use.
Definition: MWLBFactory.php:302
Page\WikiPageFactory
Definition: WikiPageFactory.php:19
DBSiteStore
Definition: DBSiteStore.php:33
MediaWiki\Storage\BlobStoreFactory
Service for instantiating BlobStores.
Definition: BlobStoreFactory.php:35
TitleParser
A title parser service for MediaWiki.
Definition: TitleParser.php:33
NamespaceInfo\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: NamespaceInfo.php:89
FileBackendGroup\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: FileBackendGroup.php:68
JobRunner\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: JobRunner.php:43
Wikimedia\DependencyStore\SqlModuleDependencyStore
Class for tracking per-entity dependency path lists in the module_deps table.
Definition: SqlModuleDependencyStore.php:37
MediaWiki\FileBackend\FSFile\TempFSFileFactory
Definition: TempFSFileFactory.php:10
wfUrlProtocols
wfUrlProtocols( $includeProtocolRelative=true)
Returns a regular expression of url protocols.
Definition: GlobalFunctions.php:718
MediaWiki\User\UserGroupManagerFactory
Factory service for UserGroupManager instances.
Definition: UserGroupManagerFactory.php:35
ExternalStoreFactory
Definition: ExternalStoreFactory.php:15
Revision\RevisionRenderer
The RevisionRenderer service provides access to rendered output for revisions.
Definition: RevisionRenderer.php:45
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:49
ParserFactory
Definition: ParserFactory.php:33
PrefixingStatsdDataFactoryProxy
Proxy to prefix metric keys sent to a StatsdDataFactoryInterface.
Definition: PrefixingStatsdDataFactoryProxy.php:29
MediaWiki\HookContainer\GlobalHookRegistry
A HookRegistry which sources its data from dynamically changing sources: $wgHooks and an ExtensionReg...
Definition: GlobalHookRegistry.php:11
MediaWiki\Content\IContentHandlerFactory
Definition: IContentHandlerFactory.php:10
SkinFactory
Factory class to create Skin objects.
Definition: SkinFactory.php:31
MediaWiki\EditPage\SpamChecker
Service to check if text (either content or a summary) qualifies as spam.
Definition: SpamChecker.php:14
MediaWiki\Shell\CommandFactory
Factory facilitating dependency injection for Command.
Definition: CommandFactory.php:32
MediaWiki\Preferences\PreferencesFactory
A PreferencesFactory is a MediaWiki service that provides the definitions of preferences for a given ...
Definition: PreferencesFactory.php:54
WANObjectCache
Multi-datacenter aware caching interface.
Definition: WANObjectCache.php:125
HtmlCacheUpdater
Class to invalidate the CDN and HTMLFileCache entries associated with URLs/titles.
Definition: HtmlCacheUpdater.php:30
LocalisationCache
Class for caching the contents of localisation files, Messages*.php and *.i18n.php.
Definition: LocalisationCache.php:43
MediaWiki\Config\ConfigRepository
Object which holds currently registered configuration options.
Definition: ConfigRepository.php:33
MediaWiki\Mail\Emailer
Definition: Emailer.php:31
Wikimedia\DependencyStore\KeyValueDependencyStore
Lightweight class for tracking path dependencies lists via an object cache instance.
Definition: KeyValueDependencyStore.php:36
MediaWiki\Storage\NameTableStore
Definition: NameTableStore.php:36
Parser
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition: Parser.php:84
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:453
Revision\RevisionStoreFactory
Factory service for RevisionStore instances.
Definition: RevisionStoreFactory.php:51
MediaWiki\User\UserOptionsLookup
Provides access to user options.
Definition: UserOptionsLookup.php:29
Page\MovePageFactory
Definition: MovePageFactory.php:30
MediaWiki\Auth\AuthManager
This serves as the entry point to the authentication system.
Definition: AuthManager.php:88
MediaWiki\Storage\BlobStore
Service for loading and storing data blobs.
Definition: BlobStore.php:35
Revision\ContributionsLookup
Definition: ContributionsLookup.php:14
MediaWiki\User\UserOptionsManager
A service class to control user options.
Definition: UserOptionsManager.php:44
WatchedItemStore
Storage layer class for WatchedItems.
Definition: WatchedItemStore.php:26
Page\PageCommandFactory
Common factory to construct page handling classes.
Definition: PageCommandFactory.php:47
IBufferingStatsdDataFactory
MediaWiki adaptation of StatsdDataFactory that provides buffering functionality.
Definition: IBufferingStatsdDataFactory.php:13
Wikimedia\Message\IMessageFormatterFactory
A simple factory providing a message formatter for a given language code.
Definition: IMessageFormatterFactory.php:10
$command
$command
Definition: mcc.php:125
ImportableUploadRevisionImporter
Definition: ImportableUploadRevisionImporter.php:9
ResourceLoader
ResourceLoader is a loading system for JavaScript and CSS resources.
Definition: ResourceLoader.php:56
OldRevisionImporter
Definition: OldRevisionImporter.php:6
JobQueueGroup\singleton
static singleton( $domain=false)
Definition: JobQueueGroup.php:70
$cache
$cache
Definition: mcc.php:33
MediaWiki\User\UserEditTracker
Track info about user edit counts and timings.
Definition: UserEditTracker.php:19
PageProps
Gives access to properties of a page.
Definition: PageProps.php:33
MediaWiki\User\UserNameUtils
UserNameUtils service.
Definition: UserNameUtils.php:42
SCHEMA_COMPAT_NEW
const SCHEMA_COMPAT_NEW
Definition: Defines.php:281
TitleFormatter
A title formatter service for MediaWiki.
Definition: TitleFormatter.php:34
TitleFactory
Creates Title objects.
Definition: TitleFactory.php:33
Page\ContentModelChangeFactory
Definition: ContentModelChangeFactory.php:32
MediaWiki\Mail\IEmailer
Interface for sending emails.
Definition: IEmailer.php:34
Wikimedia
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
RepoGroup
Prioritized list of file repositories.
Definition: RepoGroup.php:31
ParserCache
Definition: ParserCache.php:32
ConfigFactory
Factory class to create Config objects.
Definition: ConfigFactory.php:31
MediaWiki\Preferences\DefaultPreferencesFactory
This is the default implementation of PreferencesFactory.
Definition: DefaultPreferencesFactory.php:64
MediaWiki\Storage\NameTableStoreFactory
Definition: NameTableStoreFactory.php:26
SearchEngineConfig
Configuration handling class for SearchEngine.
Definition: SearchEngineConfig.php:12
Revision\SlotRoleRegistry
A registry service for SlotRoleHandlers, used to define which slot roles are available on which page.
Definition: SlotRoleRegistry.php:48
$ext
if(!is_readable( $file)) $ext
Definition: router.php:48
MediaWiki\Config\ServiceOptions\get
get( $key)
Definition: ServiceOptions.php:84
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:44
PasswordFactory
Factory class for creating and checking Password objects.
Definition: PasswordFactory.php:30
wfWarn
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
Definition: GlobalFunctions.php:1073
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
MediaWiki\HookContainer\HookRunner
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Definition: HookRunner.php:570
$mime
$mime
Definition: router.php:60
JobRunner
Job queue runner utility methods.
Definition: JobRunner.php:41
MessageCache
Cache of messages that are defined by MediaWiki namespace pages or by hooks.
Definition: MessageCache.php:50
$IP
$IP
Definition: WebStart.php:49
Message\FORMAT_PLAIN
const FORMAT_PLAIN
Use message text as-is.
Definition: Message.php:163
PasswordReset
Helper class for the password reset functionality shared by the web UI and the API.
Definition: PasswordReset.php:43
MediaWiki\User\UserFactory
Creates User objects.
Definition: UserFactory.php:36
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:41
NoWriteWatchedItemStore
Definition: NoWriteWatchedItemStore.php:30
MediaWiki\Block\BlockRestrictionStore
Definition: BlockRestrictionStore.php:34
wfShellExec
wfShellExec( $cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
Definition: GlobalFunctions.php:2052