Go to the documentation of this file.
14 use Liuggio\StatsdClient\Factory\StatsdDataFactory;
81 private static $instance =
null;
98 if ( self::$instance ===
null ) {
104 self::$instance = self::newInstance( $bootstrapConfig,
'load' );
107 return self::$instance;
124 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
125 throw new MWException( __METHOD__ .
' must not be used outside unit tests.' );
128 $old = self::getInstance();
174 if ( self::$instance ===
null ) {
179 self::failIfResetNotAllowed( __METHOD__ );
181 if ( $bootstrapConfig ===
null ) {
182 $bootstrapConfig = self::$instance->getBootstrapConfig();
185 $oldInstance = self::$instance;
187 self::$instance = self::newInstance( $bootstrapConfig,
'load' );
188 self::$instance->importWiring( $oldInstance, [
'BootstrapConfig' ] );
190 if ( $quick ===
'quick' ) {
191 self::$instance->salvage( $oldInstance );
193 $oldInstance->destroy();
205 foreach ( $this->getServiceNames()
as $name ) {
210 $oldService = $other->peekService(
$name );
211 }
catch ( NoSuchServiceException
$e ) {
215 if ( $oldService instanceof SalvageableService ) {
217 $newService = $this->getService(
$name );
218 $newService->salvage( $oldService );
240 private static function newInstance( Config $bootstrapConfig, $loadWiring =
'' ) {
241 $instance =
new self( $bootstrapConfig );
244 if ( $loadWiring ===
'load' ) {
245 $wiringFiles = $bootstrapConfig->get(
'ServiceWiringFiles' );
246 $instance->loadWiringFiles( $wiringFiles );
250 Hooks::run(
'MediaWikiServices', [ $instance ] );
272 $destroy = [
'DBLoadBalancer',
'DBLoadBalancerFactory' ];
275 foreach ( $destroy
as $name ) {
297 self::resetGlobalInstance();
301 mt_srand( getmypid() );
326 if ( !defined(
'MW_PHPUNIT_TEST' ) && !defined(
'MW_PARSER_TEST' ) ) {
327 throw new MWException(
'resetServiceForTesting() must not be used outside unit tests.' );
330 $this->resetService(
$name, $destroy );
361 if ( !defined(
'MW_PHPUNIT_TEST' )
362 && !defined(
'MW_PARSER_TEST' )
363 && !defined(
'MEDIAWIKI_INSTALL' )
364 && !defined(
'RUN_MAINTENANCE_IF_MAIN' )
365 && defined(
'MW_SERVICE_BOOTSTRAP_COMPLETE' )
367 throw new MWException( $method .
' may only be called during bootstrapping and unit tests!' );
377 parent::__construct();
380 $this->defineService(
'BootstrapConfig',
function()
use ( $config ) {
401 return $this->getService(
'BootstrapConfig' );
409 return $this->getService(
'ConfigFactory' );
420 return $this->getService(
'MainConfig' );
428 return $this->getService(
'SiteLookup' );
436 return $this->getService(
'SiteStore' );
444 return $this->getService(
'InterwikiLookup' );
452 return $this->getService(
'StatsdDataFactory' );
460 return $this->getService(
'EventRelayerGroup' );
469 return $this->getService(
'SearchEngineFactory' )->create();
477 return $this->getService(
'SearchEngineFactory' );
485 return $this->getService(
'SearchEngineConfig' );
493 return $this->getService(
'SkinFactory' );
501 return $this->getService(
'DBLoadBalancerFactory' );
509 return $this->getService(
'DBLoadBalancer' );
517 return $this->getService(
'WatchedItemStore' );
525 return $this->getService(
'WatchedItemQueryService' );
533 return $this->getService(
'CryptRand' );
541 return $this->getService(
'CryptHKDF' );
549 return $this->getService(
'MediaHandlerFactory' );
557 return $this->getService(
'MimeAnalyzer' );
565 return $this->getService(
'ProxyLookup' );
573 return $this->getService(
'Parser' );
581 return $this->getService(
'GenderCache' );
589 return $this->getService(
'LinkCache' );
597 return $this->getService(
'LinkRendererFactory' );
608 return $this->getService(
'LinkRenderer' );
616 return $this->getService(
'TitleFormatter' );
624 return $this->getService(
'TitleParser' );
632 return $this->getService(
'MainObjectStash' );
640 return $this->getService(
'MainWANObjectCache' );
648 return $this->getService(
'LocalServerObjectCache' );
656 return $this->getService(
'VirtualRESTServiceClient' );
664 return $this->getService(
'ConfiguredReadOnlyMode' );
672 return $this->getService(
'ReadOnlyMode' );
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.
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.