12 use Liuggio\StatsdClient\Factory\StatsdDataFactory;
73 private static $instance = null;
90 if ( self::$instance === null ) {
96 self::$instance = self::newInstance( $bootstrapConfig,
'load' );
99 return self::$instance;
116 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
117 throw new MWException( __METHOD__ .
' must not be used outside unit tests.' );
120 $old = self::getInstance();
166 if ( self::$instance === null ) {
171 self::failIfResetNotAllowed( __METHOD__ );
173 if ( $bootstrapConfig === null ) {
174 $bootstrapConfig = self::$instance->getBootstrapConfig();
177 $oldInstance = self::$instance;
179 self::$instance = self::newInstance( $bootstrapConfig );
180 self::$instance->importWiring( $oldInstance, [
'BootstrapConfig' ] );
182 if ( $quick ===
'quick' ) {
183 self::$instance->salvage( $oldInstance );
185 $oldInstance->destroy();
198 foreach ( $this->getServiceNames()
as $name ) {
199 $oldService = $other->peekService( $name );
201 if ( $oldService instanceof SalvageableService ) {
203 $newService = $this->getService( $name );
204 $newService->salvage( $oldService );
227 $instance =
new self( $bootstrapConfig );
230 if ( $loadWiring ===
'load' ) {
231 $wiringFiles = $bootstrapConfig->
get(
'ServiceWiringFiles' );
232 $instance->loadWiringFiles( $wiringFiles );
236 Hooks::run(
'MediaWikiServices', [ $instance ] );
258 $destroy = [
'DBLoadBalancer',
'DBLoadBalancerFactory' ];
261 foreach ( $destroy
as $name ) {
283 self::resetGlobalInstance();
287 mt_srand( getmypid() );
312 if ( !defined(
'MW_PHPUNIT_TEST' ) && !defined(
'MW_PARSER_TEST' ) ) {
313 throw new MWException(
'resetServiceForTesting() must not be used outside unit tests.' );
316 $this->resetService(
$name, $destroy );
347 if ( !defined(
'MW_PHPUNIT_TEST' )
348 && !defined(
'MW_PARSER_TEST' )
349 && !defined(
'MEDIAWIKI_INSTALL' )
350 && !defined(
'RUN_MAINTENANCE_IF_MAIN' )
351 && defined(
'MW_SERVICE_BOOTSTRAP_COMPLETE' )
353 throw new MWException( $method .
' may only be called during bootstrapping and unit tests!' );
363 parent::__construct();
366 $this->defineService(
'BootstrapConfig',
function()
use ( $config ) {
387 return $this->getService(
'BootstrapConfig' );
395 return $this->getService(
'ConfigFactory' );
406 return $this->getService(
'MainConfig' );
414 return $this->getService(
'SiteLookup' );
422 return $this->getService(
'SiteStore' );
430 return $this->getService(
'InterwikiLookup' );
438 return $this->getService(
'StatsdDataFactory' );
446 return $this->getService(
'EventRelayerGroup' );
455 return $this->getService(
'SearchEngineFactory' )->create();
463 return $this->getService(
'SearchEngineFactory' );
471 return $this->getService(
'SearchEngineConfig' );
479 return $this->getService(
'SkinFactory' );
487 return $this->getService(
'DBLoadBalancerFactory' );
495 return $this->getService(
'DBLoadBalancer' );
503 return $this->getService(
'WatchedItemStore' );
511 return $this->getService(
'WatchedItemQueryService' );
519 return $this->getService(
'GenderCache' );
527 return $this->getService(
'LinkCache' );
535 return $this->getService(
'LinkRendererFactory' );
546 return $this->getService(
'LinkRenderer' );
554 return $this->getService(
'TitleFormatter' );
562 return $this->getService(
'TitleParser' );
Factory class to create Skin objects.
Factory class to create Config objects.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Configuration handling class for SearchEngine.
get($name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
Storage layer class for WatchedItems.
Factory class for spawning EventRelayer objects using configuration.
Accesses configuration settings from $GLOBALS.
Database load balancing object.
Interface for configuration instances.
An interface for generating database load balancers.
A title parser service for MediaWiki.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
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
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
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
Factory class for SearchEngine.
Caches user genders when needed to use correct namespace aliases.
Cache for article titles (prefixed DB keys) and ids linked from one source.
Contain a class for special pages.
static clear()
Clear all the cached instances.
Functions to get cache objects.
Allows to change the fields on the form that will be generated $name