MediaWiki  master
ServiceWiring.php
Go to the documentation of this file.
1 <?php
66 
67 return [
68  'ActorMigration' => function ( MediaWikiServices $services ) : ActorMigration {
69  return new ActorMigration(
70  $services->getMainConfig()->get( 'ActorTableSchemaMigrationStage' )
71  );
72  },
73 
74  'BlobStore' => function ( MediaWikiServices $services ) : BlobStore {
75  return $services->getService( '_SqlBlobStore' );
76  },
77 
78  'BlobStoreFactory' => function ( MediaWikiServices $services ) : BlobStoreFactory {
79  return new BlobStoreFactory(
80  $services->getDBLoadBalancerFactory(),
81  $services->getMainWANObjectCache(),
82  $services->getMainConfig(),
83  $services->getContentLanguage()
84  );
85  },
86 
87  'CommentStore' => function ( MediaWikiServices $services ) : CommentStore {
88  return new CommentStore(
89  $services->getContentLanguage(),
91  );
92  },
93 
94  'ConfigFactory' => function ( MediaWikiServices $services ) : ConfigFactory {
95  // Use the bootstrap config to initialize the ConfigFactory.
96  $registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' );
97  $factory = new ConfigFactory();
98 
99  foreach ( $registry as $name => $callback ) {
100  $factory->register( $name, $callback );
101  }
102  return $factory;
103  },
104 
105  'ConfigRepository' => function ( MediaWikiServices $services ) : ConfigRepository {
106  return new ConfigRepository( $services->getConfigFactory() );
107  },
108 
109  'ConfiguredReadOnlyMode' => function ( MediaWikiServices $services ) : ConfiguredReadOnlyMode {
110  return new ConfiguredReadOnlyMode( $services->getMainConfig() );
111  },
112 
113  'ContentLanguage' => function ( MediaWikiServices $services ) : Language {
114  return Language::factory( $services->getMainConfig()->get( 'LanguageCode' ) );
115  },
116 
117  'CryptHKDF' => function ( MediaWikiServices $services ) : CryptHKDF {
118  $config = $services->getMainConfig();
119 
120  $secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
121  if ( !$secret ) {
122  throw new RuntimeException( "Cannot use MWCryptHKDF without a secret." );
123  }
124 
125  // In HKDF, the context can be known to the attacker, but this will
126  // keep simultaneous runs from producing the same output.
127  $context = [ microtime(), getmypid(), gethostname() ];
128 
129  // Setup salt cache. Use APC, or fallback to the main cache if it isn't setup
130  $cache = $services->getLocalServerObjectCache();
131  if ( $cache instanceof EmptyBagOStuff ) {
133  }
134 
135  return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm' ), $cache, $context );
136  },
137 
138  'DateFormatterFactory' => function () : DateFormatterFactory {
139  return new DateFormatterFactory;
140  },
141 
142  'DBLoadBalancer' => function ( MediaWikiServices $services ) : Wikimedia\Rdbms\LoadBalancer {
143  // just return the default LB from the DBLoadBalancerFactory service
144  return $services->getDBLoadBalancerFactory()->getMainLB();
145  },
146 
147  'DBLoadBalancerFactory' =>
148  function ( MediaWikiServices $services ) : Wikimedia\Rdbms\LBFactory {
149  $mainConfig = $services->getMainConfig();
150 
152  $mainConfig->get( 'LBFactoryConf' ),
153  $mainConfig,
154  $services->getConfiguredReadOnlyMode(),
155  $services->getLocalServerObjectCache(),
156  $services->getMainObjectStash(),
157  $services->getMainWANObjectCache()
158  );
159  $class = MWLBFactory::getLBFactoryClass( $lbConf );
160 
161  $instance = new $class( $lbConf );
162  MWLBFactory::setSchemaAliases( $instance, $mainConfig );
163 
164  return $instance;
165  },
166 
167  'EventRelayerGroup' => function ( MediaWikiServices $services ) : EventRelayerGroup {
168  return new EventRelayerGroup( $services->getMainConfig()->get( 'EventRelayerConfig' ) );
169  },
170 
171  'ExternalStoreFactory' => function ( MediaWikiServices $services ) : ExternalStoreFactory {
172  $config = $services->getMainConfig();
173 
174  return new ExternalStoreFactory(
175  $config->get( 'ExternalStores' )
176  );
177  },
178 
179  'GenderCache' => function ( MediaWikiServices $services ) : GenderCache {
180  return new GenderCache();
181  },
182 
183  'HttpRequestFactory' =>
184  function ( MediaWikiServices $services ) : \MediaWiki\Http\HttpRequestFactory {
185  return new \MediaWiki\Http\HttpRequestFactory();
186  },
187 
188  'InterwikiLookup' => function ( MediaWikiServices $services ) : InterwikiLookup {
189  $config = $services->getMainConfig();
190  return new ClassicInterwikiLookup(
191  $services->getContentLanguage(),
192  $services->getMainWANObjectCache(),
193  $config->get( 'InterwikiExpiry' ),
194  $config->get( 'InterwikiCache' ),
195  $config->get( 'InterwikiScopes' ),
196  $config->get( 'InterwikiFallbackSite' )
197  );
198  },
199 
200  'LinkCache' => function ( MediaWikiServices $services ) : LinkCache {
201  return new LinkCache(
202  $services->getTitleFormatter(),
203  $services->getMainWANObjectCache()
204  );
205  },
206 
207  'LinkRenderer' => function ( MediaWikiServices $services ) : LinkRenderer {
208  if ( defined( 'MW_NO_SESSION' ) ) {
209  return $services->getLinkRendererFactory()->create();
210  } else {
211  return $services->getLinkRendererFactory()->createForUser(
212  RequestContext::getMain()->getUser()
213  );
214  }
215  },
216 
217  'LinkRendererFactory' => function ( MediaWikiServices $services ) : LinkRendererFactory {
218  return new LinkRendererFactory(
219  $services->getTitleFormatter(),
220  $services->getLinkCache()
221  );
222  },
223 
224  'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
226  return \ObjectCache::newFromId( $cacheId );
227  },
228 
229  'MagicWordFactory' => function ( MediaWikiServices $services ) : MagicWordFactory {
230  return new MagicWordFactory( $services->getContentLanguage() );
231  },
232 
233  'MainConfig' => function ( MediaWikiServices $services ) : Config {
234  // Use the 'main' config from the ConfigFactory service.
235  return $services->getConfigFactory()->makeConfig( 'main' );
236  },
237 
238  'MainObjectStash' => function ( MediaWikiServices $services ) : BagOStuff {
239  $mainConfig = $services->getMainConfig();
240 
241  $id = $mainConfig->get( 'MainStash' );
242  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$id] ) ) {
243  throw new UnexpectedValueException(
244  "Cache type \"$id\" is not present in \$wgObjectCaches." );
245  }
246 
247  return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] );
248  },
249 
250  'MainWANObjectCache' => function ( MediaWikiServices $services ) : WANObjectCache {
251  $mainConfig = $services->getMainConfig();
252 
253  $id = $mainConfig->get( 'MainWANCache' );
254  if ( !isset( $mainConfig->get( 'WANObjectCaches' )[$id] ) ) {
255  throw new UnexpectedValueException(
256  "WAN cache type \"$id\" is not present in \$wgWANObjectCaches." );
257  }
258 
259  $params = $mainConfig->get( 'WANObjectCaches' )[$id];
260  $objectCacheId = $params['cacheId'];
261  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$objectCacheId] ) ) {
262  throw new UnexpectedValueException(
263  "Cache type \"$objectCacheId\" is not present in \$wgObjectCaches." );
264  }
265  $params['store'] = $mainConfig->get( 'ObjectCaches' )[$objectCacheId];
266 
267  return \ObjectCache::newWANCacheFromParams( $params );
268  },
269 
270  'MediaHandlerFactory' => function ( MediaWikiServices $services ) : MediaHandlerFactory {
271  return new MediaHandlerFactory(
272  $services->getMainConfig()->get( 'MediaHandlers' )
273  );
274  },
275 
276  'MimeAnalyzer' => function ( MediaWikiServices $services ) : MimeAnalyzer {
277  $logger = LoggerFactory::getInstance( 'Mime' );
278  $mainConfig = $services->getMainConfig();
279  $params = [
280  'typeFile' => $mainConfig->get( 'MimeTypeFile' ),
281  'infoFile' => $mainConfig->get( 'MimeInfoFile' ),
282  'xmlTypes' => $mainConfig->get( 'XMLMimeTypes' ),
283  'guessCallback' =>
284  function ( $mimeAnalyzer, &$head, &$tail, $file, &$mime ) use ( $logger ) {
285  // Also test DjVu
286  $deja = new DjVuImage( $file );
287  if ( $deja->isValid() ) {
288  $logger->info( "Detected $file as image/vnd.djvu\n" );
289  $mime = 'image/vnd.djvu';
290 
291  return;
292  }
293  // Some strings by reference for performance - assuming well-behaved hooks
294  Hooks::run(
295  'MimeMagicGuessFromContent',
296  [ $mimeAnalyzer, &$head, &$tail, $file, &$mime ]
297  );
298  },
299  'extCallback' => function ( $mimeAnalyzer, $ext, &$mime ) {
300  // Media handling extensions can improve the MIME detected
301  Hooks::run( 'MimeMagicImproveFromExtension', [ $mimeAnalyzer, $ext, &$mime ] );
302  },
303  'initCallback' => function ( $mimeAnalyzer ) {
304  // Allow media handling extensions adding MIME-types and MIME-info
305  Hooks::run( 'MimeMagicInit', [ $mimeAnalyzer ] );
306  },
307  'logger' => $logger
308  ];
309 
310  if ( $params['infoFile'] === 'includes/mime.info' ) {
311  $params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
312  }
313 
314  if ( $params['typeFile'] === 'includes/mime.types' ) {
315  $params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
316  }
317 
318  $detectorCmd = $mainConfig->get( 'MimeDetectorCommand' );
319  if ( $detectorCmd ) {
320  $factory = $services->getShellCommandFactory();
321  $params['detectCallback'] = function ( $file ) use ( $detectorCmd, $factory ) {
322  $result = $factory->create()
323  // $wgMimeDetectorCommand can contain commands with parameters
324  ->unsafeParams( $detectorCmd )
325  ->params( $file )
326  ->execute();
327  return $result->getStdout();
328  };
329  }
330 
331  return new MimeAnalyzer( $params );
332  },
333 
334  'NamespaceInfo' => function ( MediaWikiServices $services ) : NamespaceInfo {
335  return new NamespaceInfo( $services->getMainConfig() );
336  },
337 
338  'NameTableStoreFactory' => function ( MediaWikiServices $services ) : NameTableStoreFactory {
339  return new NameTableStoreFactory(
340  $services->getDBLoadBalancerFactory(),
341  $services->getMainWANObjectCache(),
342  LoggerFactory::getInstance( 'NameTableSqlStore' )
343  );
344  },
345 
346  'OldRevisionImporter' => function ( MediaWikiServices $services ) : OldRevisionImporter {
348  true,
349  LoggerFactory::getInstance( 'OldRevisionImporter' ),
350  $services->getDBLoadBalancer()
351  );
352  },
353 
354  'PageEditStash' => function ( MediaWikiServices $services ) : PageEditStash {
355  $config = $services->getMainConfig();
356 
357  return new PageEditStash(
359  $services->getDBLoadBalancer(),
360  LoggerFactory::getInstance( 'StashEdit' ),
361  $services->getStatsdDataFactory(),
362  defined( 'MEDIAWIKI_JOB_RUNNER' ) || $config->get( 'CommandLineMode' )
363  ? PageEditStash::INITIATOR_JOB_OR_CLI
364  : PageEditStash::INITIATOR_USER
365  );
366  },
367 
368  'Parser' => function ( MediaWikiServices $services ) : Parser {
369  return $services->getParserFactory()->create();
370  },
371 
372  'ParserCache' => function ( MediaWikiServices $services ) : ParserCache {
373  $config = $services->getMainConfig();
374  $cache = ObjectCache::getInstance( $config->get( 'ParserCacheType' ) );
375  wfDebugLog( 'caches', 'parser: ' . get_class( $cache ) );
376 
377  return new ParserCache(
378  $cache,
379  $config->get( 'CacheEpoch' )
380  );
381  },
382 
383  'ParserFactory' => function ( MediaWikiServices $services ) : ParserFactory {
384  return new ParserFactory(
385  $services->getMainConfig()->get( 'ParserConf' ),
386  $services->getMagicWordFactory(),
387  $services->getContentLanguage(),
388  wfUrlProtocols(),
389  $services->getSpecialPageFactory(),
390  $services->getMainConfig(),
391  $services->getLinkRendererFactory(),
392  $services->getNamespaceInfo()
393  );
394  },
395 
396  'PasswordFactory' => function ( MediaWikiServices $services ) : PasswordFactory {
397  $config = $services->getMainConfig();
398  return new PasswordFactory(
399  $config->get( 'PasswordConfig' ),
400  $config->get( 'PasswordDefault' )
401  );
402  },
403 
404  'PerDbNameStatsdDataFactory' =>
405  function ( MediaWikiServices $services ) : StatsdDataFactoryInterface {
406  $config = $services->getMainConfig();
407  $wiki = $config->get( 'DBname' );
409  $services->getStatsdDataFactory(),
410  $wiki
411  );
412  },
413 
414  'PermissionManager' => function ( MediaWikiServices $services ) : PermissionManager {
415  $config = $services->getMainConfig();
416  return new PermissionManager(
417  $services->getSpecialPageFactory(),
418  $config->get( 'WhitelistRead' ),
419  $config->get( 'WhitelistReadRegexp' ),
420  $config->get( 'EmailConfirmToEdit' ),
421  $config->get( 'BlockDisablesLogin' ),
422  $services->getNamespaceInfo()
423  );
424  },
425 
426  'PreferencesFactory' => function ( MediaWikiServices $services ) : PreferencesFactory {
427  $factory = new DefaultPreferencesFactory(
428  $services->getMainConfig(),
429  $services->getContentLanguage(),
430  AuthManager::singleton(),
431  $services->getLinkRendererFactory()->create()
432  );
433  $factory->setLogger( LoggerFactory::getInstance( 'preferences' ) );
434 
435  return $factory;
436  },
437 
438  'ProxyLookup' => function ( MediaWikiServices $services ) : ProxyLookup {
439  $mainConfig = $services->getMainConfig();
440  return new ProxyLookup(
441  $mainConfig->get( 'SquidServers' ),
442  $mainConfig->get( 'SquidServersNoPurge' )
443  );
444  },
445 
446  'ReadOnlyMode' => function ( MediaWikiServices $services ) : ReadOnlyMode {
447  return new ReadOnlyMode(
448  $services->getConfiguredReadOnlyMode(),
449  $services->getDBLoadBalancer()
450  );
451  },
452 
453  'ResourceLoader' => function ( MediaWikiServices $services ) : ResourceLoader {
454  global $IP;
455  $config = $services->getMainConfig();
456 
457  $rl = new ResourceLoader(
458  $config,
459  LoggerFactory::getInstance( 'resourceloader' )
460  );
461 
462  $rl->addSource( $config->get( 'ResourceLoaderSources' ) );
463 
464  // Core modules, then extension/skin modules
465  $rl->register( include "$IP/resources/Resources.php" );
466  $rl->register( $config->get( 'ResourceModules' ) );
467  Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
468 
469  if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
470  $rl->registerTestModules();
471  }
472 
473  return $rl;
474  },
475 
476  'RevisionFactory' => function ( MediaWikiServices $services ) : RevisionFactory {
477  return $services->getRevisionStore();
478  },
479 
480  'RevisionLookup' => function ( MediaWikiServices $services ) : RevisionLookup {
481  return $services->getRevisionStore();
482  },
483 
484  'RevisionRenderer' => function ( MediaWikiServices $services ) : RevisionRenderer {
485  $renderer = new RevisionRenderer(
486  $services->getDBLoadBalancer(),
487  $services->getSlotRoleRegistry()
488  );
489 
490  $renderer->setLogger( LoggerFactory::getInstance( 'SaveParse' ) );
491  return $renderer;
492  },
493 
494  'RevisionStore' => function ( MediaWikiServices $services ) : RevisionStore {
495  return $services->getRevisionStoreFactory()->getRevisionStore();
496  },
497 
498  'RevisionStoreFactory' => function ( MediaWikiServices $services ) : RevisionStoreFactory {
499  $config = $services->getMainConfig();
500  $store = new RevisionStoreFactory(
501  $services->getDBLoadBalancerFactory(),
502  $services->getBlobStoreFactory(),
503  $services->getNameTableStoreFactory(),
504  $services->getSlotRoleRegistry(),
505  $services->getMainWANObjectCache(),
506  $services->getCommentStore(),
507  $services->getActorMigration(),
508  $config->get( 'MultiContentRevisionSchemaMigrationStage' ),
509  LoggerFactory::getProvider(),
510  $config->get( 'ContentHandlerUseDB' )
511  );
512 
513  return $store;
514  },
515 
516  'SearchEngineConfig' => function ( MediaWikiServices $services ) : SearchEngineConfig {
517  return new SearchEngineConfig( $services->getMainConfig(),
518  $services->getContentLanguage() );
519  },
520 
521  'SearchEngineFactory' => function ( MediaWikiServices $services ) : SearchEngineFactory {
522  return new SearchEngineFactory( $services->getSearchEngineConfig() );
523  },
524 
525  'ShellCommandFactory' => function ( MediaWikiServices $services ) : CommandFactory {
526  $config = $services->getMainConfig();
527 
528  $limits = [
529  'time' => $config->get( 'MaxShellTime' ),
530  'walltime' => $config->get( 'MaxShellWallClockTime' ),
531  'memory' => $config->get( 'MaxShellMemory' ),
532  'filesize' => $config->get( 'MaxShellFileSize' ),
533  ];
534  $cgroup = $config->get( 'ShellCgroup' );
535  $restrictionMethod = $config->get( 'ShellRestrictionMethod' );
536 
537  $factory = new CommandFactory( $limits, $cgroup, $restrictionMethod );
538  $factory->setLogger( LoggerFactory::getInstance( 'exec' ) );
539  $factory->logStderr();
540 
541  return $factory;
542  },
543 
544  'SiteLookup' => function ( MediaWikiServices $services ) : SiteLookup {
545  // Use SiteStore as the SiteLookup as well. This was originally separated
546  // to allow for a cacheable read-only interface (using FileBasedSiteLookup),
547  // but this was never used. SiteStore has caching (see below).
548  return $services->getSiteStore();
549  },
550 
551  'SiteStore' => function ( MediaWikiServices $services ) : SiteStore {
552  $rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() );
553 
554  // TODO: replace wfGetCache with a CacheFactory service.
555  // TODO: replace wfIsHHVM with a capabilities service.
556  $cache = wfGetCache( wfIsHHVM() ? CACHE_ACCEL : CACHE_ANYTHING );
557 
558  return new CachingSiteStore( $rawSiteStore, $cache );
559  },
560 
561  'SkinFactory' => function ( MediaWikiServices $services ) : SkinFactory {
562  $factory = new SkinFactory();
563 
564  $names = $services->getMainConfig()->get( 'ValidSkinNames' );
565 
566  foreach ( $names as $name => $skin ) {
567  $factory->register( $name, $skin, function () use ( $name, $skin ) {
568  $class = "Skin$skin";
569  return new $class( $name );
570  } );
571  }
572  // Register a hidden "fallback" skin
573  $factory->register( 'fallback', 'Fallback', function () {
574  return new SkinFallback;
575  } );
576  // Register a hidden skin for api output
577  $factory->register( 'apioutput', 'ApiOutput', function () {
578  return new SkinApi;
579  } );
580 
581  return $factory;
582  },
583 
584  'SlotRoleRegistry' => function ( MediaWikiServices $services ) : SlotRoleRegistry {
585  $config = $services->getMainConfig();
586 
587  $registry = new SlotRoleRegistry(
588  $services->getNameTableStoreFactory()->getSlotRoles()
589  );
590 
591  $registry->defineRole( 'main', function () use ( $config ) {
592  return new MainSlotRoleHandler(
593  $config->get( 'NamespaceContentModels' )
594  );
595  } );
596 
597  return $registry;
598  },
599 
600  'SpecialPageFactory' => function ( MediaWikiServices $services ) : SpecialPageFactory {
601  $config = $services->getMainConfig();
602  $options = [];
603  foreach ( SpecialPageFactory::$constructorOptions as $key ) {
604  $options[$key] = $config->get( $key );
605  }
606  return new SpecialPageFactory(
607  $options,
608  $services->getContentLanguage()
609  );
610  },
611 
612  'StatsdDataFactory' => function ( MediaWikiServices $services ) : IBufferingStatsdDataFactory {
613  return new BufferingStatsdDataFactory(
614  rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' )
615  );
616  },
617 
618  'TitleFormatter' => function ( MediaWikiServices $services ) : TitleFormatter {
619  return $services->getService( '_MediaWikiTitleCodec' );
620  },
621 
622  'TitleParser' => function ( MediaWikiServices $services ) : TitleParser {
623  return $services->getService( '_MediaWikiTitleCodec' );
624  },
625 
626  'UploadRevisionImporter' => function ( MediaWikiServices $services ) : UploadRevisionImporter {
628  $services->getMainConfig()->get( 'EnableUploads' ),
629  LoggerFactory::getInstance( 'UploadRevisionImporter' )
630  );
631  },
632 
633  'VirtualRESTServiceClient' =>
635  $config = $services->getMainConfig()->get( 'VirtualRestConfig' );
636 
637  $vrsClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) );
638  foreach ( $config['paths'] as $prefix => $serviceConfig ) {
639  $class = $serviceConfig['class'];
640  // Merge in the global defaults
641  $constructArg = $serviceConfig['options'] ?? [];
642  $constructArg += $config['global'];
643  // Make the VRS service available at the mount point
644  $vrsClient->mount( $prefix, [ 'class' => $class, 'config' => $constructArg ] );
645  }
646 
647  return $vrsClient;
648  },
649 
650  'WatchedItemQueryService' =>
652  return new WatchedItemQueryService(
653  $services->getDBLoadBalancer(),
654  $services->getCommentStore(),
655  $services->getActorMigration(),
656  $services->getWatchedItemStore()
657  );
658  },
659 
660  'WatchedItemStore' => function ( MediaWikiServices $services ) : WatchedItemStore {
661  $store = new WatchedItemStore(
662  $services->getDBLoadBalancerFactory(),
664  $services->getMainObjectStash(),
665  new HashBagOStuff( [ 'maxKeys' => 100 ] ),
666  $services->getReadOnlyMode(),
667  $services->getMainConfig()->get( 'UpdateRowsPerQuery' )
668  );
669  $store->setStatsdDataFactory( $services->getStatsdDataFactory() );
670 
671  if ( $services->getMainConfig()->get( 'ReadOnlyWatchedItemStore' ) ) {
672  $store = new NoWriteWatchedItemStore( $store );
673  }
674 
675  return $store;
676  },
677 
678  'WikiRevisionOldRevisionImporterNoUpdates' =>
681  false,
682  LoggerFactory::getInstance( 'OldRevisionImporter' ),
683  $services->getDBLoadBalancer()
684  );
685  },
686 
687  '_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) : MediaWikiTitleCodec {
688  return new MediaWikiTitleCodec(
689  $services->getContentLanguage(),
690  $services->getGenderCache(),
691  $services->getMainConfig()->get( 'LocalInterwikis' ),
692  $services->getInterwikiLookup(),
693  $services->getNamespaceInfo()
694  );
695  },
696 
697  '_SqlBlobStore' => function ( MediaWikiServices $services ) : SqlBlobStore {
698  return $services->getBlobStoreFactory()->newSqlBlobStore();
699  },
700 
702  // NOTE: When adding a service here, don't forget to add a getter function
703  // in the MediaWikiServices class. The convenience getter should just call
704  // $this->getService( 'FooBarService' ).
706 
707 ];
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.
wfIsHHVM()
Check if we are running under HHVM.
const CACHE_ACCEL
Definition: Defines.php:105
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 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.
A helper class for throttling authentication attempts.
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.
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
Various HTTP related functions.
Definition: Http.php:27
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:215
Service for looking up page revisions.
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 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
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:101
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
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
static setSchemaAliases(LBFactory $lbFactory, Config $config)
const MIGRATION_NEW
Definition: Defines.php:318
Class to handle multiple HTTP requests.
static detectLocalServerCache()
Detects which local server cache library is present and returns a configuration for it...
static applyDefaultConfig(array $lbConf, Config $mainConfig, ConfiguredReadOnlyMode $readOnlyMode, BagOStuff $srvCace, BagOStuff $mainStash, WANObjectCache $wanCache)
Definition: MWLBFactory.php:46
Proxy to prefix metric keys sent to a StatsdDataFactoryInterface.
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