Go to the documentation of this file.
83 private static $instance =
null;
100 if ( self::$instance ===
null ) {
106 self::$instance = self::newInstance( $bootstrapConfig,
'load' );
109 return self::$instance;
126 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
127 throw new MWException( __METHOD__ .
' must not be used outside unit tests.' );
130 $old = self::getInstance();
176 if ( self::$instance ===
null ) {
181 self::failIfResetNotAllowed( __METHOD__ );
183 if ( $bootstrapConfig ===
null ) {
184 $bootstrapConfig = self::$instance->getBootstrapConfig();
187 $oldInstance = self::$instance;
189 self::$instance = self::newInstance( $bootstrapConfig,
'load' );
190 self::$instance->importWiring( $oldInstance, [
'BootstrapConfig' ] );
192 if ( $quick ===
'quick' ) {
193 self::$instance->salvage( $oldInstance );
195 $oldInstance->destroy();
207 foreach ( $this->getServiceNames()
as $name ) {
212 $oldService = $other->peekService(
$name );
213 }
catch ( NoSuchServiceException
$e ) {
217 if ( $oldService instanceof SalvageableService ) {
219 $newService = $this->getService(
$name );
220 $newService->salvage( $oldService );
242 private static function newInstance( Config $bootstrapConfig, $loadWiring =
'' ) {
243 $instance =
new self( $bootstrapConfig );
246 if ( $loadWiring ===
'load' ) {
247 $wiringFiles = $bootstrapConfig->get(
'ServiceWiringFiles' );
248 $instance->loadWiringFiles( $wiringFiles );
252 Hooks::run(
'MediaWikiServices', [ $instance ] );
274 $destroy = [
'DBLoadBalancer',
'DBLoadBalancerFactory' ];
277 foreach ( $destroy
as $name ) {
299 self::resetGlobalInstance();
303 mt_srand( getmypid() );
328 if ( !defined(
'MW_PHPUNIT_TEST' ) && !defined(
'MW_PARSER_TEST' ) ) {
329 throw new MWException(
'resetServiceForTesting() must not be used outside unit tests.' );
332 $this->resetService(
$name, $destroy );
363 if ( !defined(
'MW_PHPUNIT_TEST' )
364 && !defined(
'MW_PARSER_TEST' )
365 && !defined(
'MEDIAWIKI_INSTALL' )
366 && !defined(
'RUN_MAINTENANCE_IF_MAIN' )
367 && defined(
'MW_SERVICE_BOOTSTRAP_COMPLETE' )
369 throw new MWException( $method .
' may only be called during bootstrapping and unit tests!' );
379 parent::__construct();
382 $this->defineService(
'BootstrapConfig',
function ()
use ( $config ) {
403 return $this->getService(
'BootstrapConfig' );
411 return $this->getService(
'ConfigFactory' );
422 return $this->getService(
'MainConfig' );
430 return $this->getService(
'SiteLookup' );
438 return $this->getService(
'SiteStore' );
446 return $this->getService(
'InterwikiLookup' );
454 return $this->getService(
'StatsdDataFactory' );
462 return $this->getService(
'EventRelayerGroup' );
471 return $this->getService(
'SearchEngineFactory' )->create();
479 return $this->getService(
'SearchEngineFactory' );
487 return $this->getService(
'SearchEngineConfig' );
495 return $this->getService(
'SkinFactory' );
503 return $this->getService(
'DBLoadBalancerFactory' );
511 return $this->getService(
'DBLoadBalancer' );
519 return $this->getService(
'WatchedItemStore' );
527 return $this->getService(
'WatchedItemQueryService' );
535 return $this->getService(
'CryptRand' );
543 return $this->getService(
'CryptHKDF' );
551 return $this->getService(
'MediaHandlerFactory' );
559 return $this->getService(
'MimeAnalyzer' );
567 return $this->getService(
'ProxyLookup' );
575 return $this->getService(
'Parser' );
583 return $this->getService(
'ParserCache' );
591 return $this->getService(
'GenderCache' );
599 return $this->getService(
'LinkCache' );
607 return $this->getService(
'LinkRendererFactory' );
618 return $this->getService(
'LinkRenderer' );
626 return $this->getService(
'TitleFormatter' );
634 return $this->getService(
'TitleParser' );
642 return $this->getService(
'MainObjectStash' );
650 return $this->getService(
'MainWANObjectCache' );
658 return $this->getService(
'LocalServerObjectCache' );
666 return $this->getService(
'VirtualRESTServiceClient' );
674 return $this->getService(
'ConfiguredReadOnlyMode' );
682 return $this->getService(
'ReadOnlyMode' );
690 return $this->getService(
'ShellCommandFactory' );
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
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
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.
Storage layer class for WatchedItems.
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.