MediaWiki  master
ServiceWiring.php
Go to the documentation of this file.
1 <?php
70 
71 return [
72  'ActorMigration' => function ( MediaWikiServices $services ) : ActorMigration {
73  return new ActorMigration(
74  $services->getMainConfig()->get( 'ActorTableSchemaMigrationStage' )
75  );
76  },
77 
78  'BlobStore' => function ( MediaWikiServices $services ) : BlobStore {
79  return $services->getService( '_SqlBlobStore' );
80  },
81 
82  'BlobStoreFactory' => function ( MediaWikiServices $services ) : BlobStoreFactory {
83  return new BlobStoreFactory(
84  $services->getDBLoadBalancerFactory(),
85  $services->getMainWANObjectCache(),
86  new ServiceOptions( BlobStoreFactory::$constructorOptions,
87  $services->getMainConfig() ),
88  $services->getContentLanguage()
89  );
90  },
91 
92  'BlockManager' => function ( MediaWikiServices $services ) : BlockManager {
93  $config = $services->getMainConfig();
95  return new BlockManager(
96  $context->getUser(),
97  $context->getRequest(),
98  $config->get( 'ApplyIpBlocksToXff' ),
99  $config->get( 'CookieSetOnAutoblock' ),
100  $config->get( 'CookieSetOnIpBlock' ),
101  $config->get( 'DnsBlacklistUrls' ),
102  $config->get( 'EnableDnsBlacklist' ),
103  $config->get( 'ProxyList' ),
104  $config->get( 'ProxyWhitelist' ),
105  $config->get( 'SecretKey' ),
106  $config->get( 'SoftBlockRanges' )
107  );
108  },
109 
110  'BlockRestrictionStore' => function ( MediaWikiServices $services ) : BlockRestrictionStore {
111  return new BlockRestrictionStore(
112  $services->getDBLoadBalancer()
113  );
114  },
115 
116  'CommentStore' => function ( MediaWikiServices $services ) : CommentStore {
117  return new CommentStore(
118  $services->getContentLanguage(),
120  );
121  },
122 
123  'ConfigFactory' => function ( MediaWikiServices $services ) : ConfigFactory {
124  // Use the bootstrap config to initialize the ConfigFactory.
125  $registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' );
126  $factory = new ConfigFactory();
127 
128  foreach ( $registry as $name => $callback ) {
129  $factory->register( $name, $callback );
130  }
131  return $factory;
132  },
133 
134  'ConfigRepository' => function ( MediaWikiServices $services ) : ConfigRepository {
135  return new ConfigRepository( $services->getConfigFactory() );
136  },
137 
138  'ConfiguredReadOnlyMode' => function ( MediaWikiServices $services ) : ConfiguredReadOnlyMode {
139  $config = $services->getMainConfig();
140  return new ConfiguredReadOnlyMode(
141  $config->get( 'ReadOnly' ),
142  $config->get( 'ReadOnlyFile' )
143  );
144  },
145 
146  'ContentLanguage' => function ( MediaWikiServices $services ) : Language {
147  return Language::factory( $services->getMainConfig()->get( 'LanguageCode' ) );
148  },
149 
150  'CryptHKDF' => function ( MediaWikiServices $services ) : CryptHKDF {
151  $config = $services->getMainConfig();
152 
153  $secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
154  if ( !$secret ) {
155  throw new RuntimeException( "Cannot use MWCryptHKDF without a secret." );
156  }
157 
158  // In HKDF, the context can be known to the attacker, but this will
159  // keep simultaneous runs from producing the same output.
160  $context = [ microtime(), getmypid(), gethostname() ];
161 
162  // Setup salt cache. Use APC, or fallback to the main cache if it isn't setup
163  $cache = $services->getLocalServerObjectCache();
164  if ( $cache instanceof EmptyBagOStuff ) {
166  }
167 
168  return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm' ), $cache, $context );
169  },
170 
171  'DateFormatterFactory' => function () : DateFormatterFactory {
172  return new DateFormatterFactory;
173  },
174 
175  'DBLoadBalancer' => function ( MediaWikiServices $services ) : Wikimedia\Rdbms\ILoadBalancer {
176  // just return the default LB from the DBLoadBalancerFactory service
177  return $services->getDBLoadBalancerFactory()->getMainLB();
178  },
179 
180  'DBLoadBalancerFactory' =>
181  function ( MediaWikiServices $services ) : Wikimedia\Rdbms\LBFactory {
182  $mainConfig = $services->getMainConfig();
183 
185  $mainConfig->get( 'LBFactoryConf' ),
187  $services->getConfiguredReadOnlyMode(),
188  $services->getLocalServerObjectCache(),
189  $services->getMainObjectStash(),
190  $services->getMainWANObjectCache()
191  );
192  $class = MWLBFactory::getLBFactoryClass( $lbConf );
193 
194  $instance = new $class( $lbConf );
195  MWLBFactory::setSchemaAliases( $instance, $mainConfig->get( 'DBtype' ) );
196 
197  return $instance;
198  },
199 
200  'EventRelayerGroup' => function ( MediaWikiServices $services ) : EventRelayerGroup {
201  return new EventRelayerGroup( $services->getMainConfig()->get( 'EventRelayerConfig' ) );
202  },
203 
204  'ExternalStoreFactory' => function ( MediaWikiServices $services ) : ExternalStoreFactory {
205  $config = $services->getMainConfig();
206 
207  return new ExternalStoreFactory(
208  $config->get( 'ExternalStores' )
209  );
210  },
211 
212  'GenderCache' => function ( MediaWikiServices $services ) : GenderCache {
213  return new GenderCache( $services->getNamespaceInfo() );
214  },
215 
216  'HttpRequestFactory' =>
218  return new HttpRequestFactory();
219  },
220 
221  'InterwikiLookup' => function ( MediaWikiServices $services ) : InterwikiLookup {
222  $config = $services->getMainConfig();
223  return new ClassicInterwikiLookup(
224  $services->getContentLanguage(),
225  $services->getMainWANObjectCache(),
226  $config->get( 'InterwikiExpiry' ),
227  $config->get( 'InterwikiCache' ),
228  $config->get( 'InterwikiScopes' ),
229  $config->get( 'InterwikiFallbackSite' )
230  );
231  },
232 
233  'LinkCache' => function ( MediaWikiServices $services ) : LinkCache {
234  return new LinkCache(
235  $services->getTitleFormatter(),
236  $services->getMainWANObjectCache(),
237  $services->getNamespaceInfo()
238  );
239  },
240 
241  'LinkRenderer' => function ( MediaWikiServices $services ) : LinkRenderer {
242  if ( defined( 'MW_NO_SESSION' ) ) {
243  return $services->getLinkRendererFactory()->create();
244  } else {
245  return $services->getLinkRendererFactory()->createForUser(
246  RequestContext::getMain()->getUser()
247  );
248  }
249  },
250 
251  'LinkRendererFactory' => function ( MediaWikiServices $services ) : LinkRendererFactory {
252  return new LinkRendererFactory(
253  $services->getTitleFormatter(),
254  $services->getLinkCache(),
255  $services->getNamespaceInfo()
256  );
257  },
258 
259  'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
261  return \ObjectCache::newFromId( $cacheId );
262  },
263 
264  'MagicWordFactory' => function ( MediaWikiServices $services ) : MagicWordFactory {
265  return new MagicWordFactory( $services->getContentLanguage() );
266  },
267 
268  'MainConfig' => function ( MediaWikiServices $services ) : Config {
269  // Use the 'main' config from the ConfigFactory service.
270  return $services->getConfigFactory()->makeConfig( 'main' );
271  },
272 
273  'MainObjectStash' => function ( MediaWikiServices $services ) : BagOStuff {
274  $mainConfig = $services->getMainConfig();
275 
276  $id = $mainConfig->get( 'MainStash' );
277  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$id] ) ) {
278  throw new UnexpectedValueException(
279  "Cache type \"$id\" is not present in \$wgObjectCaches." );
280  }
281 
282  return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] );
283  },
284 
285  'MainWANObjectCache' => function ( MediaWikiServices $services ) : WANObjectCache {
286  $mainConfig = $services->getMainConfig();
287 
288  $id = $mainConfig->get( 'MainWANCache' );
289  if ( !isset( $mainConfig->get( 'WANObjectCaches' )[$id] ) ) {
290  throw new UnexpectedValueException(
291  "WAN cache type \"$id\" is not present in \$wgWANObjectCaches." );
292  }
293 
294  $params = $mainConfig->get( 'WANObjectCaches' )[$id];
295  $objectCacheId = $params['cacheId'];
296  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$objectCacheId] ) ) {
297  throw new UnexpectedValueException(
298  "Cache type \"$objectCacheId\" is not present in \$wgObjectCaches." );
299  }
300  $params['store'] = $mainConfig->get( 'ObjectCaches' )[$objectCacheId];
301 
302  return \ObjectCache::newWANCacheFromParams( $params );
303  },
304 
305  'MediaHandlerFactory' => function ( MediaWikiServices $services ) : MediaHandlerFactory {
306  return new MediaHandlerFactory(
307  $services->getMainConfig()->get( 'MediaHandlers' )
308  );
309  },
310 
311  'MimeAnalyzer' => function ( MediaWikiServices $services ) : MimeAnalyzer {
312  $logger = LoggerFactory::getInstance( 'Mime' );
313  $mainConfig = $services->getMainConfig();
314  $params = [
315  'typeFile' => $mainConfig->get( 'MimeTypeFile' ),
316  'infoFile' => $mainConfig->get( 'MimeInfoFile' ),
317  'xmlTypes' => $mainConfig->get( 'XMLMimeTypes' ),
318  'guessCallback' =>
319  function ( $mimeAnalyzer, &$head, &$tail, $file, &$mime ) use ( $logger ) {
320  // Also test DjVu
321  $deja = new DjVuImage( $file );
322  if ( $deja->isValid() ) {
323  $logger->info( "Detected $file as image/vnd.djvu\n" );
324  $mime = 'image/vnd.djvu';
325 
326  return;
327  }
328  // Some strings by reference for performance - assuming well-behaved hooks
329  Hooks::run(
330  'MimeMagicGuessFromContent',
331  [ $mimeAnalyzer, &$head, &$tail, $file, &$mime ]
332  );
333  },
334  'extCallback' => function ( $mimeAnalyzer, $ext, &$mime ) {
335  // Media handling extensions can improve the MIME detected
336  Hooks::run( 'MimeMagicImproveFromExtension', [ $mimeAnalyzer, $ext, &$mime ] );
337  },
338  'initCallback' => function ( $mimeAnalyzer ) {
339  // Allow media handling extensions adding MIME-types and MIME-info
340  Hooks::run( 'MimeMagicInit', [ $mimeAnalyzer ] );
341  },
342  'logger' => $logger
343  ];
344 
345  if ( $params['infoFile'] === 'includes/mime.info' ) {
346  $params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
347  }
348 
349  if ( $params['typeFile'] === 'includes/mime.types' ) {
350  $params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
351  }
352 
353  $detectorCmd = $mainConfig->get( 'MimeDetectorCommand' );
354  if ( $detectorCmd ) {
355  $factory = $services->getShellCommandFactory();
356  $params['detectCallback'] = function ( $file ) use ( $detectorCmd, $factory ) {
357  $result = $factory->create()
358  // $wgMimeDetectorCommand can contain commands with parameters
359  ->unsafeParams( $detectorCmd )
360  ->params( $file )
361  ->execute();
362  return $result->getStdout();
363  };
364  }
365 
366  return new MimeAnalyzer( $params );
367  },
368 
369  'NamespaceInfo' => function ( MediaWikiServices $services ) : NamespaceInfo {
371  $services->getMainConfig() ) );
372  },
373 
374  'NameTableStoreFactory' => function ( MediaWikiServices $services ) : NameTableStoreFactory {
375  return new NameTableStoreFactory(
376  $services->getDBLoadBalancerFactory(),
377  $services->getMainWANObjectCache(),
378  LoggerFactory::getInstance( 'NameTableSqlStore' )
379  );
380  },
381 
382  'OldRevisionImporter' => function ( MediaWikiServices $services ) : OldRevisionImporter {
384  true,
385  LoggerFactory::getInstance( 'OldRevisionImporter' ),
386  $services->getDBLoadBalancer()
387  );
388  },
389 
390  'PageEditStash' => function ( MediaWikiServices $services ) : PageEditStash {
391  $config = $services->getMainConfig();
392 
393  return new PageEditStash(
395  $services->getDBLoadBalancer(),
396  LoggerFactory::getInstance( 'StashEdit' ),
397  $services->getStatsdDataFactory(),
398  defined( 'MEDIAWIKI_JOB_RUNNER' ) || $config->get( 'CommandLineMode' )
399  ? PageEditStash::INITIATOR_JOB_OR_CLI
400  : PageEditStash::INITIATOR_USER
401  );
402  },
403 
404  'Parser' => function ( MediaWikiServices $services ) : Parser {
405  return $services->getParserFactory()->create();
406  },
407 
408  'ParserCache' => function ( MediaWikiServices $services ) : ParserCache {
409  $config = $services->getMainConfig();
410  $cache = ObjectCache::getInstance( $config->get( 'ParserCacheType' ) );
411  wfDebugLog( 'caches', 'parser: ' . get_class( $cache ) );
412 
413  return new ParserCache(
414  $cache,
415  $config->get( 'CacheEpoch' )
416  );
417  },
418 
419  'ParserFactory' => function ( MediaWikiServices $services ) : ParserFactory {
421  // 'class' and 'preprocessorClass'
422  $services->getMainConfig()->get( 'ParserConf' ),
423  // Make sure to have defaults in case someone overrode ParserConf with something silly
424  [ 'class' => Parser::class,
425  'preprocessorClass' => Parser::getDefaultPreprocessorClass() ],
426  // Plus a buch of actual config options
427  $services->getMainConfig()
428  );
429 
430  return new ParserFactory(
431  $options,
432  $services->getMagicWordFactory(),
433  $services->getContentLanguage(),
434  wfUrlProtocols(),
435  $services->getSpecialPageFactory(),
436  $services->getLinkRendererFactory(),
437  $services->getNamespaceInfo()
438  );
439  },
440 
441  'PasswordFactory' => function ( MediaWikiServices $services ) : PasswordFactory {
442  $config = $services->getMainConfig();
443  return new PasswordFactory(
444  $config->get( 'PasswordConfig' ),
445  $config->get( 'PasswordDefault' )
446  );
447  },
448 
449  'PerDbNameStatsdDataFactory' =>
450  function ( MediaWikiServices $services ) : StatsdDataFactoryInterface {
451  $config = $services->getMainConfig();
452  $wiki = $config->get( 'DBname' );
454  $services->getStatsdDataFactory(),
455  $wiki
456  );
457  },
458 
459  'PermissionManager' => function ( MediaWikiServices $services ) : PermissionManager {
460  $config = $services->getMainConfig();
461  return new PermissionManager(
462  $services->getSpecialPageFactory(),
463  $config->get( 'WhitelistRead' ),
464  $config->get( 'WhitelistReadRegexp' ),
465  $config->get( 'EmailConfirmToEdit' ),
466  $config->get( 'BlockDisablesLogin' ),
467  $services->getNamespaceInfo()
468  );
469  },
470 
471  'PreferencesFactory' => function ( MediaWikiServices $services ) : PreferencesFactory {
472  $factory = new DefaultPreferencesFactory(
473  new ServiceOptions(
474  DefaultPreferencesFactory::$constructorOptions, $services->getMainConfig() ),
475  $services->getContentLanguage(),
476  AuthManager::singleton(),
477  $services->getLinkRendererFactory()->create(),
478  $services->getNamespaceInfo()
479  );
480  $factory->setLogger( LoggerFactory::getInstance( 'preferences' ) );
481 
482  return $factory;
483  },
484 
485  'ProxyLookup' => function ( MediaWikiServices $services ) : ProxyLookup {
486  $mainConfig = $services->getMainConfig();
487  return new ProxyLookup(
488  $mainConfig->get( 'CdnServers' ),
489  $mainConfig->get( 'CdnServersNoPurge' )
490  );
491  },
492 
493  'ReadOnlyMode' => function ( MediaWikiServices $services ) : ReadOnlyMode {
494  return new ReadOnlyMode(
495  $services->getConfiguredReadOnlyMode(),
496  $services->getDBLoadBalancer()
497  );
498  },
499 
500  'RepoGroup' => function ( MediaWikiServices $services ) : RepoGroup {
501  $config = $services->getMainConfig();
502  return new RepoGroup(
503  $config->get( 'LocalFileRepo' ),
504  $config->get( 'ForeignFileRepos' ),
505  $services->getMainWANObjectCache()
506  );
507  },
508 
509  'ResourceLoader' => function ( MediaWikiServices $services ) : ResourceLoader {
510  // @todo This should not take a Config object, but it's not so easy to remove because it
511  // exposes it in a getter, which is actually used.
512  global $IP;
513  $config = $services->getMainConfig();
514 
515  $rl = new ResourceLoader(
516  $config,
517  LoggerFactory::getInstance( 'resourceloader' )
518  );
519 
520  $rl->addSource( $config->get( 'ResourceLoaderSources' ) );
521 
522  // Core modules, then extension/skin modules
523  $rl->register( include "$IP/resources/Resources.php" );
524  $rl->register( $config->get( 'ResourceModules' ) );
525  Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
526 
527  if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
528  $rl->registerTestModules();
529  }
530 
531  return $rl;
532  },
533 
534  'RevisionFactory' => function ( MediaWikiServices $services ) : RevisionFactory {
535  return $services->getRevisionStore();
536  },
537 
538  'RevisionLookup' => function ( MediaWikiServices $services ) : RevisionLookup {
539  return $services->getRevisionStore();
540  },
541 
542  'RevisionRenderer' => function ( MediaWikiServices $services ) : RevisionRenderer {
543  $renderer = new RevisionRenderer(
544  $services->getDBLoadBalancer(),
545  $services->getSlotRoleRegistry()
546  );
547 
548  $renderer->setLogger( LoggerFactory::getInstance( 'SaveParse' ) );
549  return $renderer;
550  },
551 
552  'RevisionStore' => function ( MediaWikiServices $services ) : RevisionStore {
553  return $services->getRevisionStoreFactory()->getRevisionStore();
554  },
555 
556  'RevisionStoreFactory' => function ( MediaWikiServices $services ) : RevisionStoreFactory {
557  $config = $services->getMainConfig();
558  $store = new RevisionStoreFactory(
559  $services->getDBLoadBalancerFactory(),
560  $services->getBlobStoreFactory(),
561  $services->getNameTableStoreFactory(),
562  $services->getSlotRoleRegistry(),
563  $services->getMainWANObjectCache(),
564  $services->getCommentStore(),
565  $services->getActorMigration(),
566  $config->get( 'MultiContentRevisionSchemaMigrationStage' ),
567  LoggerFactory::getProvider(),
568  $config->get( 'ContentHandlerUseDB' )
569  );
570 
571  return $store;
572  },
573 
574  'SearchEngineConfig' => function ( MediaWikiServices $services ) : SearchEngineConfig {
575  // @todo This should not take a Config object, but it's not so easy to remove because it
576  // exposes it in a getter, which is actually used.
577  return new SearchEngineConfig( $services->getMainConfig(),
578  $services->getContentLanguage() );
579  },
580 
581  'SearchEngineFactory' => function ( MediaWikiServices $services ) : SearchEngineFactory {
582  return new SearchEngineFactory( $services->getSearchEngineConfig() );
583  },
584 
585  'ShellCommandFactory' => function ( MediaWikiServices $services ) : CommandFactory {
586  $config = $services->getMainConfig();
587 
588  $limits = [
589  'time' => $config->get( 'MaxShellTime' ),
590  'walltime' => $config->get( 'MaxShellWallClockTime' ),
591  'memory' => $config->get( 'MaxShellMemory' ),
592  'filesize' => $config->get( 'MaxShellFileSize' ),
593  ];
594  $cgroup = $config->get( 'ShellCgroup' );
595  $restrictionMethod = $config->get( 'ShellRestrictionMethod' );
596 
597  $factory = new CommandFactory( $limits, $cgroup, $restrictionMethod );
598  $factory->setLogger( LoggerFactory::getInstance( 'exec' ) );
599  $factory->logStderr();
600 
601  return $factory;
602  },
603 
604  'SiteLookup' => function ( MediaWikiServices $services ) : SiteLookup {
605  // Use SiteStore as the SiteLookup as well. This was originally separated
606  // to allow for a cacheable read-only interface (using FileBasedSiteLookup),
607  // but this was never used. SiteStore has caching (see below).
608  return $services->getSiteStore();
609  },
610 
611  'SiteStore' => function ( MediaWikiServices $services ) : SiteStore {
612  $rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() );
613 
614  // TODO: replace wfGetCache with a CacheFactory service.
615  // TODO: replace wfIsHHVM with a capabilities service.
616  $cache = wfGetCache( wfIsHHVM() ? CACHE_ACCEL : CACHE_ANYTHING );
617 
618  return new CachingSiteStore( $rawSiteStore, $cache );
619  },
620 
621  'SkinFactory' => function ( MediaWikiServices $services ) : SkinFactory {
622  $factory = new SkinFactory();
623 
624  $names = $services->getMainConfig()->get( 'ValidSkinNames' );
625 
626  foreach ( $names as $name => $skin ) {
627  $factory->register( $name, $skin, function () use ( $name, $skin ) {
628  $class = "Skin$skin";
629  return new $class( $name );
630  } );
631  }
632  // Register a hidden "fallback" skin
633  $factory->register( 'fallback', 'Fallback', function () {
634  return new SkinFallback;
635  } );
636  // Register a hidden skin for api output
637  $factory->register( 'apioutput', 'ApiOutput', function () {
638  return new SkinApi;
639  } );
640 
641  return $factory;
642  },
643 
644  'SlotRoleRegistry' => function ( MediaWikiServices $services ) : SlotRoleRegistry {
645  $config = $services->getMainConfig();
646 
647  $registry = new SlotRoleRegistry(
648  $services->getNameTableStoreFactory()->getSlotRoles()
649  );
650 
651  $registry->defineRole( 'main', function () use ( $config ) {
652  return new MainSlotRoleHandler(
653  $config->get( 'NamespaceContentModels' )
654  );
655  } );
656 
657  return $registry;
658  },
659 
660  'SpecialPageFactory' => function ( MediaWikiServices $services ) : SpecialPageFactory {
661  return new SpecialPageFactory(
662  new ServiceOptions(
663  SpecialPageFactory::$constructorOptions, $services->getMainConfig() ),
664  $services->getContentLanguage()
665  );
666  },
667 
668  'StatsdDataFactory' => function ( MediaWikiServices $services ) : IBufferingStatsdDataFactory {
669  return new BufferingStatsdDataFactory(
670  rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' )
671  );
672  },
673 
674  'TitleFormatter' => function ( MediaWikiServices $services ) : TitleFormatter {
675  return $services->getService( '_MediaWikiTitleCodec' );
676  },
677 
678  'TitleParser' => function ( MediaWikiServices $services ) : TitleParser {
679  return $services->getService( '_MediaWikiTitleCodec' );
680  },
681 
682  'UploadRevisionImporter' => function ( MediaWikiServices $services ) : UploadRevisionImporter {
684  $services->getMainConfig()->get( 'EnableUploads' ),
685  LoggerFactory::getInstance( 'UploadRevisionImporter' )
686  );
687  },
688 
689  'VirtualRESTServiceClient' =>
691  $config = $services->getMainConfig()->get( 'VirtualRestConfig' );
692 
693  $vrsClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) );
694  foreach ( $config['paths'] as $prefix => $serviceConfig ) {
695  $class = $serviceConfig['class'];
696  // Merge in the global defaults
697  $constructArg = $serviceConfig['options'] ?? [];
698  $constructArg += $config['global'];
699  // Make the VRS service available at the mount point
700  $vrsClient->mount( $prefix, [ 'class' => $class, 'config' => $constructArg ] );
701  }
702 
703  return $vrsClient;
704  },
705 
706  'WatchedItemQueryService' =>
708  return new WatchedItemQueryService(
709  $services->getDBLoadBalancer(),
710  $services->getCommentStore(),
711  $services->getActorMigration(),
712  $services->getWatchedItemStore()
713  );
714  },
715 
716  'WatchedItemStore' => function ( MediaWikiServices $services ) : WatchedItemStore {
717  $store = new WatchedItemStore(
718  $services->getDBLoadBalancerFactory(),
720  $services->getMainObjectStash(),
721  new HashBagOStuff( [ 'maxKeys' => 100 ] ),
722  $services->getReadOnlyMode(),
723  $services->getMainConfig()->get( 'UpdateRowsPerQuery' ),
724  $services->getNamespaceInfo(),
725  $services->getRevisionLookup()
726  );
727  $store->setStatsdDataFactory( $services->getStatsdDataFactory() );
728 
729  if ( $services->getMainConfig()->get( 'ReadOnlyWatchedItemStore' ) ) {
730  $store = new NoWriteWatchedItemStore( $store );
731  }
732 
733  return $store;
734  },
735 
736  'WikiRevisionOldRevisionImporterNoUpdates' =>
739  false,
740  LoggerFactory::getInstance( 'OldRevisionImporter' ),
741  $services->getDBLoadBalancer()
742  );
743  },
744 
745  '_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) : MediaWikiTitleCodec {
746  return new MediaWikiTitleCodec(
747  $services->getContentLanguage(),
748  $services->getGenderCache(),
749  $services->getMainConfig()->get( 'LocalInterwikis' ),
750  $services->getInterwikiLookup(),
751  $services->getNamespaceInfo()
752  );
753  },
754 
755  '_SqlBlobStore' => function ( MediaWikiServices $services ) : SqlBlobStore {
756  return $services->getBlobStoreFactory()->newSqlBlobStore();
757  },
758 
760  // NOTE: When adding a service here, don't forget to add a getter function
761  // in the MediaWikiServices class. The convenience getter should just call
762  // $this->getService( 'FooBarService' ).
764 
765 ];
Service for storing and loading Content objects.
In both all secondary updates will be triggered handle like object that caches derived data representing a and can trigger updates of cached copies of that e g in the links the ParserCache
Definition: pageupdater.txt:78
A factory for application metric data.
A codec for MediaWiki page titles.
wfUrlProtocols( $includeProtocolRelative=true)
Returns a regular expression of url protocols.
static array $constructorOptions
TODO Make this const when HHVM support is dropped (T192166)
wfIsHHVM()
Check if we are running under HHVM.
const CACHE_ACCEL
Definition: Defines.php:101
SkinTemplate class for API output.
Definition: SkinApi.php:31
$IP
Definition: WebStart.php:41
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Definition: router.php:42
The RevisionRenderer service provides access to rendered output for revisions.
Class for managing stashed edits used by the page updater classes.
Service for instantiating BlobStores.
wfGetCache( $cacheType)
Get a specific cache object.
A registry service for SlotRoleHandlers, used to define which slot roles are available on which page...
setLogger(LoggerInterface $saveParseLogger)
static getInstance( $id)
Get a cached instance of the specified type of cache object.
Definition: ObjectCache.php:92
static setSchemaAliases(LBFactory $lbFactory, $dbType)
static getLocalClusterInstance()
Get the main cluster-local cache object.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
A read-only mode service which does not depend on LoadBalancer.
defineRole( $role, callable $instantiator)
Defines a slot role.
Factory service for RevisionStore instances.
InterwikiLookup implementing the "classic" interwiki storage (hardcoded up to MW 1.26).
Storage layer class for WatchedItems.
This is the default implementation of PreferencesFactory.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1980
A service class for fetching the wiki&#39;s current read-only mode.
A class for passing options to services.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:1982
Support for detecting/validating DjVu image files and getting some basic file metadata (resolution et...
Definition: DjVuImage.php:38
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
Class that generates HTML links for pages.
Factory for handling the special page list and generating SpecialPage objects.
static getMain()
Get the RequestContext object associated with the main request.
Interface for configuration instances.
Definition: Config.php:28
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition: hooks.txt:2217
Service for looking up page revisions.
$cache
Definition: mcc.php:33
$params
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1982
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:216
Service for looking up page revisions.
static applyDefaultConfig(array $lbConf, ServiceOptions $options, ConfiguredReadOnlyMode $readOnlyMode, BagOStuff $srvCace, BagOStuff $mainStash, WANObjectCache $wanCache)
Definition: MWLBFactory.php:74
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
Definition: hooks.txt:1982
Service interface for looking up Interwiki records.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
SkinTemplate class for the fallback skin.
Service for constructing revision objects.
setStatsdDataFactory(StatsdDataFactoryInterface $stats)
A service class for checking blocks.
A SlotRoleHandler for the main slot.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Factory creating MWHttpRequest objects.
static array $applyDefaultConfigOptions
TODO Make this a const when HHVM support is dropped (T192166)
Definition: MWLBFactory.php:44
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
static getLBFactoryClass(array $config)
Returns the LBFactory class to use and the load balancer configuration.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
const CACHE_ANYTHING
Definition: Defines.php:97
Factory facilitating dependency injection for Command.
if(!is_readable( $file)) $ext
Definition: router.php:48
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2633
static array $constructorOptions
TODO Make this a const when HHVM support is dropped (T192166)
Definition: Parser.php:301
MediaWiki Logger LoggerFactory implements a PSR [0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
Definition: logger.txt:5
static singleton( $domain=false)
Factory to create LinkRender objects.
A PreferencesFactory is a MediaWiki service that provides the definitions of preferences for a given ...
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
Object which holds currently registered configuration options.
Service for loading and storing data blobs.
Definition: BlobStore.php:33
const MIGRATION_NEW
Definition: Defines.php:314
Class to handle multiple HTTP requests.
static detectLocalServerCache()
Detects which local server cache library is present and returns a configuration for it...
Proxy to prefix metric keys sent to a StatsdDataFactoryInterface.
static getDefaultPreprocessorClass()
Which class should we use for the preprocessor if not otherwise specified?
Definition: Parser.php:427
MediaWikiServices is the service locator for the application scope of MediaWiki.
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might include
Definition: hooks.txt:780