108 private static $instance =
null;
125 if ( self::$instance ===
null ) {
131 self::$instance = self::newInstance( $bootstrapConfig,
'load' );
134 return self::$instance;
151 if ( !defined(
'MW_PHPUNIT_TEST' ) ) {
152 throw new MWException( __METHOD__ .
' must not be used outside unit tests.' );
155 $old = self::getInstance();
201 if ( self::$instance ===
null ) {
206 self::failIfResetNotAllowed( __METHOD__ );
208 if ( $bootstrapConfig ===
null ) {
209 $bootstrapConfig = self::$instance->getBootstrapConfig();
212 $oldInstance = self::$instance;
214 self::$instance = self::newInstance( $bootstrapConfig,
'load' );
215 self::$instance->importWiring( $oldInstance, [
'BootstrapConfig' ] );
217 if ( $quick ===
'quick' ) {
218 self::$instance->salvage( $oldInstance );
220 $oldInstance->destroy();
232 foreach ( $this->getServiceNames()
as $name ) {
237 $oldService = $other->peekService( $name );
238 }
catch ( NoSuchServiceException
$e ) {
242 if ( $oldService instanceof SalvageableService ) {
244 $newService = $this->getService( $name );
245 $newService->salvage( $oldService );
268 $instance =
new self( $bootstrapConfig );
271 if ( $loadWiring ===
'load' ) {
272 $wiringFiles = $bootstrapConfig->
get(
'ServiceWiringFiles' );
273 $instance->loadWiringFiles( $wiringFiles );
277 Hooks::run(
'MediaWikiServices', [ $instance ] );
299 $destroy = [
'DBLoadBalancer',
'DBLoadBalancerFactory' ];
302 foreach ( $destroy
as $name ) {
324 self::resetGlobalInstance();
328 mt_srand( getmypid() );
353 if ( !defined(
'MW_PHPUNIT_TEST' ) && !defined(
'MW_PARSER_TEST' ) ) {
354 throw new MWException(
'resetServiceForTesting() must not be used outside unit tests.' );
357 $this->resetService(
$name, $destroy );
388 if ( !defined(
'MW_PHPUNIT_TEST' )
389 && !defined(
'MW_PARSER_TEST' )
390 && !defined(
'MEDIAWIKI_INSTALL' )
391 && !defined(
'RUN_MAINTENANCE_IF_MAIN' )
392 && defined(
'MW_SERVICE_BOOTSTRAP_COMPLETE' )
394 throw new MWException( $method .
' may only be called during bootstrapping and unit tests!' );
404 parent::__construct();
407 $this->defineService(
'BootstrapConfig',
function ()
use ( $config ) {
419 return $this->getService(
'ActorMigration' );
427 return $this->getService(
'_SqlBlobStore' );
435 return $this->getService(
'BlobStoreFactory' );
452 return $this->getService(
'BootstrapConfig' );
460 return $this->getService(
'NameTableStoreFactory' )->getChangeTagDef();
468 return $this->getService(
'CommentStore' );
476 return $this->getService(
'ConfigFactory' );
484 return $this->getService(
'ConfigRepository' );
492 return $this->getService(
'ConfiguredReadOnlyMode' );
500 return $this->getService(
'ContentLanguage' );
508 return $this->getService(
'NameTableStoreFactory' )->getContentModels();
516 return $this->getService(
'CryptHKDF' );
524 return $this->getService(
'DateFormatterFactory' );
532 return $this->getService(
'DBLoadBalancer' );
540 return $this->getService(
'DBLoadBalancerFactory' );
548 return $this->getService(
'EventRelayerGroup' );
556 return $this->getService(
'ExternalStoreFactory' );
564 return $this->getService(
'GenderCache' );
572 return $this->getService(
'HttpRequestFactory' );
580 return $this->getService(
'InterwikiLookup' );
588 return $this->getService(
'LinkCache' );
599 return $this->getService(
'LinkRenderer' );
607 return $this->getService(
'LinkRendererFactory' );
615 return $this->getService(
'LocalServerObjectCache' );
623 return $this->getService(
'MagicWordFactory' );
634 return $this->getService(
'MainConfig' );
642 return $this->getService(
'MainObjectStash' );
650 return $this->getService(
'MainWANObjectCache' );
658 return $this->getService(
'MediaHandlerFactory' );
666 return $this->getService(
'MimeAnalyzer' );
674 return $this->getService(
'NamespaceInfo' );
682 return $this->getService(
'NameTableStoreFactory' );
690 return $this->getService(
'OldRevisionImporter' );
698 return $this->getService(
'Parser' );
706 return $this->getService(
'ParserCache' );
714 return $this->getService(
'ParserFactory' );
722 return $this->getService(
'PasswordFactory' );
730 return $this->getService(
'PerDbNameStatsdDataFactory' );
738 return $this->getService(
'PermissionManager' );
746 return $this->getService(
'PreferencesFactory' );
754 return $this->getService(
'ProxyLookup' );
762 return $this->getService(
'ReadOnlyMode' );
770 return $this->getService(
'ResourceLoader' );
778 return $this->getService(
'RevisionFactory' );
786 return $this->getService(
'RevisionLookup' );
794 return $this->getService(
'RevisionRenderer' );
802 return $this->getService(
'RevisionStore' );
810 return $this->getService(
'RevisionStoreFactory' );
819 return $this->getService(
'SearchEngineFactory' )->create();
827 return $this->getService(
'SearchEngineConfig' );
835 return $this->getService(
'SearchEngineFactory' );
843 return $this->getService(
'ShellCommandFactory' );
851 return $this->getService(
'SiteLookup' );
859 return $this->getService(
'SiteStore' );
867 return $this->getService(
'SkinFactory' );
875 return $this->getService(
'SlotRoleRegistry' );
883 return $this->getService(
'NameTableStoreFactory' )->getSlotRoles();
891 return $this->getService(
'SpecialPageFactory' );
899 return $this->getService(
'StatsdDataFactory' );
907 return $this->getService(
'TitleFormatter' );
915 return $this->getService(
'TitleParser' );
923 return $this->getService(
'UploadRevisionImporter' );
931 return $this->getService(
'VirtualRESTServiceClient' );
939 return $this->getService(
'WatchedItemQueryService' );
947 return $this->getService(
'WatchedItemStore' );
955 return $this->getService(
'OldRevisionImporter' );
963 return $this->getService(
'WikiRevisionOldRevisionImporterNoUpdates' );
971 return $this->getService(
'UploadRevisionImporter' );
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
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
Interface for configuration instances.
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
Wrapper for backward compatibility for old callers that used static methods.
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 null
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
Allows to change the fields on the form that will be generated $name
static clear()
Clear all the cached instances.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.