MediaWiki  1.34.0
ServiceWiring.php
Go to the documentation of this file.
1 <?php
47 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
84 use Wikimedia\ObjectFactory;
85 
86 return [
87  'ActorMigration' => function ( MediaWikiServices $services ) : ActorMigration {
88  return new ActorMigration( SCHEMA_COMPAT_NEW );
89  },
90 
91  'BadFileLookup' => function ( MediaWikiServices $services ) : BadFileLookup {
92  return new BadFileLookup(
93  function () {
94  return wfMessage( 'bad_image_list' )->inContentLanguage()->plain();
95  },
96  $services->getLocalServerObjectCache(),
97  $services->getRepoGroup(),
98  $services->getTitleParser()
99  );
100  },
101 
102  'BlobStore' => function ( MediaWikiServices $services ) : BlobStore {
103  return $services->getService( '_SqlBlobStore' );
104  },
105 
106  'BlobStoreFactory' => function ( MediaWikiServices $services ) : BlobStoreFactory {
107  return new BlobStoreFactory(
108  $services->getDBLoadBalancerFactory(),
109  $services->getExternalStoreAccess(),
110  $services->getMainWANObjectCache(),
111  new ServiceOptions( BlobStoreFactory::CONSTRUCTOR_OPTIONS,
112  $services->getMainConfig() )
113  );
114  },
115 
116  'BlockManager' => function ( MediaWikiServices $services ) : BlockManager {
117  return new BlockManager(
118  new ServiceOptions(
119  BlockManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
120  ),
121  $services->getPermissionManager(),
122  LoggerFactory::getInstance( 'BlockManager' )
123  );
124  },
125 
126  'BlockRestrictionStore' => function ( MediaWikiServices $services ) : BlockRestrictionStore {
127  return new BlockRestrictionStore(
128  $services->getDBLoadBalancer()
129  );
130  },
131 
132  'CommentStore' => function ( MediaWikiServices $services ) : CommentStore {
133  return new CommentStore(
134  $services->getContentLanguage(),
136  );
137  },
138 
139  'ConfigFactory' => function ( MediaWikiServices $services ) : ConfigFactory {
140  // Use the bootstrap config to initialize the ConfigFactory.
141  $registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' );
142  $factory = new ConfigFactory();
143 
144  foreach ( $registry as $name => $callback ) {
145  $factory->register( $name, $callback );
146  }
147  return $factory;
148  },
149 
150  'ConfigRepository' => function ( MediaWikiServices $services ) : ConfigRepository {
151  return new ConfigRepository( $services->getConfigFactory() );
152  },
153 
154  'ConfiguredReadOnlyMode' => function ( MediaWikiServices $services ) : ConfiguredReadOnlyMode {
155  $config = $services->getMainConfig();
156  return new ConfiguredReadOnlyMode(
157  $config->get( 'ReadOnly' ),
158  $config->get( 'ReadOnlyFile' )
159  );
160  },
161 
162  'ContentLanguage' => function ( MediaWikiServices $services ) : Language {
163  return Language::factory( $services->getMainConfig()->get( 'LanguageCode' ) );
164  },
165 
166  'CryptHKDF' => function ( MediaWikiServices $services ) : CryptHKDF {
167  $config = $services->getMainConfig();
168 
169  $secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
170  if ( !$secret ) {
171  throw new RuntimeException( "Cannot use MWCryptHKDF without a secret." );
172  }
173 
174  // In HKDF, the context can be known to the attacker, but this will
175  // keep simultaneous runs from producing the same output.
176  $context = [ microtime(), getmypid(), gethostname() ];
177 
178  // Setup salt cache. Use APC, or fallback to the main cache if it isn't setup
179  $cache = $services->getLocalServerObjectCache();
180  if ( $cache instanceof EmptyBagOStuff ) {
182  }
183 
184  return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm' ), $cache, $context );
185  },
186 
187  'DateFormatterFactory' => function () : DateFormatterFactory {
188  return new DateFormatterFactory;
189  },
190 
191  'DBLoadBalancer' => function ( MediaWikiServices $services ) : Wikimedia\Rdbms\ILoadBalancer {
192  // just return the default LB from the DBLoadBalancerFactory service
193  return $services->getDBLoadBalancerFactory()->getMainLB();
194  },
195 
196  'DBLoadBalancerFactory' =>
197  function ( MediaWikiServices $services ) : Wikimedia\Rdbms\LBFactory {
198  $mainConfig = $services->getMainConfig();
199 
201  $mainConfig->get( 'LBFactoryConf' ),
202  new ServiceOptions( MWLBFactory::APPLY_DEFAULT_CONFIG_OPTIONS, $mainConfig ),
203  $services->getConfiguredReadOnlyMode(),
204  $services->getLocalServerObjectCache(),
205  $services->getMainObjectStash(),
206  $services->getMainWANObjectCache()
207  );
208  $class = MWLBFactory::getLBFactoryClass( $lbConf );
209 
210  return new $class( $lbConf );
211  },
212 
213  'EventRelayerGroup' => function ( MediaWikiServices $services ) : EventRelayerGroup {
214  return new EventRelayerGroup( $services->getMainConfig()->get( 'EventRelayerConfig' ) );
215  },
216 
217  'ExternalStoreAccess' => function ( MediaWikiServices $services ) : ExternalStoreAccess {
218  return new ExternalStoreAccess(
219  $services->getExternalStoreFactory(),
220  LoggerFactory::getInstance( 'ExternalStore' )
221  );
222  },
223 
224  'ExternalStoreFactory' => function ( MediaWikiServices $services ) : ExternalStoreFactory {
225  $config = $services->getMainConfig();
226  $writeStores = $config->get( 'DefaultExternalStore' );
227 
228  return new ExternalStoreFactory(
229  $config->get( 'ExternalStores' ),
230  ( $writeStores !== false ) ? (array)$writeStores : [],
231  $services->getDBLoadBalancer()->getLocalDomainID(),
232  LoggerFactory::getInstance( 'ExternalStore' )
233  );
234  },
235 
236  'GenderCache' => function ( MediaWikiServices $services ) : GenderCache {
237  $nsInfo = $services->getNamespaceInfo();
238  // Database layer may be disabled, so processing without database connection
239  $dbLoadBalancer = $services->isServiceDisabled( 'DBLoadBalancer' )
240  ? null
241  : $services->getDBLoadBalancer();
242  return new GenderCache( $nsInfo, $dbLoadBalancer );
243  },
244 
245  'HttpRequestFactory' =>
246  function ( MediaWikiServices $services ) : HttpRequestFactory {
247  return new HttpRequestFactory();
248  },
249 
250  'InterwikiLookup' => function ( MediaWikiServices $services ) : InterwikiLookup {
251  $config = $services->getMainConfig();
252  return new ClassicInterwikiLookup(
253  $services->getContentLanguage(),
254  $services->getMainWANObjectCache(),
255  $config->get( 'InterwikiExpiry' ),
256  $config->get( 'InterwikiCache' ),
257  $config->get( 'InterwikiScopes' ),
258  $config->get( 'InterwikiFallbackSite' )
259  );
260  },
261 
262  'LanguageNameUtils' => function ( MediaWikiServices $services ) : LanguageNameUtils {
263  return new LanguageNameUtils( new ServiceOptions(
264  LanguageNameUtils::CONSTRUCTOR_OPTIONS,
265  $services->getMainConfig()
266  ) );
267  },
268 
269  'LinkCache' => function ( MediaWikiServices $services ) : LinkCache {
270  return new LinkCache(
271  $services->getTitleFormatter(),
272  $services->getMainWANObjectCache(),
273  $services->getNamespaceInfo()
274  );
275  },
276 
277  'LinkRenderer' => function ( MediaWikiServices $services ) : LinkRenderer {
278  if ( defined( 'MW_NO_SESSION' ) ) {
279  return $services->getLinkRendererFactory()->create();
280  } else {
281  // Normally information from the current request would not be passed in here;
282  // this is an exception. (See also the class documentation.)
283  return $services->getLinkRendererFactory()->createForUser(
285  );
286  }
287  },
288 
289  'LinkRendererFactory' => function ( MediaWikiServices $services ) : LinkRendererFactory {
290  return new LinkRendererFactory(
291  $services->getTitleFormatter(),
292  $services->getLinkCache(),
293  $services->getNamespaceInfo()
294  );
295  },
296 
297  'LocalisationCache' => function ( MediaWikiServices $services ) : LocalisationCache {
298  $conf = $services->getMainConfig()->get( 'LocalisationCacheConf' );
299 
300  $logger = LoggerFactory::getInstance( 'localisation' );
301 
303  $conf, $services->getMainConfig()->get( 'CacheDirectory' ) );
304  $logger->debug( 'LocalisationCache: using store ' . get_class( $store ) );
305 
306  return new $conf['class'](
307  new ServiceOptions(
308  LocalisationCache::CONSTRUCTOR_OPTIONS,
309  // Two of the options are stored in $wgLocalisationCacheConf
310  $conf,
311  // In case someone set that config variable and didn't reset all keys, set defaults.
312  [
313  'forceRecache' => false,
314  'manualRecache' => false,
315  ],
316  // Some other options come from config itself
317  $services->getMainConfig()
318  ),
319  $store,
320  $logger,
321  [ function () use ( $services ) {
322  // NOTE: Make sure we use the same cache object that is assigned in the
323  // constructor of the MessageBlobStore class used by ResourceLoader.
324  // T231866: Avoid circular dependency via ResourceLoader.
325  MessageBlobStore::clearGlobalCacheEntry( $services->getMainWANObjectCache() );
326  } ],
327  $services->getLanguageNameUtils()
328  );
329  },
330 
331  'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
332  $config = $services->getMainConfig();
334 
335  return ObjectCache::newFromParams( $config->get( 'ObjectCaches' )[$cacheId] );
336  },
337 
338  'LockManagerGroupFactory' => function ( MediaWikiServices $services ) : LockManagerGroupFactory {
339  return new LockManagerGroupFactory(
341  $services->getMainConfig()->get( 'LockManagers' ),
342  $services->getDBLoadBalancerFactory()
343  );
344  },
345 
346  'MagicWordFactory' => function ( MediaWikiServices $services ) : MagicWordFactory {
347  return new MagicWordFactory( $services->getContentLanguage() );
348  },
349 
350  'MainConfig' => function ( MediaWikiServices $services ) : Config {
351  // Use the 'main' config from the ConfigFactory service.
352  return $services->getConfigFactory()->makeConfig( 'main' );
353  },
354 
355  'MainObjectStash' => function ( MediaWikiServices $services ) : BagOStuff {
356  $mainConfig = $services->getMainConfig();
357 
358  $id = $mainConfig->get( 'MainStash' );
359  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$id] ) ) {
360  throw new UnexpectedValueException(
361  "Cache type \"$id\" is not present in \$wgObjectCaches." );
362  }
363 
364  $params = $mainConfig->get( 'ObjectCaches' )[$id];
365  $logger = $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] ?? 'objectcache' );
366 
367  $store = ObjectCache::newFromParams( $params );
368  $logger->debug( 'MainObjectStash using store {class}', [
369  'class' => get_class( $store )
370  ] );
371 
372  return $store;
373  },
374 
375  'MainWANObjectCache' => function ( MediaWikiServices $services ) : WANObjectCache {
376  $mainConfig = $services->getMainConfig();
377 
378  $id = $mainConfig->get( 'MainWANCache' );
379  if ( !isset( $mainConfig->get( 'WANObjectCaches' )[$id] ) ) {
380  throw new UnexpectedValueException(
381  "WAN cache type \"$id\" is not present in \$wgWANObjectCaches." );
382  }
383 
384  $params = $mainConfig->get( 'WANObjectCaches' )[$id];
385 
386  $logger = LoggerFactory::getInstance( $params['loggroup'] ?? 'objectcache' );
387 
388  $objectCacheId = $params['cacheId'];
389  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$objectCacheId] ) ) {
390  throw new UnexpectedValueException(
391  "Cache type \"$objectCacheId\" is not present in \$wgObjectCaches." );
392  }
393  $storeParams = $mainConfig->get( 'ObjectCaches' )[$objectCacheId];
394  $store = ObjectCache::newFromParams( $storeParams );
395  $logger->debug( 'MainWANObjectCache using store {class}', [
396  'class' => get_class( $store )
397  ] );
398 
399  $params['logger'] = $logger;
400  $params['cache'] = $store;
401  $params['secret'] = $params['secret'] ?? $mainConfig->get( 'SecretKey' );
402  if ( !$mainConfig->get( 'CommandLineMode' ) ) {
403  // Send the statsd data post-send on HTTP requests; avoid in CLI mode (T181385)
404  $params['stats'] = $services->getStatsdDataFactory();
405  // Let pre-emptive refreshes happen post-send on HTTP requests
406  $params['asyncHandler'] = [ DeferredUpdates::class, 'addCallableUpdate' ];
407  }
408 
409  $class = $params['class'];
410  $instance = new $class( $params );
411 
412  '@phan-var WANObjectCache $instance';
413  return $instance;
414  },
415 
416  'MediaHandlerFactory' => function ( MediaWikiServices $services ) : MediaHandlerFactory {
417  return new MediaHandlerFactory(
418  $services->getMainConfig()->get( 'MediaHandlers' )
419  );
420  },
421 
422  'MessageCache' => function ( MediaWikiServices $services ) : MessageCache {
423  $mainConfig = $services->getMainConfig();
424  $clusterCache = ObjectCache::getInstance( $mainConfig->get( 'MessageCacheType' ) );
425  $srvCache = $mainConfig->get( 'UseLocalMessageCache' )
426  ? $services->getLocalServerObjectCache()
427  : new EmptyBagOStuff();
428 
429  // TODO: Inject this into MessageCache.
430  $logger = LoggerFactory::getInstance( 'MessageCache' );
431  $logger->debug( 'MessageCache using store {class}', [
432  'class' => get_class( $clusterCache )
433  ] );
434 
435  return new MessageCache(
436  $services->getMainWANObjectCache(),
437  $clusterCache,
438  $srvCache,
439  $mainConfig->get( 'UseDatabaseMessages' ),
440  $services->getContentLanguage()
441  );
442  },
443 
444  'MessageFormatterFactory' =>
445  function ( MediaWikiServices $services ) : IMessageFormatterFactory {
446  // @phan-suppress-next-line PhanAccessMethodInternal
447  return new MessageFormatterFactory();
448  },
449 
450  'MimeAnalyzer' => function ( MediaWikiServices $services ) : MimeAnalyzer {
451  $logger = LoggerFactory::getInstance( 'Mime' );
452  $mainConfig = $services->getMainConfig();
453  $params = [
454  'typeFile' => $mainConfig->get( 'MimeTypeFile' ),
455  'infoFile' => $mainConfig->get( 'MimeInfoFile' ),
456  'xmlTypes' => $mainConfig->get( 'XMLMimeTypes' ),
457  'guessCallback' =>
458  function ( $mimeAnalyzer, &$head, &$tail, $file, &$mime ) use ( $logger ) {
459  // Also test DjVu
460  $deja = new DjVuImage( $file );
461  if ( $deja->isValid() ) {
462  $logger->info( "Detected $file as image/vnd.djvu\n" );
463  $mime = 'image/vnd.djvu';
464 
465  return;
466  }
467  // Some strings by reference for performance - assuming well-behaved hooks
468  Hooks::run(
469  'MimeMagicGuessFromContent',
470  [ $mimeAnalyzer, &$head, &$tail, $file, &$mime ]
471  );
472  },
473  'extCallback' => function ( $mimeAnalyzer, $ext, &$mime ) {
474  // Media handling extensions can improve the MIME detected
475  Hooks::run( 'MimeMagicImproveFromExtension', [ $mimeAnalyzer, $ext, &$mime ] );
476  },
477  'initCallback' => function ( $mimeAnalyzer ) {
478  // Allow media handling extensions adding MIME-types and MIME-info
479  Hooks::run( 'MimeMagicInit', [ $mimeAnalyzer ] );
480  },
481  'logger' => $logger
482  ];
483 
484  if ( $params['infoFile'] === 'includes/mime.info' ) {
485  $params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
486  }
487 
488  if ( $params['typeFile'] === 'includes/mime.types' ) {
489  $params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
490  }
491 
492  $detectorCmd = $mainConfig->get( 'MimeDetectorCommand' );
493  if ( $detectorCmd ) {
494  $factory = $services->getShellCommandFactory();
495  $params['detectCallback'] = function ( $file ) use ( $detectorCmd, $factory ) {
496  $result = $factory->create()
497  // $wgMimeDetectorCommand can contain commands with parameters
498  ->unsafeParams( $detectorCmd )
499  ->params( $file )
500  ->execute();
501  return $result->getStdout();
502  };
503  }
504 
505  return new MimeAnalyzer( $params );
506  },
507 
508  'MovePageFactory' => function ( MediaWikiServices $services ) : MovePageFactory {
509  return new MovePageFactory(
510  new ServiceOptions( MovePageFactory::$constructorOptions, $services->getMainConfig() ),
511  $services->getDBLoadBalancer(),
512  $services->getNamespaceInfo(),
513  $services->getWatchedItemStore(),
514  $services->getPermissionManager(),
515  $services->getRepoGroup()
516  );
517  },
518 
519  'NamespaceInfo' => function ( MediaWikiServices $services ) : NamespaceInfo {
521  $services->getMainConfig() ) );
522  },
523 
524  'NameTableStoreFactory' => function ( MediaWikiServices $services ) : NameTableStoreFactory {
525  return new NameTableStoreFactory(
526  $services->getDBLoadBalancerFactory(),
527  $services->getMainWANObjectCache(),
528  LoggerFactory::getInstance( 'NameTableSqlStore' )
529  );
530  },
531 
532  'ObjectFactory' => function ( MediaWikiServices $services ) : ObjectFactory {
533  return new ObjectFactory( $services );
534  },
535 
536  'OldRevisionImporter' => function ( MediaWikiServices $services ) : OldRevisionImporter {
538  true,
539  LoggerFactory::getInstance( 'OldRevisionImporter' ),
540  $services->getDBLoadBalancer()
541  );
542  },
543 
544  'PageEditStash' => function ( MediaWikiServices $services ) : PageEditStash {
545  $config = $services->getMainConfig();
546 
547  return new PageEditStash(
549  $services->getDBLoadBalancer(),
550  LoggerFactory::getInstance( 'StashEdit' ),
551  $services->getStatsdDataFactory(),
552  defined( 'MEDIAWIKI_JOB_RUNNER' ) || $config->get( 'CommandLineMode' )
553  ? PageEditStash::INITIATOR_JOB_OR_CLI
554  : PageEditStash::INITIATOR_USER
555  );
556  },
557 
558  'Parser' => function ( MediaWikiServices $services ) : Parser {
559  return $services->getParserFactory()->create();
560  },
561 
562  'ParserCache' => function ( MediaWikiServices $services ) : ParserCache {
563  $config = $services->getMainConfig();
564  $cache = ObjectCache::getInstance( $config->get( 'ParserCacheType' ) );
565  wfDebugLog( 'caches', 'parser: ' . get_class( $cache ) );
566 
567  return new ParserCache(
568  $cache,
569  $config->get( 'CacheEpoch' )
570  );
571  },
572 
573  'ParserFactory' => function ( MediaWikiServices $services ) : ParserFactory {
574  $options = new ServiceOptions( Parser::$constructorOptions,
575  // 'class' and 'preprocessorClass'
576  $services->getMainConfig()->get( 'ParserConf' ),
577  // Make sure to have defaults in case someone overrode ParserConf with something silly
578  [ 'class' => Parser::class, 'preprocessorClass' => Preprocessor_Hash::class ],
579  // Plus a buch of actual config options
580  $services->getMainConfig()
581  );
582 
583  return new ParserFactory(
584  $options,
585  $services->getMagicWordFactory(),
586  $services->getContentLanguage(),
587  wfUrlProtocols(),
588  $services->getSpecialPageFactory(),
589  $services->getLinkRendererFactory(),
590  $services->getNamespaceInfo(),
591  LoggerFactory::getInstance( 'Parser' )
592  );
593  },
594 
595  'PasswordFactory' => function ( MediaWikiServices $services ) : PasswordFactory {
596  $config = $services->getMainConfig();
597  return new PasswordFactory(
598  $config->get( 'PasswordConfig' ),
599  $config->get( 'PasswordDefault' )
600  );
601  },
602 
603  'PasswordReset' => function ( MediaWikiServices $services ) : PasswordReset {
604  $options = new ServiceOptions( PasswordReset::CONSTRUCTOR_OPTIONS, $services->getMainConfig() );
605  return new PasswordReset(
606  $options,
607  AuthManager::singleton(),
608  $services->getPermissionManager(),
609  $services->getDBLoadBalancer(),
610  LoggerFactory::getInstance( 'authentication' )
611  );
612  },
613 
614  'PerDbNameStatsdDataFactory' =>
615  function ( MediaWikiServices $services ) : StatsdDataFactoryInterface {
616  $config = $services->getMainConfig();
617  $wiki = $config->get( 'DBname' );
619  $services->getStatsdDataFactory(),
620  $wiki
621  );
622  },
623 
624  'PermissionManager' => function ( MediaWikiServices $services ) : PermissionManager {
625  return new PermissionManager(
626  new ServiceOptions(
627  PermissionManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
628  ),
629  $services->getSpecialPageFactory(),
630  $services->getRevisionLookup(),
631  $services->getNamespaceInfo()
632  );
633  },
634 
635  'PreferencesFactory' => function ( MediaWikiServices $services ) : PreferencesFactory {
636  $factory = new DefaultPreferencesFactory(
637  new ServiceOptions(
638  DefaultPreferencesFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
639  $services->getContentLanguage(),
640  AuthManager::singleton(),
641  $services->getLinkRendererFactory()->create(),
642  $services->getNamespaceInfo(),
643  $services->getPermissionManager()
644  );
645  $factory->setLogger( LoggerFactory::getInstance( 'preferences' ) );
646 
647  return $factory;
648  },
649 
650  'ProxyLookup' => function ( MediaWikiServices $services ) : ProxyLookup {
651  $mainConfig = $services->getMainConfig();
652  return new ProxyLookup(
653  $mainConfig->get( 'CdnServers' ),
654  $mainConfig->get( 'CdnServersNoPurge' )
655  );
656  },
657 
658  'ReadOnlyMode' => function ( MediaWikiServices $services ) : ReadOnlyMode {
659  return new ReadOnlyMode(
660  $services->getConfiguredReadOnlyMode(),
661  $services->getDBLoadBalancer()
662  );
663  },
664 
665  'RepoGroup' => function ( MediaWikiServices $services ) : RepoGroup {
666  $config = $services->getMainConfig();
667  return new RepoGroup(
668  $config->get( 'LocalFileRepo' ),
669  $config->get( 'ForeignFileRepos' ),
670  $services->getMainWANObjectCache()
671  );
672  },
673 
674  'ResourceLoader' => function ( MediaWikiServices $services ) : ResourceLoader {
675  // @todo This should not take a Config object, but it's not so easy to remove because it
676  // exposes it in a getter, which is actually used.
677  global $IP;
678  $config = $services->getMainConfig();
679 
680  $rl = new ResourceLoader(
681  $config,
682  LoggerFactory::getInstance( 'resourceloader' )
683  );
684 
685  $rl->addSource( $config->get( 'ResourceLoaderSources' ) );
686 
687  // Core modules, then extension/skin modules
688  $rl->register( include "$IP/resources/Resources.php" );
689  $rl->register( $config->get( 'ResourceModules' ) );
690  Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
691 
692  if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
693  $rl->registerTestModules();
694  }
695 
696  return $rl;
697  },
698 
699  'RevisionFactory' => function ( MediaWikiServices $services ) : RevisionFactory {
700  return $services->getRevisionStore();
701  },
702 
703  'RevisionLookup' => function ( MediaWikiServices $services ) : RevisionLookup {
704  return $services->getRevisionStore();
705  },
706 
707  'RevisionRenderer' => function ( MediaWikiServices $services ) : RevisionRenderer {
708  $renderer = new RevisionRenderer(
709  $services->getDBLoadBalancer(),
710  $services->getSlotRoleRegistry()
711  );
712 
713  $renderer->setLogger( LoggerFactory::getInstance( 'SaveParse' ) );
714  return $renderer;
715  },
716 
717  'RevisionStore' => function ( MediaWikiServices $services ) : RevisionStore {
718  return $services->getRevisionStoreFactory()->getRevisionStore();
719  },
720 
721  'RevisionStoreFactory' => function ( MediaWikiServices $services ) : RevisionStoreFactory {
722  $config = $services->getMainConfig();
723  $store = new RevisionStoreFactory(
724  $services->getDBLoadBalancerFactory(),
725  $services->getBlobStoreFactory(),
726  $services->getNameTableStoreFactory(),
727  $services->getSlotRoleRegistry(),
728  $services->getMainWANObjectCache(),
729  $services->getCommentStore(),
730  $services->getActorMigration(),
731  $config->get( 'MultiContentRevisionSchemaMigrationStage' ),
732  LoggerFactory::getInstance( 'RevisionStore' ),
733  $config->get( 'ContentHandlerUseDB' )
734  );
735 
736  return $store;
737  },
738 
739  'SearchEngineConfig' => function ( MediaWikiServices $services ) : SearchEngineConfig {
740  // @todo This should not take a Config object, but it's not so easy to remove because it
741  // exposes it in a getter, which is actually used.
742  return new SearchEngineConfig( $services->getMainConfig(),
743  $services->getContentLanguage() );
744  },
745 
746  'SearchEngineFactory' => function ( MediaWikiServices $services ) : SearchEngineFactory {
747  return new SearchEngineFactory( $services->getSearchEngineConfig() );
748  },
749 
750  'ShellCommandFactory' => function ( MediaWikiServices $services ) : CommandFactory {
751  $config = $services->getMainConfig();
752 
753  $limits = [
754  'time' => $config->get( 'MaxShellTime' ),
755  'walltime' => $config->get( 'MaxShellWallClockTime' ),
756  'memory' => $config->get( 'MaxShellMemory' ),
757  'filesize' => $config->get( 'MaxShellFileSize' ),
758  ];
759  $cgroup = $config->get( 'ShellCgroup' );
760  $restrictionMethod = $config->get( 'ShellRestrictionMethod' );
761 
762  $factory = new CommandFactory( $limits, $cgroup, $restrictionMethod );
763  $factory->setLogger( LoggerFactory::getInstance( 'exec' ) );
764  $factory->logStderr();
765 
766  return $factory;
767  },
768 
769  'SiteLookup' => function ( MediaWikiServices $services ) : SiteLookup {
770  // Use SiteStore as the SiteLookup as well. This was originally separated
771  // to allow for a cacheable read-only interface (using FileBasedSiteLookup),
772  // but this was never used. SiteStore has caching (see below).
773  return $services->getSiteStore();
774  },
775 
776  'SiteStore' => function ( MediaWikiServices $services ) : SiteStore {
777  $rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() );
778 
779  $cache = $services->getLocalServerObjectCache();
780  if ( $cache instanceof EmptyBagOStuff ) {
782  }
783 
784  return new CachingSiteStore( $rawSiteStore, $cache );
785  },
786 
787  'SkinFactory' => function ( MediaWikiServices $services ) : SkinFactory {
788  $factory = new SkinFactory();
789 
790  $names = $services->getMainConfig()->get( 'ValidSkinNames' );
791 
792  foreach ( $names as $name => $skin ) {
793  $factory->register( $name, $skin, function () use ( $name, $skin ) {
794  $class = "Skin$skin";
795  return new $class( $name );
796  } );
797  }
798  // Register a hidden "fallback" skin
799  $factory->register( 'fallback', 'Fallback', function () {
800  return new SkinFallback;
801  } );
802  // Register a hidden skin for api output
803  $factory->register( 'apioutput', 'ApiOutput', function () {
804  return new SkinApi;
805  } );
806 
807  return $factory;
808  },
809 
810  'SlotRoleRegistry' => function ( MediaWikiServices $services ) : SlotRoleRegistry {
811  $config = $services->getMainConfig();
812 
813  $registry = new SlotRoleRegistry(
814  $services->getNameTableStoreFactory()->getSlotRoles()
815  );
816 
817  $registry->defineRole( 'main', function () use ( $config ) {
818  return new MainSlotRoleHandler(
819  $config->get( 'NamespaceContentModels' )
820  );
821  } );
822 
823  return $registry;
824  },
825 
826  'SpecialPageFactory' => function ( MediaWikiServices $services ) : SpecialPageFactory {
827  return new SpecialPageFactory(
828  new ServiceOptions(
829  SpecialPageFactory::$constructorOptions, $services->getMainConfig() ),
830  $services->getContentLanguage(),
831  $services->getObjectFactory()
832  );
833  },
834 
835  'StatsdDataFactory' => function ( MediaWikiServices $services ) : IBufferingStatsdDataFactory {
836  return new BufferingStatsdDataFactory(
837  rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' )
838  );
839  },
840 
841  'TempFSFileFactory' => function ( MediaWikiServices $services ) : TempFSFileFactory {
842  return new TempFSFileFactory( $services->getMainConfig()->get( 'TmpDirectory' ) );
843  },
844 
845  'TitleFormatter' => function ( MediaWikiServices $services ) : TitleFormatter {
846  return $services->getService( '_MediaWikiTitleCodec' );
847  },
848 
849  'TitleParser' => function ( MediaWikiServices $services ) : TitleParser {
850  return $services->getService( '_MediaWikiTitleCodec' );
851  },
852 
853  'UploadRevisionImporter' => function ( MediaWikiServices $services ) : UploadRevisionImporter {
855  $services->getMainConfig()->get( 'EnableUploads' ),
856  LoggerFactory::getInstance( 'UploadRevisionImporter' )
857  );
858  },
859 
860  'VirtualRESTServiceClient' =>
861  function ( MediaWikiServices $services ) : VirtualRESTServiceClient {
862  $config = $services->getMainConfig()->get( 'VirtualRestConfig' );
863 
864  $vrsClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) );
865  foreach ( $config['paths'] as $prefix => $serviceConfig ) {
866  $class = $serviceConfig['class'];
867  // Merge in the global defaults
868  $constructArg = $serviceConfig['options'] ?? [];
869  $constructArg += $config['global'];
870  // Make the VRS service available at the mount point
871  $vrsClient->mount( $prefix, [ 'class' => $class, 'config' => $constructArg ] );
872  }
873 
874  return $vrsClient;
875  },
876 
877  'WatchedItemQueryService' =>
878  function ( MediaWikiServices $services ) : WatchedItemQueryService {
879  return new WatchedItemQueryService(
880  $services->getDBLoadBalancer(),
881  $services->getCommentStore(),
882  $services->getActorMigration(),
883  $services->getWatchedItemStore(),
884  $services->getPermissionManager()
885  );
886  },
887 
888  'WatchedItemStore' => function ( MediaWikiServices $services ) : WatchedItemStore {
889  $store = new WatchedItemStore(
890  $services->getDBLoadBalancerFactory(),
892  $services->getMainObjectStash(),
893  new HashBagOStuff( [ 'maxKeys' => 100 ] ),
894  $services->getReadOnlyMode(),
895  $services->getMainConfig()->get( 'UpdateRowsPerQuery' ),
896  $services->getNamespaceInfo(),
897  $services->getRevisionLookup()
898  );
899  $store->setStatsdDataFactory( $services->getStatsdDataFactory() );
900 
901  if ( $services->getMainConfig()->get( 'ReadOnlyWatchedItemStore' ) ) {
902  $store = new NoWriteWatchedItemStore( $store );
903  }
904 
905  return $store;
906  },
907 
908  'WikiRevisionOldRevisionImporterNoUpdates' =>
909  function ( MediaWikiServices $services ) : ImportableOldRevisionImporter {
911  false,
912  LoggerFactory::getInstance( 'OldRevisionImporter' ),
913  $services->getDBLoadBalancer()
914  );
915  },
916 
917  '_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) : MediaWikiTitleCodec {
918  return new MediaWikiTitleCodec(
919  $services->getContentLanguage(),
920  $services->getGenderCache(),
921  $services->getMainConfig()->get( 'LocalInterwikis' ),
922  $services->getInterwikiLookup(),
923  $services->getNamespaceInfo()
924  );
925  },
926 
927  '_SqlBlobStore' => function ( MediaWikiServices $services ) : SqlBlobStore {
928  // @phan-suppress-next-line PhanAccessMethodInternal
929  return $services->getBlobStoreFactory()->newSqlBlobStore();
930  },
931 
933  // NOTE: When adding a service here, don't forget to add a getter function
934  // in the MediaWikiServices class. The convenience getter should just call
935  // $this->getService( 'FooBarService' ).
937 
938 ];
PasswordReset\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: PasswordReset.php:63
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
MultiHttpClient
Class to handle multiple HTTP requests.
Definition: MultiHttpClient.php:52
MediaWikiTitleCodec
A codec for MediaWiki page titles.
Definition: MediaWikiTitleCodec.php:38
WikiMap\getCurrentWikiDbDomain
static getCurrentWikiDbDomain()
Definition: WikiMap.php:292
UploadRevisionImporter
Definition: UploadRevisionImporter.php:6
ObjectCache\getLocalClusterInstance
static getLocalClusterInstance()
Get the main cluster-local cache object.
Definition: ObjectCache.php:342
MessageBlobStore\clearGlobalCacheEntry
static clearGlobalCacheEntry(WANObjectCache $cache)
Invalidate cache keys for all known modules.
Definition: MessageBlobStore.php:188
SkinApi
SkinTemplate class for API output.
Definition: SkinApi.php:31
MagicWordFactory
A factory that stores information about MagicWords, and creates them on demand with caching.
Definition: MagicWordFactory.php:34
HashBagOStuff
Simple store for keeping values in an associative array for the current process.
Definition: HashBagOStuff.php:31
ImportableOldRevisionImporter
Definition: ImportableOldRevisionImporter.php:9
MediaWiki\Interwiki\ClassicInterwikiLookup
InterwikiLookup implementing the "classic" interwiki storage (hardcoded up to MW 1....
Definition: ClassicInterwikiLookup.php:47
EmptyBagOStuff
A BagOStuff object with no objects in it.
Definition: EmptyBagOStuff.php:29
Revision\MainSlotRoleHandler
A SlotRoleHandler for the main slot.
Definition: MainSlotRoleHandler.php:41
MediaWiki\Block\BlockManager
A service class for checking blocks.
Definition: BlockManager.php:44
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
MediaWiki\BadFileLookup
Definition: BadFileLookup.php:12
MimeAnalyzer
Implements functions related to MIME types such as detection and mapping to file extension.
Definition: MimeAnalyzer.php:31
Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:79
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:51
ObjectCache\detectLocalServerCache
static detectLocalServerCache()
Detects which local server cache library is present and returns a configuration for it.
Definition: ObjectCache.php:362
MediaWiki\Http\HttpRequestFactory
Factory creating MWHttpRequest objects.
Definition: HttpRequestFactory.php:35
true
return true
Definition: router.php:92
MediaWiki\Linker\LinkRenderer
Class that generates HTML links for pages.
Definition: LinkRenderer.php:41
getUser
getUser()
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:11
MIGRATION_NEW
const MIGRATION_NEW
Definition: Defines.php:298
GenderCache
Caches user genders when needed to use correct namespace aliases.
Definition: GenderCache.php:33
ConfiguredReadOnlyMode
A read-only mode service which does not depend on LoadBalancer.
Definition: ConfiguredReadOnlyMode.php:9
CommentStore
CommentStore handles storage of comments (edit summaries, log reasons, etc) in the database.
Definition: CommentStore.php:31
$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:63
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1264
MediaWiki\Linker\LinkRendererFactory
Factory to create LinkRender objects.
Definition: LinkRendererFactory.php:32
SearchEngineFactory
Factory class for SearchEngine.
Definition: SearchEngineFactory.php:11
Revision\RevisionFactory
Service for constructing revision objects.
Definition: RevisionFactory.php:37
ActorMigration
This class handles the logic for the actor table migration.
Definition: ActorMigration.php:38
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:1007
SiteLookup
Definition: SiteLookup.php:28
Revision\RevisionLookup
Service for looking up page revisions.
Definition: RevisionLookup.php:38
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\Languages\LanguageNameUtils
Definition: LanguageNameUtils.php:45
SiteStore
Definition: SiteStore.php:29
Config
Interface for configuration instances.
Definition: Config.php:28
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:354
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:44
DateFormatterFactory
Definition: DateFormatterFactory.php:3
LocalisationCache\getStoreFromConf
static getStoreFromConf(array $conf, $fallbackCacheDir)
Return a suitable LCStore as specified by the given configuration.
Definition: LocalisationCache.php:202
Revision\SlotRoleRegistry\defineRole
defineRole( $role, callable $instantiator)
Defines a slot role.
Definition: SlotRoleRegistry.php:84
CryptHKDF
Definition: CryptHKDF.php:33
MWLBFactory\applyDefaultConfig
static applyDefaultConfig(array $lbConf, ServiceOptions $options, ConfiguredReadOnlyMode $readOnlyMode, BagOStuff $srvCache, BagOStuff $mainStash, WANObjectCache $wanCache)
Definition: MWLBFactory.php:72
WatchedItemQueryService
Definition: WatchedItemQueryService.php:21
ProxyLookup
Definition: ProxyLookup.php:27
VirtualRESTServiceClient
Virtual HTTP service client loosely styled after a Virtual File System.
Definition: VirtualRESTServiceClient.php:45
MediaWiki\Interwiki\InterwikiLookup
Service interface for looking up Interwiki records.
Definition: InterwikiLookup.php:32
$IP
$IP
Definition: update.php:3
SkinFallback
SkinTemplate class for the fallback skin.
Definition: SkinFallback.php:12
ObjectCache\getInstance
static getInstance( $id)
Get a cached instance of the specified type of cache object.
Definition: ObjectCache.php:80
BufferingStatsdDataFactory
A factory for application metric data.
Definition: BufferingStatsdDataFactory.php:35
MWLBFactory\getLBFactoryClass
static getLBFactoryClass(array $config)
Returns the LBFactory class to use and the load balancer configuration.
Definition: MWLBFactory.php:327
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\$constructorOptions
static array $constructorOptions
TODO Make this const when HHVM support is dropped (T192166)
Definition: NamespaceInfo.php:89
MediaWiki\Page\MovePageFactory
Definition: MovePageFactory.php:36
MediaWiki\FileBackend\FSFile\TempFSFileFactory
Definition: TempFSFileFactory.php:10
MediaWiki\Special\SpecialPageFactory
Factory for handling the special page list and generating SpecialPage objects.
Definition: SpecialPageFactory.php:64
wfUrlProtocols
wfUrlProtocols( $includeProtocolRelative=true)
Returns a regular expression of url protocols.
Definition: GlobalFunctions.php:719
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:47
ParserFactory
Definition: ParserFactory.php:33
PrefixingStatsdDataFactoryProxy
Proxy to prefix metric keys sent to a StatsdDataFactoryInterface.
Definition: PrefixingStatsdDataFactoryProxy.php:29
SkinFactory
Factory class to create Skin objects.
Definition: SkinFactory.php:29
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:52
WANObjectCache
Multi-datacenter aware caching interface.
Definition: WANObjectCache.php:116
LocalisationCache
Class for caching the contents of localisation files, Messages*.php and *.i18n.php.
Definition: LocalisationCache.php:41
MediaWiki\Config\ConfigRepository
Object which holds currently registered configuration options.
Definition: ConfigRepository.php:33
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:431
Revision\RevisionStoreFactory
Factory service for RevisionStore instances.
Definition: RevisionStoreFactory.php:49
MediaWiki\Auth\AuthManager
This serves as the entry point to the authentication system.
Definition: AuthManager.php:85
MediaWiki\Storage\BlobStore
Service for loading and storing data blobs.
Definition: BlobStore.php:35
$context
$context
Definition: load.php:45
WatchedItemStore
Storage layer class for WatchedItems.
Definition: WatchedItemStore.php:21
IBufferingStatsdDataFactory
MediaWiki adaptation of StatsdDataFactory that provides buffering functionality.
Definition: IBufferingStatsdDataFactory.php:11
Wikimedia\Message\IMessageFormatterFactory
A simple factory providing a message formatter for a given language code.
Definition: IMessageFormatterFactory.php:10
ImportableUploadRevisionImporter
Definition: ImportableUploadRevisionImporter.php:9
OldRevisionImporter
Definition: OldRevisionImporter.php:6
JobQueueGroup\singleton
static singleton( $domain=false)
Definition: JobQueueGroup.php:70
$cache
$cache
Definition: mcc.php:33
SCHEMA_COMPAT_NEW
const SCHEMA_COMPAT_NEW
Definition: Defines.php:271
TitleFormatter
A title formatter service for MediaWiki.
Definition: TitleFormatter.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:30
ConfigFactory
Factory class to create Config objects.
Definition: ConfigFactory.php:31
WatchedItemStore\setStatsdDataFactory
setStatsdDataFactory(StatsdDataFactoryInterface $stats)
Definition: WatchedItemStore.php:130
MediaWiki\Preferences\DefaultPreferencesFactory
This is the default implementation of PreferencesFactory.
Definition: DefaultPreferencesFactory.php:62
MediaWiki\Storage\NameTableStoreFactory
Definition: NameTableStoreFactory.php:26
SearchEngineConfig
Configuration handling class for SearchEngine.
Definition: SearchEngineConfig.php:9
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
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:217
ObjectCache\newFromParams
static newFromParams( $params)
Create a new cache object from parameters.
Definition: ObjectCache.php:161
PasswordFactory
Factory class for creating and checking Password objects.
Definition: PasswordFactory.php:28
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:33
MediumSpecificBagOStuff\get
get( $key, $flags=0)
Get an item with the given key.
Definition: MediumSpecificBagOStuff.php:109
MessageCache
Cache of messages that are defined by MediaWiki namespace pages or by hooks.
Definition: MessageCache.php:40
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
Revision\RevisionRenderer\setLogger
setLogger(LoggerInterface $saveParseLogger)
Definition: RevisionRenderer.php:78
PasswordReset
Helper class for the password reset functionality shared by the web UI and the API.
Definition: PasswordReset.php:41
Language
Internationalisation code.
Definition: Language.php:37
NoWriteWatchedItemStore
Definition: NoWriteWatchedItemStore.php:30
MediaWiki\Block\BlockRestrictionStore
Definition: BlockRestrictionStore.php:34