Debian Codegraph @

includes/MediaWikiServices.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 namespace MediaWiki;
22
23 use ExternalStoreAccess;
24 use ExternalStoreFactory;
25 use JobQueueGroup;
26 use JobRunner;
27 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
28 use LocalisationCache;
29 use LogFormatterFactory;
30 use LogicException;
31 use MediaHandlerFactory;
32 use MediaWiki\Actions\ActionFactory;
33 use MediaWiki\Auth\AuthManager;
34 use MediaWiki\Block\AutoblockExemptionList;
35 use MediaWiki\Block\BlockActionInfo;
36 use MediaWiki\Block\BlockErrorFormatter;
37 use MediaWiki\Block\BlockManager;
38 use MediaWiki\Block\BlockPermissionCheckerFactory;
39 use MediaWiki\Block\BlockRestrictionStore;
40 use MediaWiki\Block\BlockRestrictionStoreFactory;
41 use MediaWiki\Block\BlockUserFactory;
42 use MediaWiki\Block\BlockUtils;
43 use MediaWiki\Block\BlockUtilsFactory;
44 use MediaWiki\Block\DatabaseBlockStore;
45 use MediaWiki\Block\DatabaseBlockStoreFactory;
46 use MediaWiki\Block\HideUserUtils;
47 use MediaWiki\Block\UnblockUserFactory;
48 use MediaWiki\Cache\BacklinkCacheFactory;
49 use MediaWiki\Cache\GenderCache;
50 use MediaWiki\Cache\HTMLCacheUpdater;
51 use MediaWiki\Cache\LinkBatchFactory;
52 use MediaWiki\Cache\LinkCache;
53 use MediaWiki\Cache\UserCache;
54 use MediaWiki\Category\TrackingCategories;
55 use MediaWiki\ChangeTags\ChangeTagsStore;
56 use MediaWiki\Collation\CollationFactory;
57 use MediaWiki\CommentFormatter\CommentFormatter;
58 use MediaWiki\CommentFormatter\CommentParserFactory;
59 use MediaWiki\CommentFormatter\RowCommentFormatter;
60 use MediaWiki\CommentStore\CommentStore;
61 use MediaWiki\Config\Config;
62 use MediaWiki\Config\ConfigFactory;
63 use MediaWiki\Config\ConfigRepository;
64 use MediaWiki\Config\GlobalVarConfig;
65 use MediaWiki\Content\ContentJsonCodec;
66 use MediaWiki\Content\IContentHandlerFactory;
67 use MediaWiki\Content\Renderer\ContentRenderer;
68 use MediaWiki\Content\Transform\ContentTransformer;
69 use MediaWiki\Edit\ParsoidOutputStash;
70 use MediaWiki\EditPage\IntroMessageBuilder;
71 use MediaWiki\EditPage\PreloadedContentBuilder;
72 use MediaWiki\EditPage\SpamChecker;
73 use MediaWiki\Export\WikiExporterFactory;
74 use MediaWiki\FileBackend\FileBackendGroup;
75 use MediaWiki\FileBackend\FSFile\TempFSFileFactory;
76 use MediaWiki\FileBackend\LockManager\LockManagerGroupFactory;
77 use MediaWiki\HookContainer\HookContainer;
78 use MediaWiki\HookContainer\HookRunner;
79 use MediaWiki\Http\HttpRequestFactory;
80 use MediaWiki\Installer\Pingback;
81 use MediaWiki\Interwiki\InterwikiLookup;
82 use MediaWiki\Interwiki\NullInterwikiLookup;
83 use MediaWiki\JobQueue\JobFactory;
84 use MediaWiki\JobQueue\JobQueueGroupFactory;
85 use MediaWiki\Json\JsonCodec;
86 use MediaWiki\Language\FormatterFactory;
87 use MediaWiki\Language\Language;
88 use MediaWiki\Language\LanguageCode;
89 use MediaWiki\Languages\LanguageConverterFactory;
90 use MediaWiki\Languages\LanguageFactory;
91 use MediaWiki\Languages\LanguageFallback;
92 use MediaWiki\Languages\LanguageNameUtils;
93 use MediaWiki\Linker\LinkRenderer;
94 use MediaWiki\Linker\LinkRendererFactory;
95 use MediaWiki\Linker\LinksMigration;
96 use MediaWiki\Linker\LinkTargetLookup;
97 use MediaWiki\Mail\EmailUserFactory;
98 use MediaWiki\Mail\IEmailer;
99 use MediaWiki\OutputTransform\OutputTransformPipeline;
100 use MediaWiki\Page\ContentModelChangeFactory;
101 use MediaWiki\Page\DeletePageFactory;
102 use MediaWiki\Page\File\BadFileLookup;
103 use MediaWiki\Page\MergeHistoryFactory;
104 use MediaWiki\Page\MovePageFactory;
105 use MediaWiki\Page\PageProps;
106 use MediaWiki\Page\PageStore;
107 use MediaWiki\Page\PageStoreFactory;
108 use MediaWiki\Page\ParserOutputAccess;
109 use MediaWiki\Page\RedirectLookup;
110 use MediaWiki\Page\RedirectStore;
111 use MediaWiki\Page\RollbackPageFactory;
112 use MediaWiki\Page\UndeletePageFactory;
113 use MediaWiki\Page\WikiPageFactory;
114 use MediaWiki\Parser\DateFormatterFactory;
115 use MediaWiki\Parser\MagicWordFactory;
116 use MediaWiki\Parser\Parser;
117 use MediaWiki\Parser\ParserCache;
118 use MediaWiki\Parser\ParserCacheFactory;
119 use MediaWiki\Parser\ParserFactory;
120 use MediaWiki\Parser\Parsoid\Config\PageConfigFactory;
121 use MediaWiki\Parser\Parsoid\Config\SiteConfig;
122 use MediaWiki\Parser\Parsoid\HtmlTransformFactory;
123 use MediaWiki\Parser\Parsoid\LintErrorChecker;
124 use MediaWiki\Parser\Parsoid\ParsoidOutputAccess;
125 use MediaWiki\Parser\Parsoid\ParsoidParserFactory;
126 use MediaWiki\Password\PasswordFactory;
127 use MediaWiki\Permissions\GrantsInfo;
128 use MediaWiki\Permissions\GrantsLocalization;
129 use MediaWiki\Permissions\GroupPermissionsLookup;
130 use MediaWiki\Permissions\PermissionManager;
131 use MediaWiki\Permissions\RateLimiter;
132 use MediaWiki\Permissions\RestrictionStore;
133 use MediaWiki\PoolCounter\PoolCounterFactory;
134 use MediaWiki\Preferences\PreferencesFactory;
135 use MediaWiki\Preferences\SignatureValidatorFactory;
136 use MediaWiki\Registration\ExtensionRegistry;
137 use MediaWiki\Request\ProxyLookup;
138 use MediaWiki\ResourceLoader\ResourceLoader;
139 use MediaWiki\Rest\Handler\Helper\PageRestHelperFactory;
140 use MediaWiki\Revision\ArchivedRevisionLookup;
141 use MediaWiki\Revision\RevisionFactory;
142 use MediaWiki\Revision\RevisionLookup;
143 use MediaWiki\Revision\RevisionRenderer;
144 use MediaWiki\Revision\RevisionStore;
145 use MediaWiki\Revision\RevisionStoreFactory;
146 use MediaWiki\Revision\SlotRoleRegistry;
147 use MediaWiki\Search\SearchResultThumbnailProvider;
148 use MediaWiki\Search\TitleMatcher;
149 use MediaWiki\Settings\Config\ConfigSchema;
150 use MediaWiki\Shell\CommandFactory;
151 use MediaWiki\Shell\ShellboxClientFactory;
152 use MediaWiki\Site\SiteLookup;
153 use MediaWiki\Site\SiteStore;
154 use MediaWiki\SpecialPage\SpecialPageFactory;
155 use MediaWiki\Storage\BlobStore;
156 use MediaWiki\Storage\BlobStoreFactory;
157 use MediaWiki\Storage\NameTableStore;
158 use MediaWiki\Storage\NameTableStoreFactory;
159 use MediaWiki\Storage\PageEditStash;
160 use MediaWiki\Storage\PageUpdaterFactory;
161 use MediaWiki\Storage\RevertedTagUpdateManager;
162 use MediaWiki\Tidy\TidyDriverBase;
163 use MediaWiki\Title\NamespaceInfo;
164 use MediaWiki\Title\TitleFactory;
165 use MediaWiki\Title\TitleFormatter;
166 use MediaWiki\Title\TitleParser;
167 use MediaWiki\User\ActorMigration;
168 use MediaWiki\User\ActorNormalization;
169 use MediaWiki\User\ActorStore;
170 use MediaWiki\User\ActorStoreFactory;
171 use MediaWiki\User\BotPasswordStore;
172 use MediaWiki\User\CentralId\CentralIdLookup;
173 use MediaWiki\User\CentralId\CentralIdLookupFactory;
174 use MediaWiki\User\Options\StaticUserOptionsLookup;
175 use MediaWiki\User\Options\UserOptionsLookup;
176 use MediaWiki\User\Options\UserOptionsManager;
177 use MediaWiki\User\PasswordReset;
178 use MediaWiki\User\Registration\UserRegistrationLookup;
179 use MediaWiki\User\TalkPageNotificationManager;
180 use MediaWiki\User\TempUser\RealTempUserConfig;
181 use MediaWiki\User\TempUser\TempUserCreator;
182 use MediaWiki\User\UserEditTracker;
183 use MediaWiki\User\UserFactory;
184 use MediaWiki\User\UserGroupManager;
185 use MediaWiki\User\UserGroupManagerFactory;
186 use MediaWiki\User\UserIdentityLookup;
187 use MediaWiki\User\UserIdentityUtils;
188 use MediaWiki\User\UserNamePrefixSearch;
189 use MediaWiki\User\UserNameUtils;
190 use MediaWiki\Utils\UrlUtils;
191 use MediaWiki\Watchlist\WatchedItemQueryService;
192 use MediaWiki\Watchlist\WatchedItemStoreInterface;
193 use MediaWiki\Watchlist\WatchlistManager;
194 use MessageCache;
195 use MWLBFactory;
196 use ObjectCacheFactory;
197 use OldRevisionImporter;
198 use RepoGroup;
199 use SearchEngine;
200 use SearchEngineConfig;
201 use SearchEngineFactory;
202 use SkinFactory;
203 use UploadRevisionImporter;
204 use WikiImporterFactory;
205 use Wikimedia\EventRelayer\EventRelayerGroup;
206 use Wikimedia\Message\IMessageFormatterFactory;
207 use Wikimedia\Mime\MimeAnalyzer;
208 use Wikimedia\NonSerializable\NonSerializableTrait;
209 use Wikimedia\ObjectCache\BagOStuff;
210 use Wikimedia\ObjectCache\WANObjectCache;
211 use Wikimedia\ObjectFactory\ObjectFactory;
212 use Wikimedia\Parsoid\Config\DataAccess;
213 use Wikimedia\Rdbms\ChronologyProtector;
214 use Wikimedia\Rdbms\ConfiguredReadOnlyMode;
215 use Wikimedia\Rdbms\DatabaseFactory;
216 use Wikimedia\Rdbms\IConnectionProvider;
217 use Wikimedia\Rdbms\ILoadBalancer;
218 use Wikimedia\Rdbms\LBFactory;
219 use Wikimedia\Rdbms\LBFactorySingle;
220 use Wikimedia\Rdbms\LoadBalancerDisabled;
221 use Wikimedia\Rdbms\ReadOnlyMode;
222 use Wikimedia\RequestTimeout\CriticalSectionProvider;
223 use Wikimedia\Services\NoSuchServiceException;
224 use Wikimedia\Services\SalvageableService;
225 use Wikimedia\Services\ServiceContainer;
226 use Wikimedia\Stats\IBufferingStatsdDataFactory;
227 use Wikimedia\Stats\StatsFactory;
228 use Wikimedia\Telemetry\TracerInterface;
229 use Wikimedia\UUID\GlobalIdGenerator;
230 use Wikimedia\WRStats\WRStatsFactory;
231
232 /**
233 * Service locator for MediaWiki core services.
234 *
235 * Refer to includes/ServiceWiring.php for the default implementations.
236 *
237 * @see [Dependency Injection](@ref dependencyinjection) in docs/Injection.md
238 * for the principles of DI and how to use it MediaWiki core.
239 *
240 * @since 1.27
241 */
242 class MediaWikiServices extends ServiceContainer {
243 use NonSerializableTrait;
244
245 /**
246 * @var bool
247 */
248 private static $globalInstanceAllowed = false;
249
250 /**
251 * @var self|null
252 */
253 private static $instance = null;
254
255 /**
256 * @see disableStorage()
257 * @var bool
258 */
259 private bool $storageDisabled = false;
260
261 /**
262 * Allows a global service container instance to exist.
263 *
264 * This should be called only after configuration settings have been read and extensions
265 * have been registered. Any change made to configuration after this method has been called
266 * may be ineffective or even harmful.
267 *
268 * @see getInstance()
269 *
270 * @since 1.36
271 */
272 public static function allowGlobalInstance() {
273 self::$globalInstanceAllowed = true;
274
275 if ( self::$instance ) {
276 // TODO: in 1.37, getInstance() should fail if $globalInstanceAllowed is false! (T153256)
277 // Until then, we have to reset service instances that have already been created.
278 // No need to warn here, getService() has already triggered a deprecation warning.
279 self::resetGlobalInstance( null, 'quick' );
280 }
281 }
282
283 /**
284 * @internal Should only be used in MediaWikiUnitTestCase
285 */
286 public static function disallowGlobalInstanceInUnitTests(): void {
287 if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
288 throw new LogicException( 'Can only be called in tests' );
289 }
290 self::$globalInstanceAllowed = false;
291 }
292
293 /**
294 * @internal Should only be used in MediaWikiUnitTestCase
295 */
296 public static function allowGlobalInstanceAfterUnitTests(): void {
297 if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
298 throw new LogicException( 'Can only be called in tests' );
299 }
300 self::$globalInstanceAllowed = true;
301 }
302
303 /**
304 * Returns true if an instance has already been initialized. This can be used to avoid accessing
305 * services if it's not safe, such as in unit tests or early setup.
306 */
307 public static function hasInstance(): bool {
308 return self::$instance !== null;
309 }
310
311 /**
312 * Returns the global default instance of the top level service locator.
313 *
314 * @note if called before allowGlobalInstance(), this method will fail.
315 *
316 * @since 1.27
317 *
318 * The default instance is initialized using the service instantiator functions
319 * defined in ServiceWiring.php.
320 *
321 * @note This should only be called by static functions! The instance returned here
322 * should not be passed around! Objects that need access to a service should have
323 * that service injected into the constructor, never a service locator!
324 */
325 public static function getInstance(): self {
326 if ( !self::$globalInstanceAllowed ) {
327 if ( defined( 'MW_PHPUNIT_TEST' ) ) {
328 // Fail hard in PHPUnit tests only
329 throw new LogicException( 'Premature access to service container' );
330 }
331 // TODO: getInstance() should always fail if $globalInstanceAllowed is false! (T153256)
332 wfDeprecatedMsg( 'Premature access to service container', '1.36' );
333 }
334
335 if ( self::$instance === null ) {
336 // NOTE: constructing GlobalVarConfig here is not particularly pretty,
337 // but some information from the global scope has to be injected here,
338 // even if it's just a file name or database credentials to load
339 // configuration from.
340 $bootstrapConfig = new GlobalVarConfig();
341 self::$instance = self::newInstance( $bootstrapConfig, 'load' );
342
343 // Provides a traditional hook point to allow extensions to configure services.
344 // NOTE: Ideally this would be in newInstance() but it causes an infinite run loop
345 $runner = new HookRunner( self::$instance->getHookContainer() );
346 $runner->onMediaWikiServices( self::$instance );
347 }
348 return self::$instance;
349 }
350
351 public function getService( $name ) {
352 // TODO: in 1.37, getInstance() should fail if $globalInstanceAllowed is false! (T153256)
353 if ( !self::$globalInstanceAllowed && $this === self::$instance ) {
354 wfDeprecatedMsg( "Premature access to service '$name'", '1.36', false, 3 );
355 }
356
357 return parent::getService( $name );
358 }
359
360 /**
361 * Replaces the global MediaWikiServices instance.
362 *
363 * @since 1.28
364 *
365 * @note This is for use in PHPUnit tests only!
366 *
367 * @param self $services The new MediaWikiServices object.
368 *
369 * @return self The old MediaWikiServices object, so it can be restored later.
370 */
371 public static function forceGlobalInstance( self $services ): self {
372 if ( !defined( 'MW_PHPUNIT_TEST' ) && !defined( 'MW_PARSER_TEST' ) ) {
373 throw new LogicException( __METHOD__ . ' must not be used outside unit tests.' );
374 }
375
376 $old = self::getInstance();
377 self::$instance = $services;
378
379 return $old;
380 }
381
382 /**
383 * Creates a new instance of MediaWikiServices and sets it as the global default
384 * instance. getInstance() will return a different MediaWikiServices object
385 * after every call to resetGlobalInstance().
386 *
387 * @since 1.28
388 *
389 * @warning This should not be used during normal operation. It is intended for use
390 * when the configuration has changed significantly since bootstrap time, e.g.
391 * during the installation process or during testing. The method must not be called after
392 * MW_SERVICE_BOOTSTRAP_COMPLETE has been defined in Setup.php, unless MW_PHPUNIT_TEST or
393 * MEDIAWIKI_INSTALL or RUN_MAINTENANCE_IF_MAIN is defined).
394 *
395 * @warning Calling resetGlobalInstance() may leave the application in an inconsistent
396 * state. Calling this is only safe under the ASSUMPTION that NO REFERENCE to
397 * any of the services managed by MediaWikiServices exist. If any service objects
398 * managed by the old MediaWikiServices instance remain in use, they may INTERFERE
399 * with the operation of the services managed by the new MediaWikiServices.
400 * Operating with a mix of services created by the old and the new
401 * MediaWikiServices instance may lead to INCONSISTENCIES and even DATA LOSS!
402 * Any class implementing LAZY LOADING is especially prone to this problem,
403 * since instances would typically retain a reference to a storage layer service.
404 *
405 * @see forceGlobalInstance()
406 * @see resetGlobalInstance()
407 * @see resetBetweenTest()
408 *
409 * @param Config|null $bootstrapConfig The Config object to be registered as the
410 * 'BootstrapConfig' service. This has to contain at least the information
411 * needed to set up the 'ConfigFactory' service. If not given, the bootstrap
412 * config of the old instance of MediaWikiServices will be re-used. If there
413 * was no previous instance, a new GlobalVarConfig object will be used to
414 * bootstrap the services.
415 * @param string $quick Set this to "quick" to allow expensive resources to be re-used.
416 * See SalvageableService for details.
417 */
418 public static function resetGlobalInstance( ?Config $bootstrapConfig = null, $quick = '' ) {
419 if ( self::$instance === null ) {
420 // no global instance yet, nothing to reset
421 return;
422 }
423
424 self::failIfResetNotAllowed( __METHOD__ );
425
426 $oldInstance = self::$instance;
427 self::$instance = self::newInstance(
428 $bootstrapConfig ?? self::$instance->getBootstrapConfig(),
429 'load'
430 );
431
432 // Provides a traditional hook point to allow extensions to configure services.
433 $runner = new HookRunner( $oldInstance->getHookContainer() );
434 $runner->onMediaWikiServices( self::$instance );
435
436 self::$instance->importWiring( $oldInstance, [ 'BootstrapConfig' ] );
437
438 if ( $quick === 'quick' ) {
439 self::$instance->salvage( $oldInstance );
440 } else {
441 $oldInstance->destroy();
442 }
443 }
444
445 /** @noinspection PhpDocSignatureInspection */
446
447 /**
448 * Salvages the state of any salvageable service instances in $other.
449 *
450 * @note $other will have been destroyed when salvage() returns.
451 */
452 private function salvage( self $other ) {
453 foreach ( $this->getServiceNames() as $name ) {
454 // The service could be new in the new instance and not registered in the
455 // other instance (e.g. an extension that was loaded after the instantiation of
456 // the other instance. Skip this service in this case. See T143974
457 try {
458 $oldService = $other->peekService( $name );
459 } catch ( NoSuchServiceException $e ) {
460 continue;
461 }
462
463 if ( $oldService instanceof SalvageableService ) {
464 /** @var SalvageableService $newService */
465 $newService = $this->getService( $name );
466 $newService->salvage( $oldService );
467 }
468 }
469
470 $other->destroy();
471 }
472
473 /**
474 * Creates a new MediaWikiServices instance and initializes it according to the
475 * given $bootstrapConfig. In particular, all wiring files defined in the
476 * ServiceWiringFiles setting are loaded, and the MediaWikiServices hook is called.
477 *
478 * @param Config $bootstrapConfig The Config object to be registered as the
479 * 'BootstrapConfig' service.
480 * @param string $loadWiring set this to 'load' to load the wiring files specified
481 * in the 'ServiceWiringFiles' setting in $bootstrapConfig.
482 */
483 private static function newInstance( Config $bootstrapConfig, $loadWiring = '' ): self {
484 $instance = new self( $bootstrapConfig );
485
486 // Load the default wiring from the specified files.
487 if ( $loadWiring === 'load' ) {
488 $wiringFiles = $bootstrapConfig->get( MainConfigNames::ServiceWiringFiles );
489 $instance->loadWiringFiles( $wiringFiles );
490 }
491
492 return $instance;
493 }
494
495 /**
496 * Disables all storage layer services. After calling this, any attempt to access the
497 * storage layer will result in an error.
498 *
499 * @since 1.28
500 * @deprecated since 1.40, use disableStorage() instead.
501 *
502 * @warning This is intended for extreme situations, see the documentation of disableStorage() for details.
503 *
504 * @see resetGlobalInstance()
505 * @see resetChildProcessServices()
506 */
507 public static function disableStorageBackend() {
508 $services = self::getInstance();
509 $services->disableStorage();
510 }
511
512 /**
513 * Disables all storage layer services. After calling this, any attempt to access the
514 * storage layer will result in an error. Use resetGlobalInstance() to restore normal
515 * operation.
516 *
517 * @since 1.40
518 *
519 * @warning This is intended for extreme situations only and should never be used
520 * while serving normal web requests. Legitimate use cases for this method include
521 * the installation process. Test fixtures may also use this, if the fixture relies
522 * on globalState.
523 *
524 * @see resetGlobalInstance()
525 * @see resetChildProcessServices()
526 */
527 public function disableStorage() {
528 if ( $this->storageDisabled ) {
529 return;
530 }
531
532 $this->redefineService(
533 'DBLoadBalancer',
534 static function ( self $services ) {
535 return new LoadBalancerDisabled();
536 }
537 );
538
539 $this->redefineService(
540 'DBLoadBalancerFactory',
541 static function ( self $services ) {
542 return LBFactorySingle::newDisabled();
543 }
544 );
545
546 $this->redefineService(
547 'InterwikiLookup',
548 static function ( self $services ) {
549 return new NullInterwikiLookup();
550 }
551 );
552
553 $this->redefineService(
554 'UserOptionsLookup',
555 static function ( self $services ) {
556 return new StaticUserOptionsLookup(
557 [],
558 $services->getMainConfig()->get( MainConfigNames::DefaultUserOptions )
559 );
560 }
561 );
562
563 $this->addServiceManipulator(
564 'LocalisationCache',
565 static function ( LocalisationCache $cache ) {
566 $cache->disableBackend();
567 }
568 );
569
570 $this->addServiceManipulator(
571 'MessageCache',
572 static function ( MessageCache $cache ) {
573 $cache->disable();
574 }
575 );
576
577 self::getInstance()->getObjectCacheFactory()->clear();
578
579 $this->storageDisabled = true;
580 }
581
582 /**
583 * Returns true if disableStorage() has been called on this MediaWikiServices instance.
584 */
585 public function isStorageDisabled(): bool {
586 return $this->storageDisabled;
587 }
588
589 /**
590 * Resets any services that may have become stale after a child processö
591 * returns from after pcntl_fork(). It's also safe, but generally unnecessary,
592 * to call this method from the parent process.
593 *
594 * @since 1.28
595 *
596 * @note This is intended for use in the context of process forking only!
597 *
598 * @see resetGlobalInstance()
599 * @see disableStorage()
600 */
601 public static function resetChildProcessServices() {
602 // NOTE: for now, just reset everything. Since we don't know the interdependencies
603 // between services, we can't do this more selectively at this time.
604 self::resetGlobalInstance();
605
606 // Child, reseed because there is no bug in PHP:
607 // https://bugs.php.net/bug.php?id=42465
608 mt_srand( getmypid() );
609 }
610
611 /**
612 * Resets the given service for testing purposes.
613 *
614 * @since 1.28
615 *
616 * @warning This is generally unsafe! Other services may still retain references
617 * to the stale service instance, leading to failures and inconsistencies. Subclasses
618 * may use this method to reset specific services under specific instances, but
619 * it should not be exposed to application logic.
620 *
621 * @note With proper dependency injection used throughout the codebase, this method
622 * should not be needed. It is provided to allow tests that pollute global service
623 * instances to clean up.
624 *
625 * @param string $name
626 * @param bool $destroy Whether the service instance should be destroyed if it exists.
627 * When set to false, any existing service instance will effectively be detached
628 * from the container.
629 */
630 public function resetServiceForTesting( $name, $destroy = true ) {
631 if ( !defined( 'MW_PHPUNIT_TEST' ) && !defined( 'MW_PARSER_TEST' ) ) {
632 throw new LogicException( 'resetServiceForTesting() must not be used outside unit tests.' );
633 }
634
635 $this->resetService( $name, $destroy );
636 }
637
638 /**
639 * Convenience method that throws an exception unless it is called during a phase in which
640 * resetting of global services is allowed. In general, services should not be reset
641 * individually, since that may introduce inconsistencies.
642 *
643 * @since 1.28
644 *
645 * This method will throw an exception if:
646 *
647 * - self::$resetInProgress is false (to allow all services to be reset together
648 * via resetGlobalInstance)
649 * - and MEDIAWIKI_INSTALL is not defined (to allow services to be reset during installation)
650 * - and MW_PHPUNIT_TEST is not defined (to allow services to be reset during testing)
651 *
652 * This method is intended to be used to safeguard against accidentally resetting
653 * global service instances that are not yet managed by MediaWikiServices. It is
654 * defined here in the MediaWikiServices services class to have a central place
655 * for managing service bootstrapping and resetting.
656 *
657 * @param string $method the name of the caller method, as given by __METHOD__.
658 *
659 * @see resetGlobalInstance()
660 * @see forceGlobalInstance()
661 * @see disableStorage()
662 */
663 public static function failIfResetNotAllowed( $method ) {
664 if ( !defined( 'MW_PHPUNIT_TEST' )
665 && !defined( 'MW_PARSER_TEST' )
666 && !defined( 'MEDIAWIKI_INSTALL' )
667 && !defined( 'RUN_MAINTENANCE_IF_MAIN' )
668 && defined( 'MW_SERVICE_BOOTSTRAP_COMPLETE' )
669 ) {
670 throw new LogicException( $method . ' may only be called during bootstrapping and unit tests!' );
671 }
672 }
673
674 /**
675 * @param Config $config The Config object to be registered as the 'BootstrapConfig' service.
676 * This has to contain at least the information needed to set up the 'ConfigFactory'
677 * service.
678 */
679 public function __construct( Config $config ) {
680 parent::__construct();
681
682 // Register the given Config object as the bootstrap config service.
683 $this->defineService( 'BootstrapConfig', static function () use ( $config ) {
684 return $config;
685 } );
686 }
687
688 // CONVENIENCE GETTERS ////////////////////////////////////////////////////
689
690 /**
691 * @since 1.37
692 */
693 public function getActionFactory(): ActionFactory {
694 return $this->getService( 'ActionFactory' );
695 }
696
697 /**
698 * @since 1.31
699 */
700 public function getActorMigration(): ActorMigration {
701 return $this->getService( 'ActorMigration' );
702 }
703
704 /**
705 * @since 1.36
706 */
707 public function getActorNormalization(): ActorNormalization {
708 return $this->getService( 'ActorNormalization' );
709 }
710
711 /**
712 * @since 1.36
713 */
714 public function getActorStore(): ActorStore {
715 return $this->getService( 'ActorStore' );
716 }
717
718 /**
719 * @since 1.36
720 */
721 public function getActorStoreFactory(): ActorStoreFactory {
722 return $this->getService( 'ActorStoreFactory' );
723 }
724
725 /**
726 * @since 1.38
727 */
728 public function getArchivedRevisionLookup(): ArchivedRevisionLookup {
729 return $this->getService( 'ArchivedRevisionLookup' );
730 }
731
732 /**
733 * @since 1.35
734 */
735 public function getAuthManager(): AuthManager {
736 return $this->getService( 'AuthManager' );
737 }
738
739 /**
740 * @since 1.42
741 */
742 public function getAutoblockExemptionList(): AutoblockExemptionList {
743 return $this->getService( 'AutoblockExemptionList' );
744 }
745
746 /**
747 * @since 1.37
748 */
749 public function getBacklinkCacheFactory(): BacklinkCacheFactory {
750 return $this->getService( 'BacklinkCacheFactory' );
751 }
752
753 /**
754 * @since 1.34
755 */
756 public function getBadFileLookup(): BadFileLookup {
757 return $this->getService( 'BadFileLookup' );
758 }
759
760 /**
761 * @since 1.31
762 */
763 public function getBlobStore(): BlobStore {
764 return $this->getService( 'BlobStore' );
765 }
766
767 /**
768 * @since 1.31
769 */
770 public function getBlobStoreFactory(): BlobStoreFactory {
771 return $this->getService( 'BlobStoreFactory' );
772 }
773
774 /**
775 * @since 1.37
776 */
777 public function getBlockActionInfo(): BlockActionInfo {
778 return $this->getService( 'BlockActionInfo' );
779 }
780
781 /**
782 * @since 1.35
783 * @deprecated since 1.42, use getFormatterFactory()->getBlockErrorFormatter() instead.
784 */
785 public function getBlockErrorFormatter(): BlockErrorFormatter {
786 wfDeprecated( __METHOD__, '1.42' );
787 return $this->getService( 'BlockErrorFormatter' );
788 }
789
790 /**
791 * @since 1.34
792 */
793 public function getBlockManager(): BlockManager {
794 return $this->getService( 'BlockManager' );
795 }
796
797 /**
798 * @since 1.35
799 */
800 public function getBlockPermissionCheckerFactory(): BlockPermissionCheckerFactory {
801 return $this->getService( 'BlockPermissionCheckerFactory' );
802 }
803
804 /**
805 * @since 1.33
806 */
807 public function getBlockRestrictionStore(): BlockRestrictionStore {
808 return $this->getService( 'BlockRestrictionStore' );
809 }
810
811 /**
812 * @since 1.38
813 */
814 public function getBlockRestrictionStoreFactory(): BlockRestrictionStoreFactory {
815 return $this->getService( 'BlockRestrictionStoreFactory' );
816 }
817
818 /**
819 * @since 1.36
820 */
821 public function getBlockUserFactory(): BlockUserFactory {
822 return $this->getService( 'BlockUserFactory' );
823 }
824
825 /**
826 * @since 1.36
827 */
828 public function getBlockUtils(): BlockUtils {
829 return $this->getService( 'BlockUtils' );
830 }
831
832 /**
833 * @since 1.42
834 */
835 public function getBlockUtilsFactory(): BlockUtilsFactory {
836 return $this->getService( 'BlockUtilsFactory' );
837 }
838
839 /**
840 * Returns the Config object containing the bootstrap configuration.
841 * Bootstrap configuration would typically include database credentials
842 * and other information that may be needed before the ConfigFactory
843 * service can be instantiated.
844 *
845 * @note This should only be used during bootstrapping, in particular
846 * when creating the MainConfig service. Application logic should
847 * use getMainConfig() to get a Config instances.
848 *
849 * @since 1.27
850 */
851 public function getBootstrapConfig(): Config {
852 return $this->getService( 'BootstrapConfig' );
853 }
854
855 /**
856 * @since 1.37
857 */
858 public function getBotPasswordStore(): BotPasswordStore {
859 return $this->getService( 'BotPasswordStore' );
860 }
861
862 /**
863 * @since 1.37
864 */
865 public function getCentralIdLookup(): CentralIdLookup {
866 return $this->getService( 'CentralIdLookup' );
867 }
868
869 /**
870 * @since 1.37
871 */
872 public function getCentralIdLookupFactory(): CentralIdLookupFactory {
873 return $this->getService( 'CentralIdLookupFactory' );
874 }
875
876 /**
877 * @since 1.32
878 */
879 public function getChangeTagDefStore(): NameTableStore {
880 return $this->getService( 'ChangeTagDefStore' );
881 }
882
883 /**
884 * @since 1.41
885 */
886 public function getChangeTagsStore(): ChangeTagsStore {
887 return $this->getService( 'ChangeTagsStore' );
888 }
889
890 /**
891 * @since 1.41
892 */
893 public function getChronologyProtector(): ChronologyProtector {
894 return $this->getService( 'ChronologyProtector' );
895 }
896
897 /**
898 * @since 1.37
899 */
900 public function getCollationFactory(): CollationFactory {
901 return $this->getService( 'CollationFactory' );
902 }
903
904 /**
905 * @since 1.38
906 */
907 public function getCommentFormatter(): CommentFormatter {
908 return $this->getService( 'CommentFormatter' );
909 }
910
911 /**
912 * @since 1.41
913 */
914 public function getCommentParserFactory(): CommentParserFactory {
915 return $this->getService( 'CommentParserFactory' );
916 }
917
918 /**
919 * @since 1.31
920 */
921 public function getCommentStore(): CommentStore {
922 return $this->getService( 'CommentStore' );
923 }
924
925 /**
926 * @since 1.27
927 */
928 public function getConfigFactory(): ConfigFactory {
929 return $this->getService( 'ConfigFactory' );
930 }
931
932 /**
933 * @deprecated since 1.42. Unused.
934 * @since 1.32
935 */
936 public function getConfigRepository(): ConfigRepository {
937 wfDeprecated( __METHOD__, '1.42' );
938 return $this->getService( 'ConfigRepository' );
939 }
940
941 /**
942 * @since 1.39
943 */
944 public function getConfigSchema(): ConfigSchema {
945 return $this->getService( 'ConfigSchema' );
946 }
947
948 /**
949 * @since 1.29
950 * @deprecated since 1.41 use ::getReadOnlyMode() instead
951 */
952 public function getConfiguredReadOnlyMode(): ConfiguredReadOnlyMode {
953 return $this->getService( 'ConfiguredReadOnlyMode' );
954 }
955
956 /**
957 * @since 1.42
958 */
959 public function getConnectionProvider(): IConnectionProvider {
960 return $this->getService( 'ConnectionProvider' );
961 }
962
963 /**
964 * @since 1.35
965 */
966 public function getContentHandlerFactory(): IContentHandlerFactory {
967 return $this->getService( 'ContentHandlerFactory' );
968 }
969
970 /**
971 * @since 1.45
972 */
973 public function getContentJsonCodec(): ContentJsonCodec {
974 return $this->getService( 'ContentJsonCodec' );
975 }
976
977 /**
978 * @since 1.32
979 */
980 public function getContentLanguage(): Language {
981 return $this->getService( 'ContentLanguage' );
982 }
983
984 /**
985 * @since 1.43
986 */
987 public function getContentLanguageCode(): LanguageCode {
988 return $this->getService( 'ContentLanguageCode' );
989 }
990
991 /**
992 * @since 1.35
993 */
994 public function getContentModelChangeFactory(): ContentModelChangeFactory {
995 return $this->getService( 'ContentModelChangeFactory' );
996 }
997
998 /**
999 * @since 1.31
1000 */
1001 public function getContentModelStore(): NameTableStore {
1002 return $this->getService( 'ContentModelStore' );
1003 }
1004
1005 /**
1006 * @since 1.38
1007 */
1008 public function getContentRenderer(): ContentRenderer {
1009 return $this->getService( 'ContentRenderer' );
1010 }
1011
1012 /**
1013 * @since 1.37
1014 */
1015 public function getContentTransformer(): ContentTransformer {
1016 return $this->getService( 'ContentTransformer' );
1017 }
1018
1019 /**
1020 * @since 1.36
1021 */
1022 public function getCriticalSectionProvider(): CriticalSectionProvider {
1023 return $this->getService( 'CriticalSectionProvider' );
1024 }
1025
1026 /**
1027 * @since 1.36
1028 */
1029 public function getDatabaseBlockStore(): DatabaseBlockStore {
1030 return $this->getService( 'DatabaseBlockStore' );
1031 }
1032
1033 /**
1034 * @since 1.40
1035 */
1036 public function getDatabaseBlockStoreFactory(): DatabaseBlockStoreFactory {
1037 return $this->getService( 'DatabaseBlockStoreFactory' );
1038 }
1039
1040 /**
1041 * @since 1.39
1042 */
1043 public function getDatabaseFactory(): DatabaseFactory {
1044 return $this->getService( 'DatabaseFactory' );
1045 }
1046
1047 /**
1048 * @since 1.33
1049 */
1050 public function getDateFormatterFactory(): DateFormatterFactory {
1051 return $this->getService( 'DateFormatterFactory' );
1052 }
1053
1054 /**
1055 * @since 1.28
1056 * @return ILoadBalancer The main DB load balancer for the local wiki.
1057 */
1058 public function getDBLoadBalancer(): ILoadBalancer {
1059 return $this->getService( 'DBLoadBalancer' );
1060 }
1061
1062 /**
1063 * @since 1.28
1064 * @note When possible, use {@link getConnectionProvider()} instead.
1065 */
1066 public function getDBLoadBalancerFactory(): LBFactory {
1067 return $this->getService( 'DBLoadBalancerFactory' );
1068 }
1069
1070 /**
1071 * @since 1.39
1072 */
1073 public function getDBLoadBalancerFactoryConfigBuilder(): MWLBFactory {
1074 return $this->getService( 'DBLoadBalancerFactoryConfigBuilder' );
1075 }
1076
1077 /**
1078 * @return OutputTransformPipeline
1079 * @internal
1080 */
1081 public function getDefaultOutputPipeline(): OutputTransformPipeline {
1082 return $this->getService( 'DefaultOutputPipeline' );
1083 }
1084
1085 /**
1086 * @since 1.37
1087 */
1088 public function getDeletePageFactory(): DeletePageFactory {
1089 return $this->getService( 'DeletePageFactory' );
1090 }
1091
1092 /**
1093 * @since 1.35
1094 */
1095 public function getEmailer(): IEmailer {
1096 return $this->getService( 'Emailer' );
1097 }
1098
1099 /**
1100 * @since 1.41
1101 */
1102 public function getEmailUserFactory(): EmailUserFactory {
1103 return $this->getService( 'EmailUserFactory' );
1104 }
1105
1106 /**
1107 * @since 1.27
1108 */
1109 public function getEventRelayerGroup(): EventRelayerGroup {
1110 return $this->getService( 'EventRelayerGroup' );
1111 }
1112
1113 /**
1114 * @since 1.42
1115 */
1116 public function getExtensionRegistry(): ExtensionRegistry {
1117 return $this->getService( 'ExtensionRegistry' );
1118 }
1119
1120 /**
1121 * @since 1.34
1122 */
1123 public function getExternalStoreAccess(): ExternalStoreAccess {
1124 return $this->getService( 'ExternalStoreAccess' );
1125 }
1126
1127 /**
1128 * @since 1.31
1129 */
1130 public function getExternalStoreFactory(): ExternalStoreFactory {
1131 return $this->getService( 'ExternalStoreFactory' );
1132 }
1133
1134 /**
1135 * @since 1.35
1136 */
1137 public function getFileBackendGroup(): FileBackendGroup {
1138 return $this->getService( 'FileBackendGroup' );
1139 }
1140
1141 /**
1142 * @since 1.41
1143 */
1144 public function getFormatterFactory(): FormatterFactory {
1145 return $this->getService( 'FormatterFactory' );
1146 }
1147
1148 /**
1149 * @since 1.28
1150 */
1151 public function getGenderCache(): GenderCache {
1152 return $this->getService( 'GenderCache' );
1153 }
1154
1155 /**
1156 * @since 1.35
1157 */
1158 public function getGlobalIdGenerator(): GlobalIdGenerator {
1159 return $this->getService( 'GlobalIdGenerator' );
1160 }
1161
1162 /**
1163 * @since 1.38
1164 */
1165 public function getGrantsInfo(): GrantsInfo {
1166 return $this->getService( 'GrantsInfo' );
1167 }
1168
1169 /**
1170 * @since 1.38
1171 */
1172 public function getGrantsLocalization(): GrantsLocalization {
1173 return $this->getService( 'GrantsLocalization' );
1174 }
1175
1176 /**
1177 * @since 1.36
1178 */
1179 public function getGroupPermissionsLookup(): GroupPermissionsLookup {
1180 return $this->getService( 'GroupPermissionsLookup' );
1181 }
1182
1183 /**
1184 * @since 1.42
1185 * @return HideUserUtils
1186 */
1187 public function getHideUserUtils(): HideUserUtils {
1188 return $this->getService( 'HideUserUtils' );
1189 }
1190
1191 /**
1192 * @since 1.35
1193 */
1194 public function getHookContainer(): HookContainer {
1195 return $this->getService( 'HookContainer' );
1196 }
1197
1198 /**
1199 * @since 1.35
1200 */
1201 public function getHtmlCacheUpdater(): HTMLCacheUpdater {
1202 return $this->getService( 'HtmlCacheUpdater' );
1203 }
1204
1205 /**
1206 * @since 1.39
1207 */
1208 public function getHtmlTransformFactory(): HtmlTransformFactory {
1209 return $this->getService( 'HtmlTransformFactory' );
1210 }
1211
1212 /**
1213 * @since 1.31
1214 */
1215 public function getHttpRequestFactory(): HttpRequestFactory {
1216 return $this->getService( 'HttpRequestFactory' );
1217 }
1218
1219 /**
1220 * @since 1.28
1221 */
1222 public function getInterwikiLookup(): InterwikiLookup {
1223 return $this->getService( 'InterwikiLookup' );
1224 }
1225
1226 /**
1227 * @since 1.41
1228 */
1229 public function getIntroMessageBuilder(): IntroMessageBuilder {
1230 return $this->getService( 'IntroMessageBuilder' );
1231 }
1232
1233 /**
1234 * @since 1.40
1235 */
1236 public function getJobFactory(): JobFactory {
1237 return $this->getService( 'JobFactory' );
1238 }
1239
1240 /**
1241 * @since 1.37
1242 */
1243 public function getJobQueueGroup(): JobQueueGroup {
1244 return $this->getService( 'JobQueueGroup' );
1245 }
1246
1247 /**
1248 * @since 1.37
1249 */
1250 public function getJobQueueGroupFactory(): JobQueueGroupFactory {
1251 return $this->getService( 'JobQueueGroupFactory' );
1252 }
1253
1254 /**
1255 * @since 1.35
1256 */
1257 public function getJobRunner(): JobRunner {
1258 return $this->getService( 'JobRunner' );
1259 }
1260
1261 /**
1262 * @since 1.36
1263 */
1264 public function getJsonCodec(): JsonCodec {
1265 return $this->getService( 'JsonCodec' );
1266 }
1267
1268 /**
1269 * @since 1.35
1270 */
1271 public function getLanguageConverterFactory(): LanguageConverterFactory {
1272 return $this->getService( 'LanguageConverterFactory' );
1273 }
1274
1275 /**
1276 * @since 1.35
1277 */
1278 public function getLanguageFactory(): LanguageFactory {
1279 return $this->getService( 'LanguageFactory' );
1280 }
1281
1282 /**
1283 * @since 1.35
1284 */
1285 public function getLanguageFallback(): LanguageFallback {
1286 return $this->getService( 'LanguageFallback' );
1287 }
1288
1289 /**
1290 * @since 1.34
1291 */
1292 public function getLanguageNameUtils(): LanguageNameUtils {
1293 return $this->getService( 'LanguageNameUtils' );
1294 }
1295
1296 /**
1297 * @since 1.35
1298 */
1299 public function getLinkBatchFactory(): LinkBatchFactory {
1300 return $this->getService( 'LinkBatchFactory' );
1301 }
1302
1303 /**
1304 * @since 1.28
1305 */
1306 public function getLinkCache(): LinkCache {
1307 return $this->getService( 'LinkCache' );
1308 }
1309
1310 /**
1311 * LinkRenderer instance that can be used
1312 * if no custom options are needed
1313 *
1314 * @since 1.28
1315 */
1316 public function getLinkRenderer(): LinkRenderer {
1317 return $this->getService( 'LinkRenderer' );
1318 }
1319
1320 /**
1321 * @since 1.28
1322 */
1323 public function getLinkRendererFactory(): LinkRendererFactory {
1324 return $this->getService( 'LinkRendererFactory' );
1325 }
1326
1327 /**
1328 * @since 1.39
1329 */
1330 public function getLinksMigration(): LinksMigration {
1331 return $this->getService( 'LinksMigration' );
1332 }
1333
1334 /**
1335 * @since 1.38
1336 */
1337 public function getLinkTargetLookup(): LinkTargetLookup {
1338 return $this->getService( 'LinkTargetLookup' );
1339 }
1340
1341 /**
1342 * @since 1.43
1343 */
1344 public function getLintErrorChecker(): LintErrorChecker {
1345 return $this->getService( 'LintErrorChecker' );
1346 }
1347
1348 /**
1349 * @since 1.34
1350 */
1351 public function getLocalisationCache(): LocalisationCache {
1352 return $this->getService( 'LocalisationCache' );
1353 }
1354
1355 /**
1356 * Returns the main server-local cache, yielding EmptyBagOStuff if there is none
1357 *
1358 * In web request mode, the cache should at least be shared among web workers.
1359 * In CLI mode, the cache should at least be shared among processes run by the same user.
1360 *
1361 * @since 1.28
1362 */
1363 public function getLocalServerObjectCache(): BagOStuff {
1364 return $this->getService( 'LocalServerObjectCache' );
1365 }
1366
1367 /**
1368 * @since 1.34
1369 */
1370 public function getLockManagerGroupFactory(): LockManagerGroupFactory {
1371 return $this->getService( 'LockManagerGroupFactory' );
1372 }
1373
1374 /**
1375 * @since 1.42
1376 */
1377 public function getLogFormatterFactory(): LogFormatterFactory {
1378 return $this->getService( 'LogFormatterFactory' );
1379 }
1380
1381 /**
1382 * @since 1.32
1383 */
1384 public function getMagicWordFactory(): MagicWordFactory {
1385 return $this->getService( 'MagicWordFactory' );
1386 }
1387
1388 /**
1389 * Returns the Config object that provides configuration for MediaWiki core.
1390 * This may or may not be the same object that is returned by getBootstrapConfig().
1391 *
1392 * @since 1.27
1393 */
1394 public function getMainConfig(): Config {
1395 return $this->getService( 'MainConfig' );
1396 }
1397
1398 /**
1399 * Returns the main object stash, yielding EmptyBagOStuff if there is none
1400 *
1401 * The stash should be shared among all datacenters
1402 *
1403 * @since 1.28
1404 */
1405 public function getMainObjectStash(): BagOStuff {
1406 return $this->getService( 'MainObjectStash' );
1407 }
1408
1409 /**
1410 * Returns the main WAN cache, yielding EmptyBagOStuff if there is none
1411 *
1412 * The cache should relay any purge operations to all datacenters
1413 *
1414 * @since 1.28
1415 */
1416 public function getMainWANObjectCache(): WANObjectCache {
1417 return $this->getService( 'MainWANObjectCache' );
1418 }
1419
1420 /**
1421 * @since 1.28
1422 */
1423 public function getMediaHandlerFactory(): MediaHandlerFactory {
1424 return $this->getService( 'MediaHandlerFactory' );
1425 }
1426
1427 /**
1428 * @since 1.35
1429 */
1430 public function getMergeHistoryFactory(): MergeHistoryFactory {
1431 return $this->getService( 'MergeHistoryFactory' );
1432 }
1433
1434 /**
1435 * @since 1.34
1436 */
1437 public function getMessageCache(): MessageCache {
1438 return $this->getService( 'MessageCache' );
1439 }
1440
1441 /**
1442 * @since 1.34
1443 */
1444 public function getMessageFormatterFactory(): IMessageFormatterFactory {
1445 return $this->getService( 'MessageFormatterFactory' );
1446 }
1447
1448 /**
1449 * @since 1.42
1450 * @unstable
1451 * @return BagOStuff
1452 */
1453 public function getMicroStash(): BagOStuff {
1454 return $this->getService( 'MicroStash' );
1455 }
1456
1457 /**
1458 * @since 1.28
1459 */
1460 public function getMimeAnalyzer(): MimeAnalyzer {
1461 return $this->getService( 'MimeAnalyzer' );
1462 }
1463
1464 /**
1465 * @since 1.34
1466 */
1467 public function getMovePageFactory(): MovePageFactory {
1468 return $this->getService( 'MovePageFactory' );
1469 }
1470
1471 /**
1472 * @since 1.34
1473 */
1474 public function getNamespaceInfo(): NamespaceInfo {
1475 return $this->getService( 'NamespaceInfo' );
1476 }
1477
1478 /**
1479 * @since 1.32
1480 */
1481 public function getNameTableStoreFactory(): NameTableStoreFactory {
1482 return $this->getService( 'NameTableStoreFactory' );
1483 }
1484
1485 /**
1486 * @since 1.42
1487 * @return ObjectCacheFactory
1488 */
1489 public function getObjectCacheFactory(): ObjectCacheFactory {
1490 return $this->getService( 'ObjectCacheFactory' );
1491 }
1492
1493 /**
1494 * ObjectFactory is intended for instantiating "handlers" from declarative definitions,
1495 * such as Action API modules, special pages, or REST API handlers.
1496 *
1497 * @since 1.34
1498 */
1499 public function getObjectFactory(): ObjectFactory {
1500 return $this->getService( 'ObjectFactory' );
1501 }
1502
1503 /**
1504 * @since 1.32
1505 */
1506 public function getOldRevisionImporter(): OldRevisionImporter {
1507 return $this->getService( 'OldRevisionImporter' );
1508 }
1509
1510 /**
1511 * @since 1.34
1512 */
1513 public function getPageEditStash(): PageEditStash {
1514 return $this->getService( 'PageEditStash' );
1515 }
1516
1517 /**
1518 * @since 1.36
1519 */
1520 public function getPageProps(): PageProps {
1521 return $this->getService( 'PageProps' );
1522 }
1523
1524 /**
1525 * @since 1.40
1526 */
1527 public function getPageRestHelperFactory(): PageRestHelperFactory {
1528 return $this->getService( 'PageRestHelperFactory' );
1529 }
1530
1531 /**
1532 * @since 1.36
1533 */
1534 public function getPageStore(): PageStore {
1535 return $this->getService( 'PageStore' );
1536 }
1537
1538 /**
1539 * @since 1.36
1540 */
1541 public function getPageStoreFactory(): PageStoreFactory {
1542 return $this->getService( 'PageStoreFactory' );
1543 }
1544
1545 /**
1546 * @since 1.37
1547 */
1548 public function getPageUpdaterFactory(): PageUpdaterFactory {
1549 return $this->getService( 'PageUpdaterFactory' );
1550 }
1551
1552 /**
1553 * Get the main Parser instance. This is unsafe when the caller is not in
1554 * a top-level context, because re-entering the parser will throw an
1555 * exception.
1556 *
1557 * @note Do not use this service for dependency injection or in service wiring.
1558 * It is convenience function to get the global instance in global code.
1559 * For dependency injection or service wiring code use the parser factory via the
1560 * 'ParserFactory' service and call one of the factory functions, preferably
1561 * {@link ParserFactory::create}.
1562 *
1563 * @since 1.29
1564 */
1565 public function getParser(): Parser {
1566 return $this->getService( 'Parser' );
1567 }
1568
1569 /**
1570 * @since 1.30
1571 */
1572 public function getParserCache(): ParserCache {
1573 return $this->getService( 'ParserCache' );
1574 }
1575
1576 /**
1577 * @since 1.36
1578 */
1579 public function getParserCacheFactory(): ParserCacheFactory {
1580 return $this->getService( 'ParserCacheFactory' );
1581 }
1582
1583 /**
1584 * @since 1.32
1585 */
1586 public function getParserFactory(): ParserFactory {
1587 return $this->getService( 'ParserFactory' );
1588 }
1589
1590 /**
1591 * @since 1.36
1592 */
1593 public function getParserOutputAccess(): ParserOutputAccess {
1594 return $this->getService( 'ParserOutputAccess' );
1595 }
1596
1597 /**
1598 * @since 1.39
1599 * @internal
1600 */
1601 public function getParsoidDataAccess(): DataAccess {
1602 return $this->getService( 'ParsoidDataAccess' );
1603 }
1604
1605 /**
1606 * @since 1.39
1607 * @unstable
1608 */
1609 public function getParsoidOutputAccess(): ParsoidOutputAccess {
1610 return $this->getService( 'ParsoidOutputAccess' );
1611 }
1612
1613 /**
1614 * @since 1.39
1615 * @unstable since 1.39, should be stable before release of 1.39
1616 */
1617 public function getParsoidOutputStash(): ParsoidOutputStash {
1618 return $this->getService( 'ParsoidOutputStash' );
1619 }
1620
1621 /**
1622 * @since 1.39
1623 * @internal
1624 */
1625 public function getParsoidPageConfigFactory(): PageConfigFactory {
1626 return $this->getService( 'ParsoidPageConfigFactory' );
1627 }
1628
1629 /**
1630 * @since 1.41
1631 * @internal
1632 */
1633 public function getParsoidParserFactory(): ParsoidParserFactory {
1634 return $this->getService( 'ParsoidParserFactory' );
1635 }
1636
1637 /**
1638 * @since 1.39
1639 * @internal
1640 */
1641 public function getParsoidSiteConfig(): SiteConfig {
1642 return $this->getService( 'ParsoidSiteConfig' );
1643 }
1644
1645 /**
1646 * @since 1.32
1647 */
1648 public function getPasswordFactory(): PasswordFactory {
1649 return $this->getService( 'PasswordFactory' );
1650 }
1651
1652 /**
1653 * @since 1.34
1654 */
1655 public function getPasswordReset(): PasswordReset {
1656 return $this->getService( 'PasswordReset' );
1657 }
1658
1659 /**
1660 * @since 1.32
1661 */
1662 public function getPerDbNameStatsdDataFactory(): StatsdDataFactoryInterface {
1663 return $this->getService( 'PerDbNameStatsdDataFactory' );
1664 }
1665
1666 /**
1667 * @since 1.33
1668 */
1669 public function getPermissionManager(): PermissionManager {
1670 return $this->getService( 'PermissionManager' );
1671 }
1672
1673 /**
1674 * @since 1.41
1675 * @internal
1676 */
1677 public function getPingback(): Pingback {
1678 return $this->getService( 'Pingback' );
1679 }
1680
1681 /**
1682 * @since 1.40
1683 */
1684 public function getPoolCounterFactory(): PoolCounterFactory {
1685 return $this->getService( 'PoolCounterFactory' );
1686 }
1687
1688 /**
1689 * @since 1.31
1690 */
1691 public function getPreferencesFactory(): PreferencesFactory {
1692 return $this->getService( 'PreferencesFactory' );
1693 }
1694
1695 /**
1696 * @since 1.41
1697 */
1698 public function getPreloadedContentBuilder(): PreloadedContentBuilder {
1699 return $this->getService( 'PreloadedContentBuilder' );
1700 }
1701
1702 /**
1703 * @since 1.28
1704 */
1705 public function getProxyLookup(): ProxyLookup {
1706 return $this->getService( 'ProxyLookup' );
1707 }
1708
1709 /**
1710 * @since 1.39
1711 */
1712 public function getRateLimiter(): RateLimiter {
1713 return $this->getService( 'RateLimiter' );
1714 }
1715
1716 /**
1717 * @since 1.29
1718 */
1719 public function getReadOnlyMode(): ReadOnlyMode {
1720 return $this->getService( 'ReadOnlyMode' );
1721 }
1722
1723 /**
1724 * @since 1.38
1725 */
1726 public function getRedirectLookup(): RedirectLookup {
1727 return $this->getService( 'RedirectLookup' );
1728 }
1729
1730 /**
1731 * @since 1.38
1732 */
1733 public function getRedirectStore(): RedirectStore {
1734 return $this->getService( 'RedirectStore' );
1735 }
1736
1737 /**
1738 * @since 1.34
1739 */
1740 public function getRepoGroup(): RepoGroup {
1741 return $this->getService( 'RepoGroup' );
1742 }
1743
1744 /**
1745 * @since 1.33
1746 */
1747 public function getResourceLoader(): ResourceLoader {
1748 return $this->getService( 'ResourceLoader' );
1749 }
1750
1751 /**
1752 * @since 1.37
1753 */
1754 public function getRestrictionStore(): RestrictionStore {
1755 return $this->getService( 'RestrictionStore' );
1756 }
1757
1758 /**
1759 * @since 1.36
1760 */
1761 public function getRevertedTagUpdateManager(): RevertedTagUpdateManager {
1762 return $this->getService( 'RevertedTagUpdateManager' );
1763 }
1764
1765 /**
1766 * @since 1.31
1767 */
1768 public function getRevisionFactory(): RevisionFactory {
1769 return $this->getService( 'RevisionFactory' );
1770 }
1771
1772 /**
1773 * @since 1.31
1774 */
1775 public function getRevisionLookup(): RevisionLookup {
1776 return $this->getService( 'RevisionLookup' );
1777 }
1778
1779 /**
1780 * @since 1.32
1781 */
1782 public function getRevisionRenderer(): RevisionRenderer {
1783 return $this->getService( 'RevisionRenderer' );
1784 }
1785
1786 /**
1787 * @since 1.31
1788 */
1789 public function getRevisionStore(): RevisionStore {
1790 return $this->getService( 'RevisionStore' );
1791 }
1792
1793 /**
1794 * @since 1.32
1795 */
1796 public function getRevisionStoreFactory(): RevisionStoreFactory {
1797 return $this->getService( 'RevisionStoreFactory' );
1798 }
1799
1800 /**
1801 * @since 1.37
1802 */
1803 public function getRollbackPageFactory(): RollbackPageFactory {
1804 return $this->getService( 'RollbackPageFactory' );
1805 }
1806
1807 /**
1808 * @since 1.38
1809 */
1810 public function getRowCommentFormatter(): RowCommentFormatter {
1811 return $this->getService( 'RowCommentFormatter' );
1812 }
1813
1814 /**
1815 * @since 1.27
1816 */
1817 public function newSearchEngine(): SearchEngine {
1818 // New engine object every time, since they keep state
1819 return $this->getService( 'SearchEngineFactory' )->create();
1820 }
1821
1822 /**
1823 * @since 1.27
1824 */
1825 public function getSearchEngineConfig(): SearchEngineConfig {
1826 return $this->getService( 'SearchEngineConfig' );
1827 }
1828
1829 /**
1830 * @since 1.27
1831 */
1832 public function getSearchEngineFactory(): SearchEngineFactory {
1833 return $this->getService( 'SearchEngineFactory' );
1834 }
1835
1836 /**
1837 * @since 1.40
1838 */
1839 public function getSearchResultThumbnailProvider(): SearchResultThumbnailProvider {
1840 return $this->getService( 'SearchResultThumbnailProvider' );
1841 }
1842
1843 /**
1844 * @since 1.36
1845 */
1846 public function getShellboxClientFactory(): ShellboxClientFactory {
1847 return $this->getService( 'ShellboxClientFactory' );
1848 }
1849
1850 /**
1851 * @since 1.30
1852 */
1853 public function getShellCommandFactory(): CommandFactory {
1854 return $this->getService( 'ShellCommandFactory' );
1855 }
1856
1857 /**
1858 * @since 1.38
1859 */
1860 public function getSignatureValidatorFactory(): SignatureValidatorFactory {
1861 return $this->getService( 'SignatureValidatorFactory' );
1862 }
1863
1864 /**
1865 * @since 1.27
1866 */
1867 public function getSiteLookup(): SiteLookup {
1868 return $this->getService( 'SiteLookup' );
1869 }
1870
1871 /**
1872 * @since 1.27
1873 */
1874 public function getSiteStore(): SiteStore {
1875 return $this->getService( 'SiteStore' );
1876 }
1877
1878 /**
1879 * @since 1.27
1880 */
1881 public function getSkinFactory(): SkinFactory {
1882 return $this->getService( 'SkinFactory' );
1883 }
1884
1885 /**
1886 * @since 1.33
1887 */
1888 public function getSlotRoleRegistry(): SlotRoleRegistry {
1889 return $this->getService( 'SlotRoleRegistry' );
1890 }
1891
1892 /**
1893 * @since 1.31
1894 */
1895 public function getSlotRoleStore(): NameTableStore {
1896 return $this->getService( 'SlotRoleStore' );
1897 }
1898
1899 /**
1900 * @since 1.35
1901 */
1902 public function getSpamChecker(): SpamChecker {
1903 return $this->getService( 'SpamChecker' );
1904 }
1905
1906 /**
1907 * @since 1.32
1908 */
1909 public function getSpecialPageFactory(): SpecialPageFactory {
1910 return $this->getService( 'SpecialPageFactory' );
1911 }
1912
1913 /**
1914 * @since 1.27
1915 */
1916 public function getStatsdDataFactory(): IBufferingStatsdDataFactory {
1917 return $this->getService( 'StatsdDataFactory' );
1918 }
1919
1920 /**
1921 * @since 1.41
1922 */
1923 public function getStatsFactory(): StatsFactory {
1924 return $this->getService( 'StatsFactory' );
1925 }
1926
1927 /**
1928 * @since 1.35
1929 */
1930 public function getTalkPageNotificationManager(): TalkPageNotificationManager {
1931 return $this->getService( 'TalkPageNotificationManager' );
1932 }
1933
1934 /**
1935 * @since 1.34
1936 */
1937 public function getTempFSFileFactory(): TempFSFileFactory {
1938 return $this->getService( 'TempFSFileFactory' );
1939 }
1940
1941 /**
1942 * @since 1.39
1943 */
1944 public function getTempUserConfig(): RealTempUserConfig {
1945 return $this->getService( 'TempUserConfig' );
1946 }
1947
1948 /**
1949 * @since 1.39
1950 */
1951 public function getTempUserCreator(): TempUserCreator {
1952 return $this->getService( 'TempUserCreator' );
1953 }
1954
1955 /**
1956 * @since 1.36
1957 */
1958 public function getTidy(): TidyDriverBase {
1959 return $this->getService( 'Tidy' );
1960 }
1961
1962 /**
1963 * @since 1.35
1964 */
1965 public function getTitleFactory(): TitleFactory {
1966 return $this->getService( 'TitleFactory' );
1967 }
1968
1969 /**
1970 * @since 1.28
1971 */
1972 public function getTitleFormatter(): TitleFormatter {
1973 return $this->getService( 'TitleFormatter' );
1974 }
1975
1976 /**
1977 * @since 1.40
1978 */
1979 public function getTitleMatcher(): TitleMatcher {
1980 return $this->getService( 'TitleMatcher' );
1981 }
1982
1983 /**
1984 * @since 1.28
1985 */
1986 public function getTitleParser(): TitleParser {
1987 return $this->getService( 'TitleParser' );
1988 }
1989
1990 public function getTracer(): TracerInterface {
1991 return $this->getService( 'Tracer' );
1992 }
1993
1994 /**
1995 * @since 1.38
1996 */
1997 public function getTrackingCategories(): TrackingCategories {
1998 return $this->getService( 'TrackingCategories' );
1999 }
2000
2001 /**
2002 * @since 1.36
2003 */
2004 public function getUnblockUserFactory(): UnblockUserFactory {
2005 return $this->getService( 'UnblockUserFactory' );
2006 }
2007
2008 /**
2009 * @since 1.38
2010 */
2011 public function getUndeletePageFactory(): UndeletePageFactory {
2012 return $this->getService( 'UndeletePageFactory' );
2013 }
2014
2015 /**
2016 * @since 1.32
2017 */
2018 public function getUploadRevisionImporter(): UploadRevisionImporter {
2019 return $this->getService( 'UploadRevisionImporter' );
2020 }
2021
2022 /**
2023 * @since 1.39
2024 */
2025 public function getUrlUtils(): UrlUtils {
2026 return $this->getService( 'UrlUtils' );
2027 }
2028
2029 /**
2030 * @since 1.36
2031 * @deprecated since 1.43, use ActorStore
2032 */
2033 public function getUserCache(): UserCache {
2034 return $this->getService( 'UserCache' );
2035 }
2036
2037 /**
2038 * @since 1.35
2039 */
2040 public function getUserEditTracker(): UserEditTracker {
2041 return $this->getService( 'UserEditTracker' );
2042 }
2043
2044 /**
2045 * @since 1.35
2046 */
2047 public function getUserFactory(): UserFactory {
2048 return $this->getService( 'UserFactory' );
2049 }
2050
2051 /**
2052 * @since 1.35
2053 */
2054 public function getUserGroupManager(): UserGroupManager {
2055 return $this->getService( 'UserGroupManager' );
2056 }
2057
2058 /**
2059 * @since 1.35
2060 */
2061 public function getUserGroupManagerFactory(): UserGroupManagerFactory {
2062 return $this->getService( 'UserGroupManagerFactory' );
2063 }
2064
2065 /**
2066 * @since 1.36
2067 */
2068 public function getUserIdentityLookup(): UserIdentityLookup {
2069 return $this->getService( 'UserIdentityLookup' );
2070 }
2071
2072 /**
2073 * @since 1.41
2074 */
2075 public function getUserIdentityUtils(): UserIdentityUtils {
2076 return $this->getService( 'UserIdentityUtils' );
2077 }
2078
2079 /**
2080 * @since 1.36
2081 */
2082 public function getUserNamePrefixSearch(): UserNamePrefixSearch {
2083 return $this->getService( 'UserNamePrefixSearch' );
2084 }
2085
2086 /**
2087 * @since 1.35
2088 */
2089 public function getUserNameUtils(): UserNameUtils {
2090 return $this->getService( 'UserNameUtils' );
2091 }
2092
2093 /**
2094 * @since 1.35
2095 */
2096 public function getUserOptionsLookup(): UserOptionsLookup {
2097 return $this->getService( 'UserOptionsLookup' );
2098 }
2099
2100 /**
2101 * @since 1.35
2102 */
2103 public function getUserOptionsManager(): UserOptionsManager {
2104 return $this->getService( 'UserOptionsManager' );
2105 }
2106
2107 /**
2108 * @since 1.41
2109 */
2110 public function getUserRegistrationLookup(): UserRegistrationLookup {
2111 return $this->getService( 'UserRegistrationLookup' );
2112 }
2113
2114 /**
2115 * @since 1.28
2116 */
2117 public function getWatchedItemQueryService(): WatchedItemQueryService {
2118 return $this->getService( 'WatchedItemQueryService' );
2119 }
2120
2121 /**
2122 * @since 1.28
2123 */
2124 public function getWatchedItemStore(): WatchedItemStoreInterface {
2125 return $this->getService( 'WatchedItemStore' );
2126 }
2127
2128 /**
2129 * @since 1.36
2130 */
2131 public function getWatchlistManager(): WatchlistManager {
2132 return $this->getService( 'WatchlistManager' );
2133 }
2134
2135 /**
2136 * @since 1.38
2137 */
2138 public function getWikiExporterFactory(): WikiExporterFactory {
2139 return $this->getService( 'WikiExporterFactory' );
2140 }
2141
2142 /**
2143 * @since 1.37
2144 */
2145 public function getWikiImporterFactory(): WikiImporterFactory {
2146 return $this->getService( 'WikiImporterFactory' );
2147 }
2148
2149 /**
2150 * @since 1.36
2151 */
2152 public function getWikiPageFactory(): WikiPageFactory {
2153 return $this->getService( 'WikiPageFactory' );
2154 }
2155
2156 /**
2157 * @since 1.31
2158 */
2159 public function getWikiRevisionOldRevisionImporter(): OldRevisionImporter {
2160 return $this->getService( 'OldRevisionImporter' );
2161 }
2162
2163 /**
2164 * @since 1.31
2165 */
2166 public function getWikiRevisionOldRevisionImporterNoUpdates(): OldRevisionImporter {
2167 return $this->getService( 'WikiRevisionOldRevisionImporterNoUpdates' );
2168 }
2169
2170 /**
2171 * @since 1.31
2172 */
2173 public function getWikiRevisionUploadImporter(): UploadRevisionImporter {
2174 return $this->getService( 'UploadRevisionImporter' );
2175 }
2176
2177 /**
2178 * @since 1.39
2179 */
2180 public function getWRStatsFactory(): WRStatsFactory {
2181 return $this->getService( 'WRStatsFactory' );
2182 }
2183
2184 }