Go to the documentation of this file.
93 private static $instance =
null;
110 if ( self::$instance ===
null ) {
116 self::$instance = self::newInstance( $bootstrapConfig,
'load' );
119 return self::$instance;
136 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
137 throw new MWException( __METHOD__ .
' must not be used outside unit tests.' );
140 $old = self::getInstance();
186 if ( self::$instance ===
null ) {
191 self::failIfResetNotAllowed( __METHOD__ );
193 if ( $bootstrapConfig ===
null ) {
194 $bootstrapConfig = self::$instance->getBootstrapConfig();
197 $oldInstance = self::$instance;
199 self::$instance = self::newInstance( $bootstrapConfig,
'load' );
200 self::$instance->importWiring( $oldInstance, [
'BootstrapConfig' ] );
202 if ( $quick ===
'quick' ) {
203 self::$instance->salvage( $oldInstance );
205 $oldInstance->destroy();
217 foreach ( $this->getServiceNames()
as $name ) {
222 $oldService = $other->peekService(
$name );
223 }
catch ( NoSuchServiceException
$e ) {
227 if ( $oldService instanceof SalvageableService ) {
229 $newService = $this->getService(
$name );
230 $newService->salvage( $oldService );
253 $instance =
new self( $bootstrapConfig );
256 if ( $loadWiring ===
'load' ) {
257 $wiringFiles = $bootstrapConfig->
get(
'ServiceWiringFiles' );
258 $instance->loadWiringFiles( $wiringFiles );
262 Hooks::run(
'MediaWikiServices', [ $instance ] );
284 $destroy = [
'DBLoadBalancer',
'DBLoadBalancerFactory' ];
287 foreach ( $destroy
as $name ) {
309 self::resetGlobalInstance();
313 mt_srand( getmypid() );
338 if ( !defined(
'MW_PHPUNIT_TEST' ) && !defined(
'MW_PARSER_TEST' ) ) {
339 throw new MWException(
'resetServiceForTesting() must not be used outside unit tests.' );
342 $this->resetService(
$name, $destroy );
373 if ( !defined(
'MW_PHPUNIT_TEST' )
374 && !defined(
'MW_PARSER_TEST' )
375 && !defined(
'MEDIAWIKI_INSTALL' )
376 && !defined(
'RUN_MAINTENANCE_IF_MAIN' )
377 && defined(
'MW_SERVICE_BOOTSTRAP_COMPLETE' )
379 throw new MWException( $method .
' may only be called during bootstrapping and unit tests!' );
389 parent::__construct();
392 $this->defineService(
'BootstrapConfig',
function ()
use ( $config ) {
413 return $this->getService(
'BootstrapConfig' );
421 return $this->getService(
'ConfigFactory' );
432 return $this->getService(
'MainConfig' );
440 return $this->getService(
'SiteLookup' );
448 return $this->getService(
'SiteStore' );
456 return $this->getService(
'InterwikiLookup' );
464 return $this->getService(
'StatsdDataFactory' );
472 return $this->getService(
'EventRelayerGroup' );
481 return $this->getService(
'SearchEngineFactory' )->create();
489 return $this->getService(
'SearchEngineFactory' );
497 return $this->getService(
'SearchEngineConfig' );
505 return $this->getService(
'SkinFactory' );
513 return $this->getService(
'DBLoadBalancerFactory' );
521 return $this->getService(
'DBLoadBalancer' );
529 return $this->getService(
'WatchedItemStore' );
537 return $this->getService(
'WatchedItemQueryService' );
545 return $this->getService(
'CryptRand' );
553 return $this->getService(
'CryptHKDF' );
561 return $this->getService(
'MediaHandlerFactory' );
569 return $this->getService(
'MimeAnalyzer' );
577 return $this->getService(
'ProxyLookup' );
585 return $this->getService(
'Parser' );
593 return $this->getService(
'ParserCache' );
601 return $this->getService(
'GenderCache' );
609 return $this->getService(
'LinkCache' );
617 return $this->getService(
'LinkRendererFactory' );
628 return $this->getService(
'LinkRenderer' );
636 return $this->getService(
'TitleFormatter' );
644 return $this->getService(
'TitleParser' );
652 return $this->getService(
'MainObjectStash' );
660 return $this->getService(
'MainWANObjectCache' );
668 return $this->getService(
'LocalServerObjectCache' );
676 return $this->getService(
'VirtualRESTServiceClient' );
684 return $this->getService(
'ConfiguredReadOnlyMode' );
692 return $this->getService(
'ReadOnlyMode' );
700 return $this->getService(
'UploadRevisionImporter' );
708 return $this->getService(
'OldRevisionImporter' );
716 return $this->getService(
'WikiRevisionOldRevisionImporterNoUpdates' );
724 return $this->getService(
'ShellCommandFactory' );
732 return $this->getService(
'ExternalStoreFactory' );
740 return $this->getService(
'BlobStoreFactory' );
748 return $this->getService(
'_SqlBlobStore' );
756 return $this->getService(
'RevisionStore' );
764 return $this->getService(
'RevisionLookup' );
772 return $this->getService(
'RevisionFactory' );
780 return $this->getService(
'ContentModelStore' );
788 return $this->getService(
'SlotRoleStore' );
796 return $this->getService(
'PreferencesFactory' );
804 return $this->getService(
'HttpRequestFactory' );
812 return $this->getService(
'CommentStore' );
820 return $this->getService(
'ActorMigration' );
Factory class for spawning EventRelayer objects using configuration.
static clear()
Clear all the cached instances.
Functions to get cache objects.
Cache for article titles (prefixed DB keys) and ids linked from one source.
Implements functions related to MIME types such as detection and mapping to file extension.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Caches user genders when needed to use correct namespace aliases.
Factory class for SearchEngine.
Allows to change the fields on the form that will be generated $name
This class handles the logic for the actor table migration.
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
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
Virtual HTTP service client loosely styled after a Virtual File System.
Accesses configuration settings from $GLOBALS.
A title parser service for MediaWiki.
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title 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
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Factory class to create Skin objects.
Contain a class for special pages.
MediaWiki adaptation of StatsdDataFactory that provides buffering functionality.
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
Factory class to create Config objects.
Configuration handling class for SearchEngine.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.