MediaWikiServices.php 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. <?php
  2. namespace MediaWiki;
  3. use ActorMigration;
  4. use CommentStore;
  5. use Config;
  6. use ConfigFactory;
  7. use CryptHKDF;
  8. use DateFormatterFactory;
  9. use EventRelayerGroup;
  10. use GenderCache;
  11. use GlobalVarConfig;
  12. use Hooks;
  13. use IBufferingStatsdDataFactory;
  14. use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
  15. use LocalisationCache;
  16. use MediaWiki\Block\BlockManager;
  17. use MediaWiki\Block\BlockRestrictionStore;
  18. use MediaWiki\FileBackend\FSFile\TempFSFileFactory;
  19. use MediaWiki\FileBackend\LockManager\LockManagerGroupFactory;
  20. use MediaWiki\Http\HttpRequestFactory;
  21. use PasswordReset;
  22. use MediaWiki\Languages\LanguageNameUtils;
  23. use Wikimedia\Message\IMessageFormatterFactory;
  24. use MediaWiki\Page\MovePageFactory;
  25. use MediaWiki\Permissions\PermissionManager;
  26. use MediaWiki\Preferences\PreferencesFactory;
  27. use MediaWiki\Revision\RevisionRenderer;
  28. use MediaWiki\Revision\SlotRoleRegistry;
  29. use MediaWiki\Shell\CommandFactory;
  30. use MediaWiki\Special\SpecialPageFactory;
  31. use MediaWiki\Storage\BlobStore;
  32. use MediaWiki\Storage\BlobStoreFactory;
  33. use MediaWiki\Storage\NameTableStore;
  34. use MediaWiki\Storage\NameTableStoreFactory;
  35. use MediaWiki\Revision\RevisionFactory;
  36. use MediaWiki\Revision\RevisionLookup;
  37. use MediaWiki\Revision\RevisionStore;
  38. use OldRevisionImporter;
  39. use MediaWiki\Revision\RevisionStoreFactory;
  40. use UploadRevisionImporter;
  41. use Wikimedia\Rdbms\ILoadBalancer;
  42. use LinkCache;
  43. use MediaHandlerFactory;
  44. use MediaWiki\Config\ConfigRepository;
  45. use MediaWiki\Linker\LinkRenderer;
  46. use MediaWiki\Linker\LinkRendererFactory;
  47. use MWException;
  48. use MessageCache;
  49. use MimeAnalyzer;
  50. use NamespaceInfo;
  51. use ObjectCache;
  52. use Parser;
  53. use ParserCache;
  54. use ParserFactory;
  55. use PasswordFactory;
  56. use ProxyLookup;
  57. use RepoGroup;
  58. use ResourceLoader;
  59. use SearchEngine;
  60. use SearchEngineConfig;
  61. use SearchEngineFactory;
  62. use SiteLookup;
  63. use SiteStore;
  64. use WatchedItemStoreInterface;
  65. use WatchedItemQueryService;
  66. use SkinFactory;
  67. use TitleFormatter;
  68. use TitleParser;
  69. use VirtualRESTServiceClient;
  70. use Wikimedia\ObjectFactory;
  71. use Wikimedia\Rdbms\LBFactory;
  72. use Wikimedia\Services\SalvageableService;
  73. use Wikimedia\Services\ServiceContainer;
  74. use Wikimedia\Services\NoSuchServiceException;
  75. use MediaWiki\Interwiki\InterwikiLookup;
  76. use MagicWordFactory;
  77. use MediaWiki\Storage\PageEditStash;
  78. /**
  79. * Service locator for MediaWiki core services.
  80. *
  81. * This program is free software; you can redistribute it and/or modify
  82. * it under the terms of the GNU General Public License as published by
  83. * the Free Software Foundation; either version 2 of the License, or
  84. * (at your option) any later version.
  85. *
  86. * This program is distributed in the hope that it will be useful,
  87. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  88. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  89. * GNU General Public License for more details.
  90. *
  91. * You should have received a copy of the GNU General Public License along
  92. * with this program; if not, write to the Free Software Foundation, Inc.,
  93. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  94. * http://www.gnu.org/copyleft/gpl.html
  95. *
  96. * @file
  97. *
  98. * @since 1.27
  99. */
  100. /**
  101. * MediaWikiServices is the service locator for the application scope of MediaWiki.
  102. * Its implemented as a simple configurable DI container.
  103. * MediaWikiServices acts as a top level factory/registry for top level services, and builds
  104. * the network of service objects that defines MediaWiki's application logic.
  105. * It acts as an entry point to MediaWiki's dependency injection mechanism.
  106. *
  107. * Services are defined in the "wiring" array passed to the constructor,
  108. * or by calling defineService().
  109. *
  110. * @see docs/injection.txt for an overview of using dependency injection in the
  111. * MediaWiki code base.
  112. */
  113. class MediaWikiServices extends ServiceContainer {
  114. /**
  115. * @var MediaWikiServices|null
  116. */
  117. private static $instance = null;
  118. /**
  119. * Returns the global default instance of the top level service locator.
  120. *
  121. * @since 1.27
  122. *
  123. * The default instance is initialized using the service instantiator functions
  124. * defined in ServiceWiring.php.
  125. *
  126. * @note This should only be called by static functions! The instance returned here
  127. * should not be passed around! Objects that need access to a service should have
  128. * that service injected into the constructor, never a service locator!
  129. *
  130. * @return MediaWikiServices
  131. */
  132. public static function getInstance() {
  133. if ( self::$instance === null ) {
  134. // NOTE: constructing GlobalVarConfig here is not particularly pretty,
  135. // but some information from the global scope has to be injected here,
  136. // even if it's just a file name or database credentials to load
  137. // configuration from.
  138. $bootstrapConfig = new GlobalVarConfig();
  139. self::$instance = self::newInstance( $bootstrapConfig, 'load' );
  140. }
  141. return self::$instance;
  142. }
  143. /**
  144. * Replaces the global MediaWikiServices instance.
  145. *
  146. * @since 1.28
  147. *
  148. * @note This is for use in PHPUnit tests only!
  149. *
  150. * @throws MWException if called outside of PHPUnit tests.
  151. *
  152. * @param MediaWikiServices $services The new MediaWikiServices object.
  153. *
  154. * @return MediaWikiServices The old MediaWikiServices object, so it can be restored later.
  155. */
  156. public static function forceGlobalInstance( MediaWikiServices $services ) {
  157. if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
  158. throw new MWException( __METHOD__ . ' must not be used outside unit tests.' );
  159. }
  160. $old = self::getInstance();
  161. self::$instance = $services;
  162. return $old;
  163. }
  164. /**
  165. * Creates a new instance of MediaWikiServices and sets it as the global default
  166. * instance. getInstance() will return a different MediaWikiServices object
  167. * after every call to resetGlobalInstance().
  168. *
  169. * @since 1.28
  170. *
  171. * @warning This should not be used during normal operation. It is intended for use
  172. * when the configuration has changed significantly since bootstrap time, e.g.
  173. * during the installation process or during testing.
  174. *
  175. * @warning Calling resetGlobalInstance() may leave the application in an inconsistent
  176. * state. Calling this is only safe under the ASSUMPTION that NO REFERENCE to
  177. * any of the services managed by MediaWikiServices exist. If any service objects
  178. * managed by the old MediaWikiServices instance remain in use, they may INTERFERE
  179. * with the operation of the services managed by the new MediaWikiServices.
  180. * Operating with a mix of services created by the old and the new
  181. * MediaWikiServices instance may lead to INCONSISTENCIES and even DATA LOSS!
  182. * Any class implementing LAZY LOADING is especially prone to this problem,
  183. * since instances would typically retain a reference to a storage layer service.
  184. *
  185. * @see forceGlobalInstance()
  186. * @see resetGlobalInstance()
  187. * @see resetBetweenTest()
  188. *
  189. * @param Config|null $bootstrapConfig The Config object to be registered as the
  190. * 'BootstrapConfig' service. This has to contain at least the information
  191. * needed to set up the 'ConfigFactory' service. If not given, the bootstrap
  192. * config of the old instance of MediaWikiServices will be re-used. If there
  193. * was no previous instance, a new GlobalVarConfig object will be used to
  194. * bootstrap the services.
  195. *
  196. * @param string $quick Set this to "quick" to allow expensive resources to be re-used.
  197. * See SalvageableService for details.
  198. *
  199. * @throws MWException If called after MW_SERVICE_BOOTSTRAP_COMPLETE has been defined in
  200. * Setup.php (unless MW_PHPUNIT_TEST or MEDIAWIKI_INSTALL or RUN_MAINTENANCE_IF_MAIN
  201. * is defined).
  202. */
  203. public static function resetGlobalInstance( Config $bootstrapConfig = null, $quick = '' ) {
  204. if ( self::$instance === null ) {
  205. // no global instance yet, nothing to reset
  206. return;
  207. }
  208. self::failIfResetNotAllowed( __METHOD__ );
  209. if ( $bootstrapConfig === null ) {
  210. $bootstrapConfig = self::$instance->getBootstrapConfig();
  211. }
  212. $oldInstance = self::$instance;
  213. self::$instance = self::newInstance( $bootstrapConfig, 'load' );
  214. self::$instance->importWiring( $oldInstance, [ 'BootstrapConfig' ] );
  215. if ( $quick === 'quick' ) {
  216. self::$instance->salvage( $oldInstance );
  217. } else {
  218. $oldInstance->destroy();
  219. }
  220. }
  221. /** @noinspection PhpDocSignatureInspection */
  222. /**
  223. * Salvages the state of any salvageable service instances in $other.
  224. *
  225. * @note $other will have been destroyed when salvage() returns.
  226. *
  227. * @param MediaWikiServices $other
  228. */
  229. private function salvage( self $other ) {
  230. foreach ( $this->getServiceNames() as $name ) {
  231. // The service could be new in the new instance and not registered in the
  232. // other instance (e.g. an extension that was loaded after the instantiation of
  233. // the other instance. Skip this service in this case. See T143974
  234. try {
  235. $oldService = $other->peekService( $name );
  236. } catch ( NoSuchServiceException $e ) {
  237. continue;
  238. }
  239. if ( $oldService instanceof SalvageableService ) {
  240. /** @var SalvageableService $newService */
  241. $newService = $this->getService( $name );
  242. $newService->salvage( $oldService );
  243. }
  244. }
  245. $other->destroy();
  246. }
  247. /**
  248. * Creates a new MediaWikiServices instance and initializes it according to the
  249. * given $bootstrapConfig. In particular, all wiring files defined in the
  250. * ServiceWiringFiles setting are loaded, and the MediaWikiServices hook is called.
  251. *
  252. * @param Config|null $bootstrapConfig The Config object to be registered as the
  253. * 'BootstrapConfig' service.
  254. *
  255. * @param string $loadWiring set this to 'load' to load the wiring files specified
  256. * in the 'ServiceWiringFiles' setting in $bootstrapConfig.
  257. *
  258. * @return MediaWikiServices
  259. * @throws MWException
  260. * @throws \FatalError
  261. */
  262. private static function newInstance( Config $bootstrapConfig, $loadWiring = '' ) {
  263. $instance = new self( $bootstrapConfig );
  264. // Load the default wiring from the specified files.
  265. if ( $loadWiring === 'load' ) {
  266. $wiringFiles = $bootstrapConfig->get( 'ServiceWiringFiles' );
  267. $instance->loadWiringFiles( $wiringFiles );
  268. }
  269. // Provide a traditional hook point to allow extensions to configure services.
  270. Hooks::run( 'MediaWikiServices', [ $instance ] );
  271. return $instance;
  272. }
  273. /**
  274. * Disables all storage layer services. After calling this, any attempt to access the
  275. * storage layer will result in an error. Use resetGlobalInstance() to restore normal
  276. * operation.
  277. *
  278. * @since 1.28
  279. *
  280. * @warning This is intended for extreme situations only and should never be used
  281. * while serving normal web requests. Legitimate use cases for this method include
  282. * the installation process. Test fixtures may also use this, if the fixture relies
  283. * on globalState.
  284. *
  285. * @see resetGlobalInstance()
  286. * @see resetChildProcessServices()
  287. */
  288. public static function disableStorageBackend() {
  289. // TODO: also disable some Caches, JobQueues, etc
  290. $destroy = [ 'DBLoadBalancer', 'DBLoadBalancerFactory' ];
  291. $services = self::getInstance();
  292. foreach ( $destroy as $name ) {
  293. $services->disableService( $name );
  294. }
  295. ObjectCache::clear();
  296. }
  297. /**
  298. * Resets any services that may have become stale after a child process
  299. * returns from after pcntl_fork(). It's also safe, but generally unnecessary,
  300. * to call this method from the parent process.
  301. *
  302. * @since 1.28
  303. *
  304. * @note This is intended for use in the context of process forking only!
  305. *
  306. * @see resetGlobalInstance()
  307. * @see disableStorageBackend()
  308. */
  309. public static function resetChildProcessServices() {
  310. // NOTE: for now, just reset everything. Since we don't know the interdependencies
  311. // between services, we can't do this more selectively at this time.
  312. self::resetGlobalInstance();
  313. // Child, reseed because there is no bug in PHP:
  314. // https://bugs.php.net/bug.php?id=42465
  315. mt_srand( getmypid() );
  316. }
  317. /**
  318. * Resets the given service for testing purposes.
  319. *
  320. * @since 1.28
  321. *
  322. * @warning This is generally unsafe! Other services may still retain references
  323. * to the stale service instance, leading to failures and inconsistencies. Subclasses
  324. * may use this method to reset specific services under specific instances, but
  325. * it should not be exposed to application logic.
  326. *
  327. * @note With proper dependency injection used throughout the codebase, this method
  328. * should not be needed. It is provided to allow tests that pollute global service
  329. * instances to clean up.
  330. *
  331. * @param string $name
  332. * @param bool $destroy Whether the service instance should be destroyed if it exists.
  333. * When set to false, any existing service instance will effectively be detached
  334. * from the container.
  335. *
  336. * @throws MWException if called outside of PHPUnit tests.
  337. */
  338. public function resetServiceForTesting( $name, $destroy = true ) {
  339. if ( !defined( 'MW_PHPUNIT_TEST' ) && !defined( 'MW_PARSER_TEST' ) ) {
  340. throw new MWException( 'resetServiceForTesting() must not be used outside unit tests.' );
  341. }
  342. $this->resetService( $name, $destroy );
  343. }
  344. /**
  345. * Convenience method that throws an exception unless it is called during a phase in which
  346. * resetting of global services is allowed. In general, services should not be reset
  347. * individually, since that may introduce inconsistencies.
  348. *
  349. * @since 1.28
  350. *
  351. * This method will throw an exception if:
  352. *
  353. * - self::$resetInProgress is false (to allow all services to be reset together
  354. * via resetGlobalInstance)
  355. * - and MEDIAWIKI_INSTALL is not defined (to allow services to be reset during installation)
  356. * - and MW_PHPUNIT_TEST is not defined (to allow services to be reset during testing)
  357. *
  358. * This method is intended to be used to safeguard against accidentally resetting
  359. * global service instances that are not yet managed by MediaWikiServices. It is
  360. * defined here in the MediaWikiServices services class to have a central place
  361. * for managing service bootstrapping and resetting.
  362. *
  363. * @param string $method the name of the caller method, as given by __METHOD__.
  364. *
  365. * @throws MWException if called outside bootstrap mode.
  366. *
  367. * @see resetGlobalInstance()
  368. * @see forceGlobalInstance()
  369. * @see disableStorageBackend()
  370. */
  371. public static function failIfResetNotAllowed( $method ) {
  372. if ( !defined( 'MW_PHPUNIT_TEST' )
  373. && !defined( 'MW_PARSER_TEST' )
  374. && !defined( 'MEDIAWIKI_INSTALL' )
  375. && !defined( 'RUN_MAINTENANCE_IF_MAIN' )
  376. && defined( 'MW_SERVICE_BOOTSTRAP_COMPLETE' )
  377. ) {
  378. throw new MWException( $method . ' may only be called during bootstrapping and unit tests!' );
  379. }
  380. }
  381. /**
  382. * @param Config $config The Config object to be registered as the 'BootstrapConfig' service.
  383. * This has to contain at least the information needed to set up the 'ConfigFactory'
  384. * service.
  385. */
  386. public function __construct( Config $config ) {
  387. parent::__construct();
  388. // Register the given Config object as the bootstrap config service.
  389. $this->defineService( 'BootstrapConfig', function () use ( $config ) {
  390. return $config;
  391. } );
  392. }
  393. // CONVENIENCE GETTERS ////////////////////////////////////////////////////
  394. /**
  395. * @since 1.31
  396. * @return ActorMigration
  397. */
  398. public function getActorMigration() {
  399. return $this->getService( 'ActorMigration' );
  400. }
  401. /**
  402. * @since 1.34
  403. * @return BadFileLookup
  404. */
  405. public function getBadFileLookup() : BadFileLookup {
  406. return $this->getService( 'BadFileLookup' );
  407. }
  408. /**
  409. * @since 1.31
  410. * @return BlobStore
  411. */
  412. public function getBlobStore() {
  413. return $this->getService( '_SqlBlobStore' );
  414. }
  415. /**
  416. * @since 1.31
  417. * @return BlobStoreFactory
  418. */
  419. public function getBlobStoreFactory() {
  420. return $this->getService( 'BlobStoreFactory' );
  421. }
  422. /**
  423. * @since 1.34
  424. * @return BlockManager
  425. */
  426. public function getBlockManager() : BlockManager {
  427. return $this->getService( 'BlockManager' );
  428. }
  429. /**
  430. * @since 1.33
  431. * @return BlockRestrictionStore
  432. */
  433. public function getBlockRestrictionStore() : BlockRestrictionStore {
  434. return $this->getService( 'BlockRestrictionStore' );
  435. }
  436. /**
  437. * Returns the Config object containing the bootstrap configuration.
  438. * Bootstrap configuration would typically include database credentials
  439. * and other information that may be needed before the ConfigFactory
  440. * service can be instantiated.
  441. *
  442. * @note This should only be used during bootstrapping, in particular
  443. * when creating the MainConfig service. Application logic should
  444. * use getMainConfig() to get a Config instances.
  445. *
  446. * @since 1.27
  447. * @return Config
  448. */
  449. public function getBootstrapConfig() {
  450. return $this->getService( 'BootstrapConfig' );
  451. }
  452. /**
  453. * @since 1.32
  454. * @return NameTableStore
  455. */
  456. public function getChangeTagDefStore() {
  457. return $this->getService( 'NameTableStoreFactory' )->getChangeTagDef();
  458. }
  459. /**
  460. * @since 1.31
  461. * @return CommentStore
  462. */
  463. public function getCommentStore() {
  464. return $this->getService( 'CommentStore' );
  465. }
  466. /**
  467. * @since 1.27
  468. * @return ConfigFactory
  469. */
  470. public function getConfigFactory() {
  471. return $this->getService( 'ConfigFactory' );
  472. }
  473. /**
  474. * @since 1.32
  475. * @return ConfigRepository
  476. */
  477. public function getConfigRepository() {
  478. return $this->getService( 'ConfigRepository' );
  479. }
  480. /**
  481. * @since 1.29
  482. * @return \ConfiguredReadOnlyMode
  483. */
  484. public function getConfiguredReadOnlyMode() {
  485. return $this->getService( 'ConfiguredReadOnlyMode' );
  486. }
  487. /**
  488. * @since 1.32
  489. * @return \Language
  490. */
  491. public function getContentLanguage() {
  492. return $this->getService( 'ContentLanguage' );
  493. }
  494. /**
  495. * @since 1.31
  496. * @return NameTableStore
  497. */
  498. public function getContentModelStore() {
  499. return $this->getService( 'NameTableStoreFactory' )->getContentModels();
  500. }
  501. /**
  502. * @since 1.28
  503. * @return CryptHKDF
  504. */
  505. public function getCryptHKDF() {
  506. return $this->getService( 'CryptHKDF' );
  507. }
  508. /**
  509. * @since 1.33
  510. * @return DateFormatterFactory
  511. */
  512. public function getDateFormatterFactory() {
  513. return $this->getService( 'DateFormatterFactory' );
  514. }
  515. /**
  516. * @since 1.28
  517. * @return ILoadBalancer The main DB load balancer for the local wiki.
  518. */
  519. public function getDBLoadBalancer() {
  520. return $this->getService( 'DBLoadBalancer' );
  521. }
  522. /**
  523. * @since 1.28
  524. * @return LBFactory
  525. */
  526. public function getDBLoadBalancerFactory() {
  527. return $this->getService( 'DBLoadBalancerFactory' );
  528. }
  529. /**
  530. * @since 1.27
  531. * @return EventRelayerGroup
  532. */
  533. public function getEventRelayerGroup() {
  534. return $this->getService( 'EventRelayerGroup' );
  535. }
  536. /**
  537. * @since 1.34
  538. * @return \ExternalStoreAccess
  539. */
  540. public function getExternalStoreAccess() {
  541. return $this->getService( 'ExternalStoreAccess' );
  542. }
  543. /**
  544. * @since 1.31
  545. * @return \ExternalStoreFactory
  546. */
  547. public function getExternalStoreFactory() {
  548. return $this->getService( 'ExternalStoreFactory' );
  549. }
  550. /**
  551. * @since 1.28
  552. * @return GenderCache
  553. */
  554. public function getGenderCache() {
  555. return $this->getService( 'GenderCache' );
  556. }
  557. /**
  558. * @since 1.31
  559. * @return HttpRequestFactory
  560. */
  561. public function getHttpRequestFactory() {
  562. return $this->getService( 'HttpRequestFactory' );
  563. }
  564. /**
  565. * @since 1.28
  566. * @return InterwikiLookup
  567. */
  568. public function getInterwikiLookup() {
  569. return $this->getService( 'InterwikiLookup' );
  570. }
  571. /**
  572. * @since 1.34
  573. * @return LanguageNameUtils
  574. */
  575. public function getLanguageNameUtils() {
  576. return $this->getService( 'LanguageNameUtils' );
  577. }
  578. /**
  579. * @since 1.28
  580. * @return LinkCache
  581. */
  582. public function getLinkCache() {
  583. return $this->getService( 'LinkCache' );
  584. }
  585. /**
  586. * LinkRenderer instance that can be used
  587. * if no custom options are needed
  588. *
  589. * @since 1.28
  590. * @return LinkRenderer
  591. */
  592. public function getLinkRenderer() {
  593. return $this->getService( 'LinkRenderer' );
  594. }
  595. /**
  596. * @since 1.28
  597. * @return LinkRendererFactory
  598. */
  599. public function getLinkRendererFactory() {
  600. return $this->getService( 'LinkRendererFactory' );
  601. }
  602. /**
  603. * @since 1.34
  604. * @return LocalisationCache
  605. */
  606. public function getLocalisationCache() : LocalisationCache {
  607. return $this->getService( 'LocalisationCache' );
  608. }
  609. /**
  610. * @since 1.28
  611. * @return \BagOStuff
  612. */
  613. public function getLocalServerObjectCache() {
  614. return $this->getService( 'LocalServerObjectCache' );
  615. }
  616. /**
  617. * @since 1.34
  618. * @return LockManagerGroupFactory
  619. */
  620. public function getLockManagerGroupFactory() : LockManagerGroupFactory {
  621. return $this->getService( 'LockManagerGroupFactory' );
  622. }
  623. /**
  624. * @since 1.32
  625. * @return MagicWordFactory
  626. */
  627. public function getMagicWordFactory() {
  628. return $this->getService( 'MagicWordFactory' );
  629. }
  630. /**
  631. * Returns the Config object that provides configuration for MediaWiki core.
  632. * This may or may not be the same object that is returned by getBootstrapConfig().
  633. *
  634. * @since 1.27
  635. * @return Config
  636. */
  637. public function getMainConfig() {
  638. return $this->getService( 'MainConfig' );
  639. }
  640. /**
  641. * @since 1.28
  642. * @return \BagOStuff
  643. */
  644. public function getMainObjectStash() {
  645. return $this->getService( 'MainObjectStash' );
  646. }
  647. /**
  648. * @since 1.28
  649. * @return \WANObjectCache
  650. */
  651. public function getMainWANObjectCache() {
  652. return $this->getService( 'MainWANObjectCache' );
  653. }
  654. /**
  655. * @since 1.28
  656. * @return MediaHandlerFactory
  657. */
  658. public function getMediaHandlerFactory() {
  659. return $this->getService( 'MediaHandlerFactory' );
  660. }
  661. /**
  662. * @since 1.34
  663. * @return MessageCache
  664. */
  665. public function getMessageCache() : MessageCache {
  666. return $this->getService( 'MessageCache' );
  667. }
  668. /**
  669. * @since 1.34
  670. * @return IMessageFormatterFactory
  671. */
  672. public function getMessageFormatterFactory() {
  673. return $this->getService( 'MessageFormatterFactory' );
  674. }
  675. /**
  676. * @since 1.28
  677. * @return MimeAnalyzer
  678. */
  679. public function getMimeAnalyzer() {
  680. return $this->getService( 'MimeAnalyzer' );
  681. }
  682. /**
  683. * @since 1.34
  684. * @return MovePageFactory
  685. */
  686. public function getMovePageFactory() : MovePageFactory {
  687. return $this->getService( 'MovePageFactory' );
  688. }
  689. /**
  690. * @since 1.34
  691. * @return NamespaceInfo
  692. */
  693. public function getNamespaceInfo() : NamespaceInfo {
  694. return $this->getService( 'NamespaceInfo' );
  695. }
  696. /**
  697. * @since 1.32
  698. * @return NameTableStoreFactory
  699. */
  700. public function getNameTableStoreFactory() {
  701. return $this->getService( 'NameTableStoreFactory' );
  702. }
  703. /**
  704. * ObjectFactory is intended for instantiating "handlers" from declarative definitions,
  705. * such as Action API modules, special pages, or REST API handlers.
  706. *
  707. * @since 1.34
  708. * @return ObjectFactory
  709. */
  710. public function getObjectFactory() {
  711. return $this->getService( 'ObjectFactory' );
  712. }
  713. /**
  714. * @since 1.32
  715. * @return OldRevisionImporter
  716. */
  717. public function getOldRevisionImporter() {
  718. return $this->getService( 'OldRevisionImporter' );
  719. }
  720. /**
  721. * @return PageEditStash
  722. * @since 1.34
  723. */
  724. public function getPageEditStash() {
  725. return $this->getService( 'PageEditStash' );
  726. }
  727. /**
  728. * @since 1.29
  729. * @return Parser
  730. */
  731. public function getParser() {
  732. return $this->getService( 'Parser' );
  733. }
  734. /**
  735. * @since 1.30
  736. * @return ParserCache
  737. */
  738. public function getParserCache() {
  739. return $this->getService( 'ParserCache' );
  740. }
  741. /**
  742. * @since 1.32
  743. * @return ParserFactory
  744. */
  745. public function getParserFactory() {
  746. return $this->getService( 'ParserFactory' );
  747. }
  748. /**
  749. * @since 1.32
  750. * @return PasswordFactory
  751. */
  752. public function getPasswordFactory() {
  753. return $this->getService( 'PasswordFactory' );
  754. }
  755. /**
  756. * @since 1.34
  757. * @return PasswordReset
  758. */
  759. public function getPasswordReset() : PasswordReset {
  760. return $this->getService( 'PasswordReset' );
  761. }
  762. /**
  763. * @since 1.32
  764. * @return StatsdDataFactoryInterface
  765. */
  766. public function getPerDbNameStatsdDataFactory() {
  767. return $this->getService( 'PerDbNameStatsdDataFactory' );
  768. }
  769. /**
  770. * @since 1.33
  771. * @return PermissionManager
  772. */
  773. public function getPermissionManager() {
  774. return $this->getService( 'PermissionManager' );
  775. }
  776. /**
  777. * @since 1.31
  778. * @return PreferencesFactory
  779. */
  780. public function getPreferencesFactory() {
  781. return $this->getService( 'PreferencesFactory' );
  782. }
  783. /**
  784. * @since 1.28
  785. * @return ProxyLookup
  786. */
  787. public function getProxyLookup() {
  788. return $this->getService( 'ProxyLookup' );
  789. }
  790. /**
  791. * @since 1.29
  792. * @return \ReadOnlyMode
  793. */
  794. public function getReadOnlyMode() {
  795. return $this->getService( 'ReadOnlyMode' );
  796. }
  797. /**
  798. * @since 1.34
  799. * @return RepoGroup
  800. */
  801. public function getRepoGroup() : RepoGroup {
  802. return $this->getService( 'RepoGroup' );
  803. }
  804. /**
  805. * @since 1.33
  806. * @return ResourceLoader
  807. */
  808. public function getResourceLoader() {
  809. return $this->getService( 'ResourceLoader' );
  810. }
  811. /**
  812. * @since 1.31
  813. * @return RevisionFactory
  814. */
  815. public function getRevisionFactory() {
  816. return $this->getService( 'RevisionFactory' );
  817. }
  818. /**
  819. * @since 1.31
  820. * @return RevisionLookup
  821. */
  822. public function getRevisionLookup() {
  823. return $this->getService( 'RevisionLookup' );
  824. }
  825. /**
  826. * @since 1.32
  827. * @return RevisionRenderer
  828. */
  829. public function getRevisionRenderer() {
  830. return $this->getService( 'RevisionRenderer' );
  831. }
  832. /**
  833. * @since 1.31
  834. * @return RevisionStore
  835. */
  836. public function getRevisionStore() {
  837. return $this->getService( 'RevisionStore' );
  838. }
  839. /**
  840. * @since 1.32
  841. * @return RevisionStoreFactory
  842. */
  843. public function getRevisionStoreFactory() {
  844. return $this->getService( 'RevisionStoreFactory' );
  845. }
  846. /**
  847. * @since 1.27
  848. * @return SearchEngine
  849. */
  850. public function newSearchEngine() {
  851. // New engine object every time, since they keep state
  852. return $this->getService( 'SearchEngineFactory' )->create();
  853. }
  854. /**
  855. * @since 1.27
  856. * @return SearchEngineConfig
  857. */
  858. public function getSearchEngineConfig() {
  859. return $this->getService( 'SearchEngineConfig' );
  860. }
  861. /**
  862. * @since 1.27
  863. * @return SearchEngineFactory
  864. */
  865. public function getSearchEngineFactory() {
  866. return $this->getService( 'SearchEngineFactory' );
  867. }
  868. /**
  869. * @since 1.30
  870. * @return CommandFactory
  871. */
  872. public function getShellCommandFactory() {
  873. return $this->getService( 'ShellCommandFactory' );
  874. }
  875. /**
  876. * @since 1.27
  877. * @return SiteLookup
  878. */
  879. public function getSiteLookup() {
  880. return $this->getService( 'SiteLookup' );
  881. }
  882. /**
  883. * @since 1.27
  884. * @return SiteStore
  885. */
  886. public function getSiteStore() {
  887. return $this->getService( 'SiteStore' );
  888. }
  889. /**
  890. * @since 1.27
  891. * @return SkinFactory
  892. */
  893. public function getSkinFactory() {
  894. return $this->getService( 'SkinFactory' );
  895. }
  896. /**
  897. * @since 1.33
  898. * @return SlotRoleRegistry
  899. */
  900. public function getSlotRoleRegistry() {
  901. return $this->getService( 'SlotRoleRegistry' );
  902. }
  903. /**
  904. * @since 1.31
  905. * @return NameTableStore
  906. */
  907. public function getSlotRoleStore() {
  908. return $this->getService( 'NameTableStoreFactory' )->getSlotRoles();
  909. }
  910. /**
  911. * @since 1.32
  912. * @return SpecialPageFactory
  913. */
  914. public function getSpecialPageFactory() : SpecialPageFactory {
  915. return $this->getService( 'SpecialPageFactory' );
  916. }
  917. /**
  918. * @since 1.27
  919. * @return IBufferingStatsdDataFactory
  920. */
  921. public function getStatsdDataFactory() {
  922. return $this->getService( 'StatsdDataFactory' );
  923. }
  924. /**
  925. * @since 1.34
  926. * @return TempFSFileFactory
  927. */
  928. public function getTempFSFileFactory() : TempFSFileFactory {
  929. return $this->getService( 'TempFSFileFactory' );
  930. }
  931. /**
  932. * @since 1.28
  933. * @return TitleFormatter
  934. */
  935. public function getTitleFormatter() {
  936. return $this->getService( 'TitleFormatter' );
  937. }
  938. /**
  939. * @since 1.28
  940. * @return TitleParser
  941. */
  942. public function getTitleParser() {
  943. return $this->getService( 'TitleParser' );
  944. }
  945. /**
  946. * @since 1.32
  947. * @return UploadRevisionImporter
  948. */
  949. public function getUploadRevisionImporter() {
  950. return $this->getService( 'UploadRevisionImporter' );
  951. }
  952. /**
  953. * @since 1.28
  954. * @return VirtualRESTServiceClient
  955. */
  956. public function getVirtualRESTServiceClient() {
  957. return $this->getService( 'VirtualRESTServiceClient' );
  958. }
  959. /**
  960. * @since 1.28
  961. * @return WatchedItemQueryService
  962. */
  963. public function getWatchedItemQueryService() {
  964. return $this->getService( 'WatchedItemQueryService' );
  965. }
  966. /**
  967. * @since 1.28
  968. * @return WatchedItemStoreInterface
  969. */
  970. public function getWatchedItemStore() {
  971. return $this->getService( 'WatchedItemStore' );
  972. }
  973. /**
  974. * @since 1.31
  975. * @return \OldRevisionImporter
  976. */
  977. public function getWikiRevisionOldRevisionImporter() {
  978. return $this->getService( 'OldRevisionImporter' );
  979. }
  980. /**
  981. * @since 1.31
  982. * @return \OldRevisionImporter
  983. */
  984. public function getWikiRevisionOldRevisionImporterNoUpdates() {
  985. return $this->getService( 'WikiRevisionOldRevisionImporterNoUpdates' );
  986. }
  987. /**
  988. * @since 1.31
  989. * @return \UploadRevisionImporter
  990. */
  991. public function getWikiRevisionUploadImporter() {
  992. return $this->getService( 'UploadRevisionImporter' );
  993. }
  994. }