MediaWiki
1.30.0
|
MediaWikiServices is the service locator for the application scope of MediaWiki. More...
Public Member Functions | |
__construct (Config $config) | |
getBootstrapConfig () | |
Returns the Config object containing the bootstrap configuration. More... | |
getConfigFactory () | |
getConfiguredReadOnlyMode () | |
getCryptHKDF () | |
getCryptRand () | |
getDBLoadBalancer () | |
getDBLoadBalancerFactory () | |
getEventRelayerGroup () | |
getGenderCache () | |
getInterwikiLookup () | |
getLinkCache () | |
getLinkRenderer () | |
LinkRenderer instance that can be used if no custom options are needed. More... | |
getLinkRendererFactory () | |
getLocalServerObjectCache () | |
getMainConfig () | |
Returns the Config object that provides configuration for MediaWiki core. More... | |
getMainObjectStash () | |
getMainWANObjectCache () | |
getMediaHandlerFactory () | |
getMimeAnalyzer () | |
getParser () | |
getParserCache () | |
getProxyLookup () | |
getReadOnlyMode () | |
getSearchEngineConfig () | |
getSearchEngineFactory () | |
getShellCommandFactory () | |
getSiteLookup () | |
getSiteStore () | |
getSkinFactory () | |
getStatsdDataFactory () | |
getTitleFormatter () | |
getTitleParser () | |
getVirtualRESTServiceClient () | |
getWatchedItemQueryService () | |
getWatchedItemStore () | |
newSearchEngine () | |
resetServiceForTesting ( $name, $destroy=true) | |
Resets the given service for testing purposes. More... | |
Public Member Functions inherited from MediaWiki\Services\ServiceContainer | |
__construct (array $extraInstantiationParams=[]) | |
applyWiring (array $serviceInstantiators) | |
Registers multiple services (aka a "wiring"). More... | |
defineService ( $name, callable $instantiator) | |
Define a new service. More... | |
destroy () | |
Destroys all contained service instances that implement the DestructibleService interface. More... | |
disableService ( $name) | |
Disables a service. More... | |
getService ( $name) | |
Returns a service object of the kind associated with $name. More... | |
getServiceNames () | |
hasService ( $name) | |
Returns true if a service is defined for $name, that is, if a call to getService( $name ) would return a service instance. More... | |
importWiring (ServiceContainer $container, $skip=[]) | |
Imports all wiring defined in $container. More... | |
isServiceDisabled ( $name) | |
loadWiringFiles (array $wiringFiles) | |
peekService ( $name) | |
Returns the service instance for $name only if that service has already been instantiated. More... | |
redefineService ( $name, callable $instantiator) | |
Replace an already defined service. More... | |
Static Public Member Functions | |
static | disableStorageBackend () |
Disables all storage layer services. More... | |
static | failIfResetNotAllowed ( $method) |
Convenience method that throws an exception unless it is called during a phase in which resetting of global services is allowed. More... | |
static | forceGlobalInstance (MediaWikiServices $services) |
Replaces the global MediaWikiServices instance. More... | |
static | getInstance () |
Returns the global default instance of the top level service locator. More... | |
static | resetChildProcessServices () |
Resets any services that may have become stale after a child process returns from after pcntl_fork(). More... | |
static | resetGlobalInstance (Config $bootstrapConfig=null, $quick='') |
Creates a new instance of MediaWikiServices and sets it as the global default instance. More... | |
Private Member Functions | |
salvage (self $other) | |
Salvages the state of any salvageable service instances in $other. More... | |
Static Private Member Functions | |
static | newInstance (Config $bootstrapConfig, $loadWiring='') |
Creates a new MediaWikiServices instance and initializes it according to the given $bootstrapConfig. More... | |
Static Private Attributes | |
static MediaWikiServices null | $instance = null |
Additional Inherited Members | |
Protected Member Functions inherited from MediaWiki\Services\ServiceContainer | |
resetService ( $name, $destroy=true) | |
Resets a service by dropping the service instance. More... | |
MediaWikiServices is the service locator for the application scope of MediaWiki.
Its implemented as a simple configurable DI container. MediaWikiServices acts as a top level factory/registry for top level services, and builds the network of service objects that defines MediaWiki's application logic. It acts as an entry point to MediaWiki's dependency injection mechanism.
Services are defined in the "wiring" array passed to the constructor, or by calling defineService().
Definition at line 78 of file MediaWikiServices.php.
MediaWiki\MediaWikiServices::__construct | ( | Config | $config | ) |
Config | $config | The Config object to be registered as the 'BootstrapConfig' service. This has to contain at least the information needed to set up the 'ConfigFactory' service. |
Definition at line 378 of file MediaWikiServices.php.
References use.
|
static |
Disables all storage layer services.
After calling this, any attempt to access the storage layer will result in an error. Use resetGlobalInstance() to restore normal operation.
Definition at line 272 of file MediaWikiServices.php.
References $name, $services, as, and ObjectCache\clear().
Referenced by Installer\__construct(), ObjectCacheTest\testNewAnythingNoAccelNoDb(), and ObjectCacheTest\testNewAnythingNothingNoDb().
|
static |
Convenience method that throws an exception unless it is called during a phase in which resetting of global services is allowed.
In general, services should not be reset individually, since that may introduce inconsistencies.
This method will throw an exception if:
This method is intended to be used to safeguard against accidentally resetting global service instances that are not yet managed by MediaWikiServices. It is defined here in the MediaWikiServices services class to have a central place for managing service bootstrapping and resetting.
string | $method | the name of the caller method, as given by METHOD. |
MWException | if called outside bootstrap mode. |
Definition at line 362 of file MediaWikiServices.php.
|
static |
Replaces the global MediaWikiServices instance.
MWException | if called outside of PHPUnit tests. |
MediaWikiServices | $services | The new MediaWikiServices object. |
Definition at line 125 of file MediaWikiServices.php.
References $services.
MediaWiki\MediaWikiServices::getBootstrapConfig | ( | ) |
Returns the Config object containing the bootstrap configuration.
Bootstrap configuration would typically include database credentials and other information that may be needed before the ConfigFactory service can be instantiated.
Definition at line 402 of file MediaWikiServices.php.
Referenced by MediaWikiTestCase\installTestServices().
MediaWiki\MediaWikiServices::getConfigFactory | ( | ) |
MediaWiki\MediaWikiServices::getConfiguredReadOnlyMode | ( | ) |
MediaWiki\MediaWikiServices::getCryptHKDF | ( | ) |
MediaWiki\MediaWikiServices::getCryptRand | ( | ) |
MediaWiki\MediaWikiServices::getDBLoadBalancer | ( | ) |
Definition at line 510 of file MediaWikiServices.php.
MediaWiki\MediaWikiServices::getDBLoadBalancerFactory | ( | ) |
MediaWiki\MediaWikiServices::getEventRelayerGroup | ( | ) |
MediaWiki\MediaWikiServices::getGenderCache | ( | ) |
|
static |
Returns the global default instance of the top level service locator.
The default instance is initialized using the service instantiator functions defined in ServiceWiring.php.
Definition at line 99 of file MediaWikiServices.php.
Referenced by MediaWiki\Auth\Throttler\__construct(), MediaWiki\Session\SessionManager\__construct(), MediaWiki\Shell\Shell\command(), SpecialNewFiles\execute(), BatchedQueryRunner\execute(), ImageBuilder\execute(), RebuildFileCache\finalSetup(), MediaWiki\Auth\UserDataAuthenticationRequest\getFieldInfo(), MediaWiki\Auth\LegacyHookPreAuthenticationProviderTest\getProvider(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\getProvider(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\getProvider(), MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\newRandom(), MediaWiki\preOutputCommit(), MediaWiki\restInPeace(), MediaWiki\Linker\LinkRenderer\runLegacyBeginHook(), MediaWiki\setDBProfilingAgent(), MediaWiki\Auth\AuthManager\singleton(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testCheckPasswordValidity(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetNewPasswordExpiry(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetPassword(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetPasswordFactory(), GlobalTest\testReadOnlyEmpty(), GlobalTest\testReadOnlySet(), and MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testSetPasswordResetFlag().
MediaWiki\MediaWikiServices::getInterwikiLookup | ( | ) |
MediaWiki\MediaWikiServices::getLinkCache | ( | ) |
MediaWiki\MediaWikiServices::getLinkRenderer | ( | ) |
LinkRenderer instance that can be used if no custom options are needed.
Definition at line 617 of file MediaWikiServices.php.
MediaWiki\MediaWikiServices::getLinkRendererFactory | ( | ) |
MediaWiki\MediaWikiServices::getLocalServerObjectCache | ( | ) |
MediaWiki\MediaWikiServices::getMainConfig | ( | ) |
Returns the Config object that provides configuration for MediaWiki core.
This may or may not be the same object that is returned by getBootstrapConfig().
Definition at line 421 of file MediaWikiServices.php.
MediaWiki\MediaWikiServices::getMainObjectStash | ( | ) |
MediaWiki\MediaWikiServices::getMainWANObjectCache | ( | ) |
MediaWiki\MediaWikiServices::getMediaHandlerFactory | ( | ) |
MediaWiki\MediaWikiServices::getMimeAnalyzer | ( | ) |
MediaWiki\MediaWikiServices::getParser | ( | ) |
MediaWiki\MediaWikiServices::getParserCache | ( | ) |
MediaWiki\MediaWikiServices::getProxyLookup | ( | ) |
MediaWiki\MediaWikiServices::getReadOnlyMode | ( | ) |
MediaWiki\MediaWikiServices::getSearchEngineConfig | ( | ) |
MediaWiki\MediaWikiServices::getSearchEngineFactory | ( | ) |
MediaWiki\MediaWikiServices::getShellCommandFactory | ( | ) |
MediaWiki\MediaWikiServices::getSiteLookup | ( | ) |
MediaWiki\MediaWikiServices::getSiteStore | ( | ) |
MediaWiki\MediaWikiServices::getSkinFactory | ( | ) |
MediaWiki\MediaWikiServices::getStatsdDataFactory | ( | ) |
MediaWiki\MediaWikiServices::getTitleFormatter | ( | ) |
MediaWiki\MediaWikiServices::getTitleParser | ( | ) |
MediaWiki\MediaWikiServices::getVirtualRESTServiceClient | ( | ) |
MediaWiki\MediaWikiServices::getWatchedItemQueryService | ( | ) |
MediaWiki\MediaWikiServices::getWatchedItemStore | ( | ) |
|
staticprivate |
Creates a new MediaWikiServices instance and initializes it according to the given $bootstrapConfig.
In particular, all wiring files defined in the ServiceWiringFiles setting are loaded, and the MediaWikiServices hook is called.
Config | null | $bootstrapConfig | The Config object to be registered as the 'BootstrapConfig' service. |
string | $loadWiring | set this to 'load' to load the wiring files specified in the 'ServiceWiringFiles' setting in $bootstrapConfig. |
MWException | |
Definition at line 242 of file MediaWikiServices.php.
References Hooks\run().
MediaWiki\MediaWikiServices::newSearchEngine | ( | ) |
|
static |
Resets any services that may have become stale after a child process returns from after pcntl_fork().
It's also safe, but generally unnecessary, to call this method from the parent process.
Definition at line 296 of file MediaWikiServices.php.
|
static |
Creates a new instance of MediaWikiServices and sets it as the global default instance.
getInstance() will return a different MediaWikiServices object after every call to resetGlobalInstance().
Config | null | $bootstrapConfig | The Config object to be registered as the 'BootstrapConfig' service. This has to contain at least the information needed to set up the 'ConfigFactory' service. If not given, the bootstrap config of the old instance of MediaWikiServices will be re-used. If there was no previous instance, a new GlobalVarConfig object will be used to bootstrap the services. |
string | $quick | Set this to "quick" to allow expensive resources to be re-used. See SalvageableService for details. |
MWException | If called after MW_SERVICE_BOOTSTRAP_COMPLETE has been defined in Setup.php (unless MW_PHPUNIT_TEST or MEDIAWIKI_INSTALL or RUN_MAINTENANCE_IF_MAIN is defined). |
Definition at line 175 of file MediaWikiServices.php.
Referenced by Installer\__construct().
MediaWiki\MediaWikiServices::resetServiceForTesting | ( | $name, | |
$destroy = true |
|||
) |
Resets the given service for testing purposes.
string | $name | |
bool | $destroy | Whether the service instance should be destroyed if it exists. When set to false, any existing service instance will effectively be detached from the container. |
MWException | if called outside of PHPUnit tests. |
Definition at line 327 of file MediaWikiServices.php.
References $name.
Referenced by MediaWikiTestCase\installTestServices().
|
private |
Salvages the state of any salvageable service instances in $other.
MediaWikiServices | $other |
Definition at line 206 of file MediaWikiServices.php.
|
staticprivate |
Definition at line 83 of file MediaWikiServices.php.