2015-10-12 08:05:45 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Default wiring for MediaWiki services.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*
|
|
|
|
|
* This file is loaded by MediaWiki\MediaWikiServices::getInstance() during the
|
|
|
|
|
* bootstrapping of the dependency injection framework.
|
|
|
|
|
*
|
|
|
|
|
* This file returns an array that associates service name with instantiator functions
|
|
|
|
|
* that create the default instances for the services used by MediaWiki core.
|
|
|
|
|
* For every service that MediaWiki core requires, an instantiator must be defined in
|
|
|
|
|
* this file.
|
|
|
|
|
*
|
2019-08-27 16:49:36 +00:00
|
|
|
* Note that, ideally, all information used to instantiate service objects should come
|
|
|
|
|
* from configuration. Information derived from the current request is acceptable, but
|
|
|
|
|
* only where there is no feasible alternative. It is preferred that such information
|
|
|
|
|
* (like the client IP, the acting user's identity, requested title, etc) be passed to
|
|
|
|
|
* the service object's methods as parameters. This makes the flow of information more
|
|
|
|
|
* obvious, and makes it easier to understand the behavior of services.
|
|
|
|
|
*
|
2015-10-12 08:05:45 +00:00
|
|
|
* @note As of version 1.27, MediaWiki is only beginning to use dependency injection.
|
|
|
|
|
* The services defined here do not yet fully represent all services used by core,
|
|
|
|
|
* much of the code still relies on global state for this accessing services.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.27
|
|
|
|
|
*
|
2019-12-14 04:13:17 +00:00
|
|
|
* @see docs/Injection.md for an overview of using dependency injection in the
|
2015-10-12 08:05:45 +00:00
|
|
|
* MediaWiki code base.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-08-18 10:22:38 +00:00
|
|
|
use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
|
2017-11-07 03:10:14 +00:00
|
|
|
use MediaWiki\Auth\AuthManager;
|
2019-08-18 18:19:05 +00:00
|
|
|
use MediaWiki\BadFileLookup;
|
2019-09-20 15:03:48 +00:00
|
|
|
use MediaWiki\Block\BlockErrorFormatter;
|
2019-04-05 19:13:17 +00:00
|
|
|
use MediaWiki\Block\BlockManager;
|
2019-04-11 19:54:10 +00:00
|
|
|
use MediaWiki\Block\BlockRestrictionStore;
|
2019-10-19 11:08:40 +00:00
|
|
|
use MediaWiki\Cache\LinkBatchFactory;
|
2016-12-14 20:55:56 +00:00
|
|
|
use MediaWiki\Config\ConfigRepository;
|
2019-04-10 15:03:54 +00:00
|
|
|
use MediaWiki\Config\ServiceOptions;
|
2020-01-18 20:25:04 +00:00
|
|
|
use MediaWiki\Content\ContentHandlerFactory;
|
|
|
|
|
use MediaWiki\Content\IContentHandlerFactory;
|
2020-04-25 04:21:55 +00:00
|
|
|
use MediaWiki\EditPage\SpamChecker;
|
2019-08-16 10:00:15 +00:00
|
|
|
use MediaWiki\FileBackend\FSFile\TempFSFileFactory;
|
2019-08-15 18:07:36 +00:00
|
|
|
use MediaWiki\FileBackend\LockManager\LockManagerGroupFactory;
|
2020-04-17 06:03:29 +00:00
|
|
|
use MediaWiki\HookContainer\DeprecatedHooks;
|
2020-05-11 08:58:38 +00:00
|
|
|
use MediaWiki\HookContainer\GlobalHookRegistry;
|
2020-04-17 06:03:29 +00:00
|
|
|
use MediaWiki\HookContainer\HookContainer;
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
use MediaWiki\HookContainer\HookRunner;
|
2019-04-22 08:21:50 +00:00
|
|
|
use MediaWiki\Http\HttpRequestFactory;
|
2015-10-30 22:04:52 +00:00
|
|
|
use MediaWiki\Interwiki\ClassicInterwikiLookup;
|
2018-08-07 16:33:20 +00:00
|
|
|
use MediaWiki\Interwiki\InterwikiLookup;
|
2020-01-23 18:39:23 +00:00
|
|
|
use MediaWiki\Languages\LanguageConverterFactory;
|
2018-08-07 13:17:16 +00:00
|
|
|
use MediaWiki\Languages\LanguageFactory;
|
2019-08-22 15:39:26 +00:00
|
|
|
use MediaWiki\Languages\LanguageFallback;
|
2019-05-02 14:23:42 +00:00
|
|
|
use MediaWiki\Languages\LanguageNameUtils;
|
2018-08-07 16:33:20 +00:00
|
|
|
use MediaWiki\Linker\LinkRenderer;
|
Add LinkRenderer (rewrite of Linker::link())
This is a rewrite of Linker::link() to a non-static, LinkTarget-based
interface. Users of plain Linker::link() with no options can use the
LinkRenderer instance provided by MediaWikiServices. Others that
have specific options should create and configure their own instance,
which can be used to create as many links as necessary.
The main entrypoints for making links are:
* ->makeLink( $target, $text, $attribs, $query );
* ->makeKnownLink( $target, $text, $attribs, $query );
* ->makeBrokenLink( $target, $text, $attribs, $query );
The order of the parameters are the same as Linker::link(), except
$options are now part of the LinkRenderer instance, and
known/broken status requires calling the function explicitly.
Additionally, instead of passing in raw $html for the link text, the
$text parameter will automatically be escaped unless it is specially
marked as safe HTML using the MediaWiki\Linker\HtmlArmor class.
The LinkBegin and LinkEnd hooks are now deprecated, but still function
for backwards-compatability. Clients should migrate to the nearly-
equivalent LinkRendererBegin and LinkRendererEnd hooks.
The main differences between the hooks are:
* Passing HtmlPageLinkRenderer object instead of deprecated DummyLinker
* Using LinkTarget instead of Title
* Begin hook can no longer change known/broken status of link. Use the
TitleIsAlwaysKnown hook for that.
* $options are no longer passed, they can be read (but shouldn't be
modified!) from the LinkRenderer object.
Bug: T469
Change-Id: I057cc86ae6404a080aa3c8e0e956ecbb10a897d5
2016-04-21 20:13:21 +00:00
|
|
|
use MediaWiki\Linker\LinkRendererFactory;
|
2016-10-02 07:04:17 +00:00
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
2020-03-09 11:00:28 +00:00
|
|
|
use MediaWiki\Mail\Emailer;
|
|
|
|
|
use MediaWiki\Mail\IEmailer;
|
2015-10-12 08:05:45 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2019-07-15 10:24:38 +00:00
|
|
|
use MediaWiki\Message\MessageFormatterFactory;
|
2020-05-30 19:10:58 +00:00
|
|
|
use MediaWiki\Page\ContentModelChangeFactory;
|
2020-04-28 22:54:18 +00:00
|
|
|
use MediaWiki\Page\MergeHistoryFactory;
|
2019-05-01 11:39:45 +00:00
|
|
|
use MediaWiki\Page\MovePageFactory;
|
2020-04-28 22:54:18 +00:00
|
|
|
use MediaWiki\Page\PageCommandFactory;
|
2019-03-07 20:02:07 +00:00
|
|
|
use MediaWiki\Permissions\PermissionManager;
|
2017-11-07 03:10:14 +00:00
|
|
|
use MediaWiki\Preferences\DefaultPreferencesFactory;
|
2020-01-10 00:00:51 +00:00
|
|
|
use MediaWiki\Preferences\PreferencesFactory;
|
2020-06-02 21:24:59 +00:00
|
|
|
use MediaWiki\Revision\ContributionsLookup;
|
2018-11-19 11:39:56 +00:00
|
|
|
use MediaWiki\Revision\MainSlotRoleHandler;
|
2018-09-20 17:29:04 +00:00
|
|
|
use MediaWiki\Revision\RevisionFactory;
|
|
|
|
|
use MediaWiki\Revision\RevisionLookup;
|
|
|
|
|
use MediaWiki\Revision\RevisionRenderer;
|
|
|
|
|
use MediaWiki\Revision\RevisionStore;
|
|
|
|
|
use MediaWiki\Revision\RevisionStoreFactory;
|
2020-01-10 00:00:51 +00:00
|
|
|
use MediaWiki\Revision\SlotRoleRegistry;
|
2017-10-07 02:26:52 +00:00
|
|
|
use MediaWiki\Shell\CommandFactory;
|
2020-02-21 00:01:43 +00:00
|
|
|
use MediaWiki\SpecialPage\SpecialPageFactory;
|
2018-08-07 16:33:20 +00:00
|
|
|
use MediaWiki\Storage\BlobStore;
|
2017-12-23 17:14:28 +00:00
|
|
|
use MediaWiki\Storage\BlobStoreFactory;
|
2020-05-27 14:45:29 +00:00
|
|
|
use MediaWiki\Storage\NameTableStore;
|
2018-09-04 01:59:03 +00:00
|
|
|
use MediaWiki\Storage\NameTableStoreFactory;
|
2019-04-13 04:38:55 +00:00
|
|
|
use MediaWiki\Storage\PageEditStash;
|
2020-01-10 00:00:51 +00:00
|
|
|
use MediaWiki\Storage\SqlBlobStore;
|
2020-05-11 19:19:13 +00:00
|
|
|
use MediaWiki\User\DefaultOptionsLookup;
|
2020-04-04 03:39:01 +00:00
|
|
|
use MediaWiki\User\TalkPageNotificationManager;
|
2020-05-26 03:33:28 +00:00
|
|
|
use MediaWiki\User\UserEditTracker;
|
2019-10-24 03:14:31 +00:00
|
|
|
use MediaWiki\User\UserGroupManager;
|
|
|
|
|
use MediaWiki\User\UserGroupManagerFactory;
|
|
|
|
|
use MediaWiki\User\UserIdentity;
|
Add a new UserNameUtils service
This replaces User::isValidUserName, ::isUsableName, ::isCreatableName,
::getCanonicalName, and ::isIP.
Unlike User::isIP, UserNameUtils::isIP will //not// return true
for IPv6 ranges.
UserNameUtils::isIPRange, like User::isIPRange, accepts a name and
simply calls IPUtils::isValidRange.
User::isValidUserName, ::isUsableName, ::isCreatableName,
::getCanonical, ::isIP, and ::isValidRange are all soft deprecated
A follow up patch will add this to the release notes, to avoid merge
conflicts.
Bug: T245231
Bug: T239527
Change-Id: I46684bc492bb74b728ff102971f6cdd4d746a50a
2020-02-23 23:52:44 +00:00
|
|
|
use MediaWiki\User\UserNameUtils;
|
2020-01-17 06:21:28 +00:00
|
|
|
use MediaWiki\User\UserOptionsLookup;
|
|
|
|
|
use MediaWiki\User\UserOptionsManager;
|
2020-05-23 08:43:34 +00:00
|
|
|
use MediaWiki\User\WatchlistNotificationManager;
|
2019-06-29 04:50:31 +00:00
|
|
|
use Wikimedia\DependencyStore\KeyValueDependencyStore;
|
|
|
|
|
use Wikimedia\DependencyStore\SqlModuleDependencyStore;
|
2020-01-10 00:00:51 +00:00
|
|
|
use Wikimedia\Message\IMessageFormatterFactory;
|
2019-08-21 16:10:30 +00:00
|
|
|
use Wikimedia\ObjectFactory;
|
2019-11-04 22:02:33 +00:00
|
|
|
use Wikimedia\Services\RecursiveServiceDependencyException;
|
2019-05-31 23:24:56 +00:00
|
|
|
use Wikimedia\UUID\GlobalIdGenerator;
|
2015-10-12 08:05:45 +00:00
|
|
|
|
|
|
|
|
return [
|
2020-01-19 14:48:00 +00:00
|
|
|
'ActorMigration' => function () : ActorMigration {
|
2019-07-23 17:40:52 +00:00
|
|
|
return new ActorMigration( SCHEMA_COMPAT_NEW );
|
2016-05-01 19:29:11 +00:00
|
|
|
},
|
|
|
|
|
|
2019-11-08 21:24:00 +00:00
|
|
|
'AuthManager' => function ( MediaWikiServices $services ) : AuthManager {
|
|
|
|
|
$authManager = new AuthManager(
|
|
|
|
|
RequestContext::getMain()->getRequest(),
|
|
|
|
|
$services->getMainConfig(),
|
2020-02-20 09:45:13 +00:00
|
|
|
$services->getObjectFactory(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getPermissionManager(),
|
|
|
|
|
$services->getHookContainer()
|
2019-11-08 21:24:00 +00:00
|
|
|
);
|
|
|
|
|
$authManager->setLogger( LoggerFactory::getInstance( 'authentication' ) );
|
|
|
|
|
return $authManager;
|
|
|
|
|
},
|
|
|
|
|
|
2019-08-18 18:19:05 +00:00
|
|
|
'BadFileLookup' => function ( MediaWikiServices $services ) : BadFileLookup {
|
|
|
|
|
return new BadFileLookup(
|
|
|
|
|
function () {
|
|
|
|
|
return wfMessage( 'bad_image_list' )->inContentLanguage()->plain();
|
|
|
|
|
},
|
|
|
|
|
$services->getLocalServerObjectCache(),
|
|
|
|
|
$services->getRepoGroup(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getTitleParser(),
|
|
|
|
|
$services->getHookContainer()
|
2019-08-18 18:19:05 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'BlobStore' => function ( MediaWikiServices $services ) : BlobStore {
|
2018-08-03 08:05:44 +00:00
|
|
|
return $services->getService( '_SqlBlobStore' );
|
2016-05-01 19:29:11 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'BlobStoreFactory' => function ( MediaWikiServices $services ) : BlobStoreFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new BlobStoreFactory(
|
2018-08-22 06:47:04 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2018-02-27 06:24:46 +00:00
|
|
|
$services->getExternalStoreAccess(),
|
2018-08-03 08:05:44 +00:00
|
|
|
$services->getMainWANObjectCache(),
|
2019-10-08 18:27:22 +00:00
|
|
|
new ServiceOptions( BlobStoreFactory::CONSTRUCTOR_OPTIONS,
|
2019-10-01 16:20:45 +00:00
|
|
|
$services->getMainConfig() )
|
2018-08-03 08:05:44 +00:00
|
|
|
);
|
2015-10-12 08:05:45 +00:00
|
|
|
},
|
|
|
|
|
|
2019-09-20 15:03:48 +00:00
|
|
|
'BlockErrorFormatter' => function () : BlockErrorFormatter {
|
|
|
|
|
return new BlockErrorFormatter();
|
|
|
|
|
},
|
|
|
|
|
|
2019-04-05 19:13:17 +00:00
|
|
|
'BlockManager' => function ( MediaWikiServices $services ) : BlockManager {
|
|
|
|
|
return new BlockManager(
|
2019-06-26 14:06:01 +00:00
|
|
|
new ServiceOptions(
|
2019-10-08 18:24:22 +00:00
|
|
|
BlockManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
|
2019-06-26 14:06:01 +00:00
|
|
|
),
|
2019-08-20 17:29:59 +00:00
|
|
|
$services->getPermissionManager(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
LoggerFactory::getInstance( 'BlockManager' ),
|
|
|
|
|
$services->getHookContainer()
|
2019-04-05 19:13:17 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-04-11 19:54:10 +00:00
|
|
|
'BlockRestrictionStore' => function ( MediaWikiServices $services ) : BlockRestrictionStore {
|
|
|
|
|
return new BlockRestrictionStore(
|
|
|
|
|
$services->getDBLoadBalancer()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2020-05-27 14:45:29 +00:00
|
|
|
'ChangeTagDefStore' => function ( MediaWikiServices $services ) : NameTableStore {
|
|
|
|
|
return $services->getNameTableStoreFactory()->getChangeTagDef();
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'CommentStore' => function ( MediaWikiServices $services ) : CommentStore {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new CommentStore(
|
|
|
|
|
$services->getContentLanguage(),
|
2019-01-04 18:55:11 +00:00
|
|
|
MIGRATION_NEW
|
2018-08-03 08:05:44 +00:00
|
|
|
);
|
2015-10-12 08:05:45 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'ConfigFactory' => function ( MediaWikiServices $services ) : ConfigFactory {
|
2015-10-12 08:05:45 +00:00
|
|
|
// Use the bootstrap config to initialize the ConfigFactory.
|
|
|
|
|
$registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' );
|
|
|
|
|
$factory = new ConfigFactory();
|
|
|
|
|
|
|
|
|
|
foreach ( $registry as $name => $callback ) {
|
|
|
|
|
$factory->register( $name, $callback );
|
|
|
|
|
}
|
|
|
|
|
return $factory;
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'ConfigRepository' => function ( MediaWikiServices $services ) : ConfigRepository {
|
2016-12-14 20:55:56 +00:00
|
|
|
return new ConfigRepository( $services->getConfigFactory() );
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'ConfiguredReadOnlyMode' => function ( MediaWikiServices $services ) : ConfiguredReadOnlyMode {
|
2019-04-10 15:03:54 +00:00
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
return new ConfiguredReadOnlyMode(
|
|
|
|
|
$config->get( 'ReadOnly' ),
|
|
|
|
|
$config->get( 'ReadOnlyFile' )
|
|
|
|
|
);
|
2015-10-12 08:05:45 +00:00
|
|
|
},
|
|
|
|
|
|
2020-01-18 20:25:04 +00:00
|
|
|
'ContentHandlerFactory' => function ( MediaWikiServices $services ) : IContentHandlerFactory {
|
|
|
|
|
$contentHandlerConfig = $services->getMainConfig()->get( 'ContentHandlers' );
|
|
|
|
|
|
2020-01-18 20:25:04 +00:00
|
|
|
return new ContentHandlerFactory(
|
|
|
|
|
$contentHandlerConfig,
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getObjectFactory(),
|
2020-06-01 01:53:14 +00:00
|
|
|
$services->getHookContainer(),
|
|
|
|
|
LoggerFactory::getInstance( 'ContentHandler' )
|
2020-01-18 20:25:04 +00:00
|
|
|
);
|
2020-01-18 20:25:04 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'ContentLanguage' => function ( MediaWikiServices $services ) : Language {
|
2018-08-07 13:17:16 +00:00
|
|
|
return $services->getLanguageFactory()->getLanguage(
|
|
|
|
|
$services->getMainConfig()->get( 'LanguageCode' ) );
|
2015-10-30 22:04:52 +00:00
|
|
|
},
|
|
|
|
|
|
2020-05-30 19:10:58 +00:00
|
|
|
'ContentModelChangeFactory' => function ( MediaWikiServices $services ) : ContentModelChangeFactory {
|
|
|
|
|
return $services->getService( '_PageCommandFactory' );
|
|
|
|
|
},
|
|
|
|
|
|
2020-05-27 14:45:29 +00:00
|
|
|
'ContentModelStore' => function ( MediaWikiServices $services ) : NameTableStore {
|
|
|
|
|
return $services->getNameTableStoreFactory()->getContentModels();
|
|
|
|
|
},
|
|
|
|
|
|
2020-06-02 21:24:59 +00:00
|
|
|
'ContributionsLookup' => function ( MediaWikiServices $services ) : ContributionsLookup {
|
|
|
|
|
return new ContributionsLookup( $services->getRevisionStore() );
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'CryptHKDF' => function ( MediaWikiServices $services ) : CryptHKDF {
|
2018-07-02 17:01:45 +00:00
|
|
|
$config = $services->getMainConfig();
|
2018-08-03 08:05:44 +00:00
|
|
|
|
|
|
|
|
$secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
|
|
|
|
|
if ( !$secret ) {
|
|
|
|
|
throw new RuntimeException( "Cannot use MWCryptHKDF without a secret." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// In HKDF, the context can be known to the attacker, but this will
|
|
|
|
|
// keep simultaneous runs from producing the same output.
|
|
|
|
|
$context = [ microtime(), getmypid(), gethostname() ];
|
|
|
|
|
|
|
|
|
|
// Setup salt cache. Use APC, or fallback to the main cache if it isn't setup
|
|
|
|
|
$cache = $services->getLocalServerObjectCache();
|
|
|
|
|
if ( $cache instanceof EmptyBagOStuff ) {
|
|
|
|
|
$cache = ObjectCache::getLocalClusterInstance();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm' ), $cache, $context );
|
|
|
|
|
},
|
|
|
|
|
|
Rehabilitate DateFormatter
This code is surprisingly little changed since I added the class in
November 2003, and needs some modernisation.
* Remove the "linked" option, unused since 1.21. Similarly, make the
"match-whole" option implied. This allows the regexes to be
simplified. Nothing will be broken, according to CodeSearch.
* Instead of ucfirst(), use the canonical month name from the language.
This will work with e.g. French which does not capitalise month names.
* Stop caching DateFormatter instances in APC. Caching was added
in 2005 when initialisation was being done on every request, but now
it is only needed when parsing a page with {{#formatdate}}, which is
rarely, and the constructor overhead is only 200µs after Language
object data initialisation. Instead, use an in-process cache via a
factory service.
* Add docs and extra tests.
* Remove todo note obsolete since 38 minutes after the original commit.
* Rename many variables.
* Use double-slash comments
* Don't store the Language object, just get arrays.
* Use mb_strtolower() instead of Language::lc() -- any customisation of
Language::lc() would break PCRE case-insensitive matching.
* Use named subpatterns instead of "keys"
* Remove the ISO1/ISO2 distinction, the only difference was linking.
* Use closure variables instead of temporary object members
Change-Id: I25fb1203dba2930724d7bc28ad0d51f59f88e1ea
2019-04-10 05:33:57 +00:00
|
|
|
'DateFormatterFactory' => function () : DateFormatterFactory {
|
|
|
|
|
return new DateFormatterFactory;
|
|
|
|
|
},
|
|
|
|
|
|
2019-04-22 08:21:50 +00:00
|
|
|
'DBLoadBalancer' => function ( MediaWikiServices $services ) : Wikimedia\Rdbms\ILoadBalancer {
|
2018-08-03 08:05:44 +00:00
|
|
|
// just return the default LB from the DBLoadBalancerFactory service
|
|
|
|
|
return $services->getDBLoadBalancerFactory()->getMainLB();
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'DBLoadBalancerFactory' =>
|
|
|
|
|
function ( MediaWikiServices $services ) : Wikimedia\Rdbms\LBFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
$mainConfig = $services->getMainConfig();
|
|
|
|
|
|
2019-11-04 22:02:33 +00:00
|
|
|
try {
|
|
|
|
|
$stash = $services->getMainObjectStash();
|
|
|
|
|
} catch ( RecursiveServiceDependencyException $e ) {
|
|
|
|
|
$stash = new EmptyBagOStuff(); // T141804: handle cases like CACHE_DB
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $stash instanceof EmptyBagOStuff ) {
|
|
|
|
|
// Use process cache if the main stash is disabled or there was recursion
|
|
|
|
|
$stash = new HashBagOStuff( [ 'maxKeys' => 100 ] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$wanCache = $services->getMainWANObjectCache();
|
|
|
|
|
} catch ( RecursiveServiceDependencyException $e ) {
|
|
|
|
|
$wanCache = WANObjectCache::newEmpty(); // T141804: handle cases like CACHE_DB
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-03 08:05:44 +00:00
|
|
|
$lbConf = MWLBFactory::applyDefaultConfig(
|
|
|
|
|
$mainConfig->get( 'LBFactoryConf' ),
|
2019-10-08 18:33:31 +00:00
|
|
|
new ServiceOptions( MWLBFactory::APPLY_DEFAULT_CONFIG_OPTIONS, $mainConfig ),
|
2019-03-22 07:17:36 +00:00
|
|
|
$services->getConfiguredReadOnlyMode(),
|
|
|
|
|
$services->getLocalServerObjectCache(),
|
2019-11-04 22:02:33 +00:00
|
|
|
$stash,
|
|
|
|
|
$wanCache
|
2018-07-02 17:01:45 +00:00
|
|
|
);
|
2019-07-03 22:02:41 +00:00
|
|
|
|
2018-08-03 08:05:44 +00:00
|
|
|
$class = MWLBFactory::getLBFactoryClass( $lbConf );
|
2019-07-03 22:02:41 +00:00
|
|
|
$instance = new $class( $lbConf );
|
|
|
|
|
|
|
|
|
|
MWLBFactory::setDomainAliases( $instance );
|
2018-08-03 08:05:44 +00:00
|
|
|
|
2019-07-03 22:02:41 +00:00
|
|
|
return $instance;
|
2018-07-02 17:01:45 +00:00
|
|
|
},
|
|
|
|
|
|
2020-03-09 11:00:28 +00:00
|
|
|
'Emailer' => function ( MediaWikiServices $services ) : IEmailer {
|
|
|
|
|
return new Emailer();
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'EventRelayerGroup' => function ( MediaWikiServices $services ) : EventRelayerGroup {
|
2016-04-23 00:09:14 +00:00
|
|
|
return new EventRelayerGroup( $services->getMainConfig()->get( 'EventRelayerConfig' ) );
|
|
|
|
|
},
|
|
|
|
|
|
2018-02-27 06:24:46 +00:00
|
|
|
'ExternalStoreAccess' => function ( MediaWikiServices $services ) : ExternalStoreAccess {
|
|
|
|
|
return new ExternalStoreAccess(
|
|
|
|
|
$services->getExternalStoreFactory(),
|
|
|
|
|
LoggerFactory::getInstance( 'ExternalStore' )
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'ExternalStoreFactory' => function ( MediaWikiServices $services ) : ExternalStoreFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
$config = $services->getMainConfig();
|
2018-02-27 06:24:46 +00:00
|
|
|
$writeStores = $config->get( 'DefaultExternalStore' );
|
2016-04-03 08:37:11 +00:00
|
|
|
|
2018-08-03 08:05:44 +00:00
|
|
|
return new ExternalStoreFactory(
|
2018-02-27 06:24:46 +00:00
|
|
|
$config->get( 'ExternalStores' ),
|
|
|
|
|
( $writeStores !== false ) ? (array)$writeStores : [],
|
|
|
|
|
$services->getDBLoadBalancer()->getLocalDomainID(),
|
|
|
|
|
LoggerFactory::getInstance( 'ExternalStore' )
|
2018-08-03 08:05:44 +00:00
|
|
|
);
|
2016-04-19 11:55:23 +00:00
|
|
|
},
|
|
|
|
|
|
2019-08-13 08:52:13 +00:00
|
|
|
'FileBackendGroup' => function ( MediaWikiServices $services ) : FileBackendGroup {
|
|
|
|
|
$mainConfig = $services->getMainConfig();
|
|
|
|
|
|
|
|
|
|
$ld = WikiMap::getCurrentWikiDbDomain();
|
|
|
|
|
$fallbackWikiId = WikiMap::getWikiIdFromDbDomain( $ld );
|
|
|
|
|
// If the local wiki ID and local domain ID do not match, probably due to a non-default
|
|
|
|
|
// schema, issue a warning. A non-default schema indicates that it might be used to
|
|
|
|
|
// disambiguate different wikis.
|
|
|
|
|
$legacyDomainId = strlen( $ld->getTablePrefix() )
|
|
|
|
|
? "{$ld->getDatabase()}-{$ld->getTablePrefix()}"
|
|
|
|
|
: $ld->getDatabase();
|
|
|
|
|
if ( $ld->getSchema() !== null && $legacyDomainId !== $fallbackWikiId ) {
|
|
|
|
|
wfWarn(
|
|
|
|
|
"Legacy default 'domainId' is '$legacyDomainId' but wiki ID is '$fallbackWikiId'."
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$cache = $services->getLocalServerObjectCache();
|
|
|
|
|
if ( $cache instanceof EmptyBagOStuff ) {
|
|
|
|
|
$cache = new HashBagOStuff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new FileBackendGroup(
|
|
|
|
|
new ServiceOptions( FileBackendGroup::CONSTRUCTOR_OPTIONS, $mainConfig,
|
|
|
|
|
[ 'fallbackWikiId' => $fallbackWikiId ] ),
|
|
|
|
|
$services->getConfiguredReadOnlyMode(),
|
|
|
|
|
$cache,
|
|
|
|
|
$services->getMainWANObjectCache(),
|
|
|
|
|
$services->getMimeAnalyzer(),
|
|
|
|
|
$services->getLockManagerGroupFactory(),
|
2019-10-23 13:34:53 +00:00
|
|
|
$services->getTempFSFileFactory(),
|
|
|
|
|
$services->getObjectFactory()
|
2019-08-13 08:52:13 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'GenderCache' => function ( MediaWikiServices $services ) : GenderCache {
|
2019-06-05 21:16:45 +00:00
|
|
|
$nsInfo = $services->getNamespaceInfo();
|
|
|
|
|
// Database layer may be disabled, so processing without database connection
|
|
|
|
|
$dbLoadBalancer = $services->isServiceDisabled( 'DBLoadBalancer' )
|
|
|
|
|
? null
|
|
|
|
|
: $services->getDBLoadBalancer();
|
|
|
|
|
return new GenderCache( $nsInfo, $dbLoadBalancer );
|
2018-08-03 08:05:44 +00:00
|
|
|
},
|
2016-05-01 19:29:11 +00:00
|
|
|
|
2019-05-31 23:24:56 +00:00
|
|
|
'GlobalIdGenerator' => function ( MediaWikiServices $services ) : GlobalIdGenerator {
|
|
|
|
|
$mainConfig = $services->getMainConfig();
|
|
|
|
|
|
|
|
|
|
return new GlobalIdGenerator(
|
|
|
|
|
$mainConfig->get( 'TmpDirectory' ),
|
|
|
|
|
// Ignore APC-like caches in CLI mode since there is no meaningful persistence.
|
|
|
|
|
// This avoids having counters restart with each script run. The ID generator
|
|
|
|
|
// will fallback to using the disk in those cases.
|
|
|
|
|
$mainConfig->get( 'CommandLineMode' )
|
|
|
|
|
? new EmptyBagOStuff()
|
|
|
|
|
: $services->getLocalServerObjectCache(),
|
|
|
|
|
function ( $command ) {
|
|
|
|
|
return wfShellExec( $command );
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2020-02-10 14:47:46 +00:00
|
|
|
'HookContainer' => function ( MediaWikiServices $services ) : HookContainer {
|
|
|
|
|
$extRegistry = ExtensionRegistry::getInstance();
|
|
|
|
|
$extDeprecatedHooks = $extRegistry->getAttribute( 'DeprecatedHooks' );
|
|
|
|
|
$deprecatedHooks = new DeprecatedHooks( $extDeprecatedHooks );
|
2020-05-11 08:58:38 +00:00
|
|
|
$hookRegistry = new GlobalHookRegistry( $extRegistry, $deprecatedHooks );
|
2020-02-10 14:47:46 +00:00
|
|
|
return new HookContainer(
|
2020-05-11 08:58:38 +00:00
|
|
|
$hookRegistry,
|
|
|
|
|
$services->getObjectFactory()
|
2020-02-10 14:47:46 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-15 00:23:26 +00:00
|
|
|
'HtmlCacheUpdater' => function ( MediaWikiServices $services ) : HtmlCacheUpdater {
|
|
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
|
|
|
|
|
return new HtmlCacheUpdater(
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getHookContainer(),
|
2019-03-15 00:23:26 +00:00
|
|
|
$config->get( 'CdnReboundPurgeDelay' ),
|
2020-05-21 09:40:16 +00:00
|
|
|
$config->get( 'UseFileCache' ),
|
|
|
|
|
$config->get( 'CdnMaxAge' )
|
2019-03-15 00:23:26 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'HttpRequestFactory' =>
|
2019-04-22 08:21:50 +00:00
|
|
|
function ( MediaWikiServices $services ) : HttpRequestFactory {
|
2020-05-15 05:19:56 +00:00
|
|
|
return new HttpRequestFactory(
|
|
|
|
|
new ServiceOptions(
|
|
|
|
|
HttpRequestFactory::CONSTRUCTOR_OPTIONS,
|
|
|
|
|
$services->getMainConfig()
|
|
|
|
|
),
|
|
|
|
|
LoggerFactory::getInstance( 'http' )
|
|
|
|
|
);
|
2018-08-03 08:05:44 +00:00
|
|
|
},
|
2016-05-01 19:29:11 +00:00
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'InterwikiLookup' => function ( MediaWikiServices $services ) : InterwikiLookup {
|
2018-08-03 08:05:44 +00:00
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
return new ClassicInterwikiLookup(
|
|
|
|
|
$services->getContentLanguage(),
|
|
|
|
|
$services->getMainWANObjectCache(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getHookContainer(),
|
2018-08-03 08:05:44 +00:00
|
|
|
$config->get( 'InterwikiExpiry' ),
|
|
|
|
|
$config->get( 'InterwikiCache' ),
|
|
|
|
|
$config->get( 'InterwikiScopes' ),
|
|
|
|
|
$config->get( 'InterwikiFallbackSite' )
|
|
|
|
|
);
|
2016-04-19 11:55:23 +00:00
|
|
|
},
|
2016-04-03 08:37:11 +00:00
|
|
|
|
2020-02-07 02:24:00 +00:00
|
|
|
'JobRunner' => function ( MediaWikiServices $services ) : JobRunner {
|
|
|
|
|
return new JobRunner(
|
|
|
|
|
new ServiceOptions( JobRunner::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
|
|
|
|
|
$services->getDBLoadBalancerFactory(),
|
|
|
|
|
JobQueueGroup::singleton(),
|
|
|
|
|
$services->getReadOnlyMode(),
|
|
|
|
|
$services->getLinkCache(),
|
|
|
|
|
$services->getStatsdDataFactory(),
|
|
|
|
|
LoggerFactory::getInstance( 'runJobs' )
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2020-01-23 18:39:23 +00:00
|
|
|
'LanguageConverterFactory' => function ( MediaWikiServices $services ) : LanguageConverterFactory {
|
|
|
|
|
$usePigLatinVariant = $services->getMainConfig()->get( 'UsePigLatinVariant' );
|
2020-03-29 22:25:50 +00:00
|
|
|
return new LanguageConverterFactory( $usePigLatinVariant, function () use ( $services ) {
|
2020-01-23 18:39:23 +00:00
|
|
|
return $services->getContentLanguage();
|
|
|
|
|
} );
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 13:17:16 +00:00
|
|
|
'LanguageFactory' => function ( MediaWikiServices $services ) : LanguageFactory {
|
|
|
|
|
return new LanguageFactory(
|
|
|
|
|
new ServiceOptions( LanguageFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
|
|
|
|
|
$services->getLocalisationCache(),
|
|
|
|
|
$services->getLanguageNameUtils(),
|
2020-01-23 18:39:23 +00:00
|
|
|
$services->getLanguageFallback(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getLanguageConverterFactory(),
|
|
|
|
|
$services->getHookContainer()
|
2018-08-07 13:17:16 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-08-22 15:39:26 +00:00
|
|
|
'LanguageFallback' => function ( MediaWikiServices $services ) : LanguageFallback {
|
|
|
|
|
return new LanguageFallback(
|
|
|
|
|
$services->getMainConfig()->get( 'LanguageCode' ),
|
|
|
|
|
$services->getLocalisationCache(),
|
|
|
|
|
$services->getLanguageNameUtils()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-05-02 14:23:42 +00:00
|
|
|
'LanguageNameUtils' => function ( MediaWikiServices $services ) : LanguageNameUtils {
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
return new LanguageNameUtils(
|
|
|
|
|
new ServiceOptions(
|
|
|
|
|
LanguageNameUtils::CONSTRUCTOR_OPTIONS,
|
|
|
|
|
$services->getMainConfig()
|
|
|
|
|
),
|
|
|
|
|
$services->getHookContainer()
|
|
|
|
|
);
|
2019-05-02 14:23:42 +00:00
|
|
|
},
|
|
|
|
|
|
2019-10-19 11:08:40 +00:00
|
|
|
'LinkBatchFactory' => function ( MediaWikiServices $services ) : LinkBatchFactory {
|
|
|
|
|
return new LinkBatchFactory(
|
|
|
|
|
$services->getLinkCache(),
|
|
|
|
|
$services->getTitleFormatter(),
|
|
|
|
|
$services->getContentLanguage(),
|
|
|
|
|
$services->getGenderCache(),
|
|
|
|
|
$services->getDBLoadBalancer()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'LinkCache' => function ( MediaWikiServices $services ) : LinkCache {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new LinkCache(
|
|
|
|
|
$services->getTitleFormatter(),
|
2019-04-09 09:30:58 +00:00
|
|
|
$services->getMainWANObjectCache(),
|
|
|
|
|
$services->getNamespaceInfo()
|
2016-04-06 10:46:50 +00:00
|
|
|
);
|
2018-08-03 08:05:44 +00:00
|
|
|
},
|
2017-03-20 13:18:22 +00:00
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'LinkRenderer' => function ( MediaWikiServices $services ) : LinkRenderer {
|
2018-08-03 08:05:44 +00:00
|
|
|
if ( defined( 'MW_NO_SESSION' ) ) {
|
|
|
|
|
return $services->getLinkRendererFactory()->create();
|
|
|
|
|
} else {
|
2019-08-27 16:49:36 +00:00
|
|
|
// Normally information from the current request would not be passed in here;
|
|
|
|
|
// this is an exception. (See also the class documentation.)
|
2019-03-07 18:19:58 +00:00
|
|
|
return $services->getLinkRendererFactory()->createForUser(
|
|
|
|
|
RequestContext::getMain()->getUser()
|
|
|
|
|
);
|
2018-08-03 08:05:44 +00:00
|
|
|
}
|
2016-04-06 10:46:50 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'LinkRendererFactory' => function ( MediaWikiServices $services ) : LinkRendererFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new LinkRendererFactory(
|
|
|
|
|
$services->getTitleFormatter(),
|
2018-08-05 12:44:11 +00:00
|
|
|
$services->getLinkCache(),
|
2020-05-22 18:33:06 +00:00
|
|
|
$services->getNamespaceInfo(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getSpecialPageFactory(),
|
|
|
|
|
$services->getHookContainer()
|
2018-01-26 19:17:27 +00:00
|
|
|
);
|
2016-04-19 09:34:31 +00:00
|
|
|
},
|
|
|
|
|
|
2019-05-01 13:56:41 +00:00
|
|
|
'LocalisationCache' => function ( MediaWikiServices $services ) : LocalisationCache {
|
|
|
|
|
$conf = $services->getMainConfig()->get( 'LocalisationCacheConf' );
|
|
|
|
|
|
|
|
|
|
$logger = LoggerFactory::getInstance( 'localisation' );
|
|
|
|
|
|
|
|
|
|
$store = LocalisationCache::getStoreFromConf(
|
|
|
|
|
$conf, $services->getMainConfig()->get( 'CacheDirectory' ) );
|
2020-02-21 00:50:54 +00:00
|
|
|
$logger->debug( 'LocalisationCache using store ' . get_class( $store ) );
|
2019-05-01 13:56:41 +00:00
|
|
|
|
|
|
|
|
return new $conf['class'](
|
|
|
|
|
new ServiceOptions(
|
2019-10-08 18:25:30 +00:00
|
|
|
LocalisationCache::CONSTRUCTOR_OPTIONS,
|
2019-05-01 13:56:41 +00:00
|
|
|
// Two of the options are stored in $wgLocalisationCacheConf
|
|
|
|
|
$conf,
|
|
|
|
|
// In case someone set that config variable and didn't reset all keys, set defaults.
|
|
|
|
|
[
|
|
|
|
|
'forceRecache' => false,
|
|
|
|
|
'manualRecache' => false,
|
|
|
|
|
],
|
|
|
|
|
// Some other options come from config itself
|
|
|
|
|
$services->getMainConfig()
|
|
|
|
|
),
|
|
|
|
|
$store,
|
|
|
|
|
$logger,
|
|
|
|
|
[ function () use ( $services ) {
|
2019-11-26 19:33:10 +00:00
|
|
|
// NOTE: Make sure we use the same cache object that is assigned in the
|
|
|
|
|
// constructor of the MessageBlobStore class used by ResourceLoader.
|
|
|
|
|
// T231866: Avoid circular dependency via ResourceLoader.
|
|
|
|
|
MessageBlobStore::clearGlobalCacheEntry( $services->getMainWANObjectCache() );
|
2019-05-02 14:23:42 +00:00
|
|
|
} ],
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getLanguageNameUtils(),
|
|
|
|
|
$services->getHookContainer()
|
2019-05-01 13:56:41 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
|
2020-03-04 15:21:19 +00:00
|
|
|
return ObjectCache::makeLocalServerCache();
|
2016-10-02 07:04:17 +00:00
|
|
|
},
|
|
|
|
|
|
2019-08-15 18:07:36 +00:00
|
|
|
'LockManagerGroupFactory' => function ( MediaWikiServices $services ) : LockManagerGroupFactory {
|
|
|
|
|
return new LockManagerGroupFactory(
|
|
|
|
|
WikiMap::getCurrentWikiDbDomain()->getId(),
|
|
|
|
|
$services->getMainConfig()->get( 'LockManagers' ),
|
|
|
|
|
$services->getDBLoadBalancerFactory()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'MagicWordFactory' => function ( MediaWikiServices $services ) : MagicWordFactory {
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
return new MagicWordFactory(
|
|
|
|
|
$services->getContentLanguage(),
|
|
|
|
|
$services->getHookContainer()
|
|
|
|
|
);
|
2018-08-03 08:05:44 +00:00
|
|
|
},
|
2016-10-04 17:48:02 +00:00
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'MainConfig' => function ( MediaWikiServices $services ) : Config {
|
2018-08-03 08:05:44 +00:00
|
|
|
// Use the 'main' config from the ConfigFactory service.
|
|
|
|
|
return $services->getConfigFactory()->makeConfig( 'main' );
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'MainObjectStash' => function ( MediaWikiServices $services ) : BagOStuff {
|
2018-08-03 08:05:44 +00:00
|
|
|
$mainConfig = $services->getMainConfig();
|
|
|
|
|
|
|
|
|
|
$id = $mainConfig->get( 'MainStash' );
|
|
|
|
|
if ( !isset( $mainConfig->get( 'ObjectCaches' )[$id] ) ) {
|
|
|
|
|
throw new UnexpectedValueException(
|
|
|
|
|
"Cache type \"$id\" is not present in \$wgObjectCaches." );
|
2016-10-04 17:48:02 +00:00
|
|
|
}
|
|
|
|
|
|
2019-10-10 20:30:47 +00:00
|
|
|
$params = $mainConfig->get( 'ObjectCaches' )[$id];
|
|
|
|
|
|
2020-03-02 14:56:08 +00:00
|
|
|
$store = ObjectCache::newFromParams( $params, $mainConfig );
|
|
|
|
|
$store->getLogger()->debug( 'MainObjectStash using store {class}', [
|
2019-10-10 20:30:47 +00:00
|
|
|
'class' => get_class( $store )
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
return $store;
|
2018-08-03 08:05:44 +00:00
|
|
|
},
|
2016-10-04 17:48:02 +00:00
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'MainWANObjectCache' => function ( MediaWikiServices $services ) : WANObjectCache {
|
2018-08-03 08:05:44 +00:00
|
|
|
$mainConfig = $services->getMainConfig();
|
|
|
|
|
|
2020-03-30 21:28:53 +00:00
|
|
|
$wanId = $mainConfig->get( 'MainWANCache' );
|
|
|
|
|
$wanParams = $mainConfig->get( 'WANObjectCaches' )[$wanId] ?? null;
|
|
|
|
|
if ( !$wanParams ) {
|
2018-08-03 08:05:44 +00:00
|
|
|
throw new UnexpectedValueException(
|
2020-03-30 21:28:53 +00:00
|
|
|
"wgWANObjectCaches must have \"$wanId\" set (via wgMainWANCache)"
|
|
|
|
|
);
|
2016-10-04 17:48:02 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-30 21:28:53 +00:00
|
|
|
$cacheId = $wanParams['cacheId'];
|
|
|
|
|
$wanClass = $wanParams['class'];
|
|
|
|
|
unset( $wanParams['cacheId'] );
|
|
|
|
|
unset( $wanParams['class'] );
|
2019-10-08 21:34:17 +00:00
|
|
|
|
2020-03-30 21:28:53 +00:00
|
|
|
$storeParams = $mainConfig->get( 'ObjectCaches' )[$cacheId] ?? null;
|
|
|
|
|
if ( !$storeParams ) {
|
2018-08-03 08:05:44 +00:00
|
|
|
throw new UnexpectedValueException(
|
2020-03-30 21:28:53 +00:00
|
|
|
"wgObjectCaches must have \"$cacheId\" set (via wgWANObjectCaches)"
|
|
|
|
|
);
|
2018-08-03 08:05:44 +00:00
|
|
|
}
|
2020-03-02 14:56:08 +00:00
|
|
|
$store = ObjectCache::newFromParams( $storeParams, $mainConfig );
|
|
|
|
|
$logger = $store->getLogger();
|
2019-10-08 21:34:17 +00:00
|
|
|
$logger->debug( 'MainWANObjectCache using store {class}', [
|
|
|
|
|
'class' => get_class( $store )
|
|
|
|
|
] );
|
|
|
|
|
|
2020-03-30 21:28:53 +00:00
|
|
|
$wanParams['cache'] = $store;
|
|
|
|
|
$wanParams['logger'] = $logger;
|
|
|
|
|
$wanParams['secret'] = $wanParams['secret'] ?? $mainConfig->get( 'SecretKey' );
|
2019-10-08 21:34:17 +00:00
|
|
|
if ( !$mainConfig->get( 'CommandLineMode' ) ) {
|
|
|
|
|
// Send the statsd data post-send on HTTP requests; avoid in CLI mode (T181385)
|
2020-03-30 21:28:53 +00:00
|
|
|
$wanParams['stats'] = $services->getStatsdDataFactory();
|
2019-10-08 21:34:17 +00:00
|
|
|
// Let pre-emptive refreshes happen post-send on HTTP requests
|
2020-03-30 21:28:53 +00:00
|
|
|
$wanParams['asyncHandler'] = [ DeferredUpdates::class, 'addCallableUpdate' ];
|
2019-10-08 21:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-30 21:28:53 +00:00
|
|
|
$instance = new $wanClass( $wanParams );
|
2018-08-03 08:05:44 +00:00
|
|
|
|
2019-10-08 21:34:17 +00:00
|
|
|
'@phan-var WANObjectCache $instance';
|
|
|
|
|
return $instance;
|
2016-10-04 17:48:02 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'MediaHandlerFactory' => function ( MediaWikiServices $services ) : MediaHandlerFactory {
|
2016-07-29 00:01:08 +00:00
|
|
|
return new MediaHandlerFactory(
|
|
|
|
|
$services->getMainConfig()->get( 'MediaHandlers' )
|
|
|
|
|
);
|
2016-07-26 02:19:25 +00:00
|
|
|
},
|
|
|
|
|
|
2020-04-28 22:54:18 +00:00
|
|
|
'MergeHistoryFactory' => function ( MediaWikiServices $services ) : MergeHistoryFactory {
|
|
|
|
|
return $services->getService( '_PageCommandFactory' );
|
|
|
|
|
},
|
|
|
|
|
|
2019-04-08 15:21:49 +00:00
|
|
|
'MessageCache' => function ( MediaWikiServices $services ) : MessageCache {
|
|
|
|
|
$mainConfig = $services->getMainConfig();
|
2019-10-11 23:26:18 +00:00
|
|
|
$clusterCache = ObjectCache::getInstance( $mainConfig->get( 'MessageCacheType' ) );
|
|
|
|
|
$srvCache = $mainConfig->get( 'UseLocalMessageCache' )
|
|
|
|
|
? $services->getLocalServerObjectCache()
|
|
|
|
|
: new EmptyBagOStuff();
|
|
|
|
|
|
|
|
|
|
$logger = LoggerFactory::getInstance( 'MessageCache' );
|
|
|
|
|
$logger->debug( 'MessageCache using store {class}', [
|
|
|
|
|
'class' => get_class( $clusterCache )
|
|
|
|
|
] );
|
|
|
|
|
|
2019-04-08 15:21:49 +00:00
|
|
|
return new MessageCache(
|
|
|
|
|
$services->getMainWANObjectCache(),
|
2019-10-11 23:26:18 +00:00
|
|
|
$clusterCache,
|
|
|
|
|
$srvCache,
|
2019-10-11 23:37:37 +00:00
|
|
|
$services->getContentLanguage(),
|
2020-01-23 18:39:23 +00:00
|
|
|
$services->getLanguageConverterFactory()->getLanguageConverter(),
|
2019-10-11 23:37:37 +00:00
|
|
|
$logger,
|
2019-08-26 12:24:37 +00:00
|
|
|
[ 'useDB' => $mainConfig->get( 'UseDatabaseMessages' ) ],
|
2019-10-28 18:05:35 +00:00
|
|
|
$services->getLanguageFactory(),
|
2020-01-03 23:03:14 +00:00
|
|
|
$services->getLocalisationCache(),
|
|
|
|
|
$services->getLanguageNameUtils(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getLanguageFallback(),
|
|
|
|
|
$services->getHookContainer()
|
2019-04-08 15:21:49 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2020-01-19 14:48:00 +00:00
|
|
|
'MessageFormatterFactory' => function () : IMessageFormatterFactory {
|
2019-07-15 10:24:38 +00:00
|
|
|
return new MessageFormatterFactory();
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'MimeAnalyzer' => function ( MediaWikiServices $services ) : MimeAnalyzer {
|
2016-11-22 23:57:34 +00:00
|
|
|
$logger = LoggerFactory::getInstance( 'Mime' );
|
|
|
|
|
$mainConfig = $services->getMainConfig();
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$hookRunner = new HookRunner( $services->getHookContainer() );
|
2016-11-22 23:57:34 +00:00
|
|
|
$params = [
|
|
|
|
|
'typeFile' => $mainConfig->get( 'MimeTypeFile' ),
|
|
|
|
|
'infoFile' => $mainConfig->get( 'MimeInfoFile' ),
|
|
|
|
|
'xmlTypes' => $mainConfig->get( 'XMLMimeTypes' ),
|
|
|
|
|
'guessCallback' =>
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
function ( $mimeAnalyzer, &$head, &$tail, $file, &$mime )
|
|
|
|
|
use ( $logger, $hookRunner ) {
|
2016-11-22 23:57:34 +00:00
|
|
|
// Also test DjVu
|
|
|
|
|
$deja = new DjVuImage( $file );
|
|
|
|
|
if ( $deja->isValid() ) {
|
2018-09-30 15:25:59 +00:00
|
|
|
$logger->info( "Detected $file as image/vnd.djvu\n" );
|
2016-11-22 23:57:34 +00:00
|
|
|
$mime = 'image/vnd.djvu';
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Some strings by reference for performance - assuming well-behaved hooks
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$hookRunner->onMimeMagicGuessFromContent(
|
|
|
|
|
$mimeAnalyzer, $head, $tail, $file, $mime );
|
2016-11-22 23:57:34 +00:00
|
|
|
},
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
'extCallback' => function ( $mimeAnalyzer, $ext, &$mime ) use ( $hookRunner ) {
|
2016-11-22 23:57:34 +00:00
|
|
|
// Media handling extensions can improve the MIME detected
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$hookRunner->onMimeMagicImproveFromExtension( $mimeAnalyzer, $ext, $mime );
|
2016-11-22 23:57:34 +00:00
|
|
|
},
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
'initCallback' => function ( $mimeAnalyzer ) use ( $hookRunner ) {
|
2016-11-22 23:57:34 +00:00
|
|
|
// Allow media handling extensions adding MIME-types and MIME-info
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$hookRunner->onMimeMagicInit( $mimeAnalyzer );
|
2016-11-22 23:57:34 +00:00
|
|
|
},
|
|
|
|
|
'logger' => $logger
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if ( $params['infoFile'] === 'includes/mime.info' ) {
|
mime: Convert built-in MIME mappings to PHP arrays
Currently, MimeAnalyzer builds the internal mappings of MIME types <=> file
extensions by concatenating several string buffers in mime.type format into a
giant string, and then parsing it. The mapping of MIME types to internal
media types is built up in a similar way, except we use a dubious homegrown
format with undocumented conventions. It's a mess, and an expensive one --
~1.5% of api.php CPU time on the WMF cluster is spent building these buffers
and parsing them. Converting the mappings to PHP associative arrays makes
them much cheaper to load and easier to maintain.
Doing this without breaking compatibility with existing behaviors requires
some delicate footwork. The current mime.types buffer is made up of the
following fragments, in order:
1) MimeAnalyzer::$wellKnownTypes
2) If $wgMimeTypeFile == 'includes/mime.types' (sic!):
the contents of includes/libs/mime/mime.types.
If $wgMimeTypeFile is another file path (e.g., '/etc/mime.types'):
the contents of that file.
If !wg$MimeTypeFile, this fragment is blank.
3) MimeAnalyzer::$extraTypes (populated by extensions via hook).
The mime.info buffer is built up in the exact same way, except it's
MimeAnalyzer::$wellKnownInfo, $wgMimeInfoFile, and MimeAnalyzer::$extraInfo.
What this means in effect is that some built-in MediaWiki MIME mappings are
"baked in" (anything in MimeAnalyzer::$wellKnown*), and others can be
overridden (anything in includes/libs/mime/mime.*).
To avoid breaking backward compatibility, we have to preserve the
distinction. Thus this change has two MIME mappings, encapsulated in two
classes: 'MimeMapMinimal', which contains just the baked-in mappings, and
'MimeMap' which contains both the baked-in and overridable mappings. We also
have to keep the code for parsing mime.types and the ad-hoc mime.info format,
at least for now.
In a FUTURE change (i.e., not here), I think we can:
* Deprecate $wgMimeTypeFile in favor of a new config var,
$wgExtraMimeTypeFile. $wgMimeTypeFile is evil because if you are using to
add support for additional MIME types, you can end up unwittingly dropping
support for other types that exist in MediaWiki's mime.types but not your
file. The new $wgExtraMimeTypeFile would only be used to add new MIME
mappings on top of the standard MimeMappings, which was probably the
original intent for $wgMimeTypeFile.
* Deprecate $wgMimeInfoFile. I don't think we need to provide a replacement,
because extensions can use the hook, and I doubt anyone is using the config
var. But if we wanted to provide an alternative, we could have a
$wgExtraMimeInfoMap that has an array of extra mappings.
* Deprecate MimeAnalyzer::addExtraTypes and MimeAnalyzer::addExtraInfo, and
provide alternative interfaces that take structured input instead of string
blobs.
I tested this by dumping the internal state of MimeAnalyzer before and after
this CL using the script in Ib856a69fe, using both default and custom values
for $wgMimeInfo(File|Type).
Bug: T252228
Change-Id: I9b2979d3c9c0dee96bb19e0290f680724e718891
2020-05-12 19:42:35 +00:00
|
|
|
$params['infoFile'] = MimeAnalyzer::USE_INTERNAL;
|
2016-11-22 23:57:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $params['typeFile'] === 'includes/mime.types' ) {
|
mime: Convert built-in MIME mappings to PHP arrays
Currently, MimeAnalyzer builds the internal mappings of MIME types <=> file
extensions by concatenating several string buffers in mime.type format into a
giant string, and then parsing it. The mapping of MIME types to internal
media types is built up in a similar way, except we use a dubious homegrown
format with undocumented conventions. It's a mess, and an expensive one --
~1.5% of api.php CPU time on the WMF cluster is spent building these buffers
and parsing them. Converting the mappings to PHP associative arrays makes
them much cheaper to load and easier to maintain.
Doing this without breaking compatibility with existing behaviors requires
some delicate footwork. The current mime.types buffer is made up of the
following fragments, in order:
1) MimeAnalyzer::$wellKnownTypes
2) If $wgMimeTypeFile == 'includes/mime.types' (sic!):
the contents of includes/libs/mime/mime.types.
If $wgMimeTypeFile is another file path (e.g., '/etc/mime.types'):
the contents of that file.
If !wg$MimeTypeFile, this fragment is blank.
3) MimeAnalyzer::$extraTypes (populated by extensions via hook).
The mime.info buffer is built up in the exact same way, except it's
MimeAnalyzer::$wellKnownInfo, $wgMimeInfoFile, and MimeAnalyzer::$extraInfo.
What this means in effect is that some built-in MediaWiki MIME mappings are
"baked in" (anything in MimeAnalyzer::$wellKnown*), and others can be
overridden (anything in includes/libs/mime/mime.*).
To avoid breaking backward compatibility, we have to preserve the
distinction. Thus this change has two MIME mappings, encapsulated in two
classes: 'MimeMapMinimal', which contains just the baked-in mappings, and
'MimeMap' which contains both the baked-in and overridable mappings. We also
have to keep the code for parsing mime.types and the ad-hoc mime.info format,
at least for now.
In a FUTURE change (i.e., not here), I think we can:
* Deprecate $wgMimeTypeFile in favor of a new config var,
$wgExtraMimeTypeFile. $wgMimeTypeFile is evil because if you are using to
add support for additional MIME types, you can end up unwittingly dropping
support for other types that exist in MediaWiki's mime.types but not your
file. The new $wgExtraMimeTypeFile would only be used to add new MIME
mappings on top of the standard MimeMappings, which was probably the
original intent for $wgMimeTypeFile.
* Deprecate $wgMimeInfoFile. I don't think we need to provide a replacement,
because extensions can use the hook, and I doubt anyone is using the config
var. But if we wanted to provide an alternative, we could have a
$wgExtraMimeInfoMap that has an array of extra mappings.
* Deprecate MimeAnalyzer::addExtraTypes and MimeAnalyzer::addExtraInfo, and
provide alternative interfaces that take structured input instead of string
blobs.
I tested this by dumping the internal state of MimeAnalyzer before and after
this CL using the script in Ib856a69fe, using both default and custom values
for $wgMimeInfo(File|Type).
Bug: T252228
Change-Id: I9b2979d3c9c0dee96bb19e0290f680724e718891
2020-05-12 19:42:35 +00:00
|
|
|
$params['typeFile'] = MimeAnalyzer::USE_INTERNAL;
|
2016-11-22 23:57:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$detectorCmd = $mainConfig->get( 'MimeDetectorCommand' );
|
|
|
|
|
if ( $detectorCmd ) {
|
2017-10-25 01:51:45 +00:00
|
|
|
$factory = $services->getShellCommandFactory();
|
|
|
|
|
$params['detectCallback'] = function ( $file ) use ( $detectorCmd, $factory ) {
|
|
|
|
|
$result = $factory->create()
|
|
|
|
|
// $wgMimeDetectorCommand can contain commands with parameters
|
|
|
|
|
->unsafeParams( $detectorCmd )
|
|
|
|
|
->params( $file )
|
|
|
|
|
->execute();
|
|
|
|
|
return $result->getStdout();
|
2016-11-22 23:57:34 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-21 01:40:59 +00:00
|
|
|
return new MimeAnalyzer( $params );
|
2016-09-22 04:57:13 +00:00
|
|
|
},
|
|
|
|
|
|
2019-05-01 11:39:45 +00:00
|
|
|
'MovePageFactory' => function ( MediaWikiServices $services ) : MovePageFactory {
|
2020-04-28 22:54:18 +00:00
|
|
|
return $services->getService( '_PageCommandFactory' );
|
2019-05-01 11:39:45 +00:00
|
|
|
},
|
|
|
|
|
|
2019-04-10 10:36:02 +00:00
|
|
|
'NamespaceInfo' => function ( MediaWikiServices $services ) : NamespaceInfo {
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
return new NamespaceInfo(
|
|
|
|
|
new ServiceOptions( NamespaceInfo::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
|
|
|
|
|
$services->getHookContainer()
|
|
|
|
|
);
|
2019-04-10 10:36:02 +00:00
|
|
|
},
|
|
|
|
|
|
2018-09-04 01:59:03 +00:00
|
|
|
'NameTableStoreFactory' => function ( MediaWikiServices $services ) : NameTableStoreFactory {
|
|
|
|
|
return new NameTableStoreFactory(
|
|
|
|
|
$services->getDBLoadBalancerFactory(),
|
|
|
|
|
$services->getMainWANObjectCache(),
|
|
|
|
|
LoggerFactory::getInstance( 'NameTableSqlStore' )
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-08-21 16:10:30 +00:00
|
|
|
'ObjectFactory' => function ( MediaWikiServices $services ) : ObjectFactory {
|
|
|
|
|
return new ObjectFactory( $services );
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'OldRevisionImporter' => function ( MediaWikiServices $services ) : OldRevisionImporter {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new ImportableOldRevisionImporter(
|
|
|
|
|
true,
|
|
|
|
|
LoggerFactory::getInstance( 'OldRevisionImporter' ),
|
|
|
|
|
$services->getDBLoadBalancer()
|
2016-09-22 02:52:06 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-04-13 04:38:55 +00:00
|
|
|
'PageEditStash' => function ( MediaWikiServices $services ) : PageEditStash {
|
|
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
|
|
|
|
|
return new PageEditStash(
|
|
|
|
|
ObjectCache::getLocalClusterInstance(),
|
|
|
|
|
$services->getDBLoadBalancer(),
|
|
|
|
|
LoggerFactory::getInstance( 'StashEdit' ),
|
|
|
|
|
$services->getStatsdDataFactory(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getHookContainer(),
|
2019-04-13 04:38:55 +00:00
|
|
|
defined( 'MEDIAWIKI_JOB_RUNNER' ) || $config->get( 'CommandLineMode' )
|
|
|
|
|
? PageEditStash::INITIATOR_JOB_OR_CLI
|
|
|
|
|
: PageEditStash::INITIATOR_USER
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'Parser' => function ( MediaWikiServices $services ) : Parser {
|
2018-08-03 08:43:00 +00:00
|
|
|
return $services->getParserFactory()->create();
|
2016-08-16 20:47:43 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'ParserCache' => function ( MediaWikiServices $services ) : ParserCache {
|
2017-05-30 00:10:16 +00:00
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
$cache = ObjectCache::getInstance( $config->get( 'ParserCacheType' ) );
|
|
|
|
|
wfDebugLog( 'caches', 'parser: ' . get_class( $cache ) );
|
|
|
|
|
|
|
|
|
|
return new ParserCache(
|
|
|
|
|
$cache,
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$config->get( 'CacheEpoch' ),
|
|
|
|
|
$services->getHookContainer()
|
2017-05-30 00:10:16 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-03 08:25:15 +00:00
|
|
|
'ParserFactory' => function ( MediaWikiServices $services ) : ParserFactory {
|
2019-10-08 18:30:42 +00:00
|
|
|
$options = new ServiceOptions( Parser::CONSTRUCTOR_OPTIONS,
|
2020-01-24 22:39:51 +00:00
|
|
|
// 'class'
|
2020-04-16 18:14:42 +00:00
|
|
|
// Note that this value is ignored by ParserFactory and is always
|
|
|
|
|
// Parser::class for legacy reasons; we'll introduce a new
|
|
|
|
|
// mechanism for selecting an alternate parser in the future
|
|
|
|
|
// (T236809)
|
2018-08-03 08:25:15 +00:00
|
|
|
$services->getMainConfig()->get( 'ParserConf' ),
|
2019-04-12 09:50:30 +00:00
|
|
|
// Make sure to have defaults in case someone overrode ParserConf with something silly
|
2020-01-24 22:39:51 +00:00
|
|
|
[ 'class' => Parser::class ],
|
2019-04-12 09:50:30 +00:00
|
|
|
// Plus a buch of actual config options
|
|
|
|
|
$services->getMainConfig()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return new ParserFactory(
|
|
|
|
|
$options,
|
2018-08-03 08:25:15 +00:00
|
|
|
$services->getMagicWordFactory(),
|
|
|
|
|
$services->getContentLanguage(),
|
2018-08-15 01:11:59 +00:00
|
|
|
wfUrlProtocols(),
|
2018-08-08 14:49:46 +00:00
|
|
|
$services->getSpecialPageFactory(),
|
2018-08-05 12:50:01 +00:00
|
|
|
$services->getLinkRendererFactory(),
|
2019-06-27 03:35:50 +00:00
|
|
|
$services->getNamespaceInfo(),
|
2020-02-04 12:42:03 +00:00
|
|
|
LoggerFactory::getInstance( 'Parser' ),
|
|
|
|
|
$services->getBadFileLookup(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getLanguageConverterFactory(),
|
|
|
|
|
$services->getHookContainer()
|
2018-08-03 08:25:15 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'PasswordFactory' => function ( MediaWikiServices $services ) : PasswordFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
return new PasswordFactory(
|
|
|
|
|
$config->get( 'PasswordConfig' ),
|
|
|
|
|
$config->get( 'PasswordDefault' )
|
2017-07-04 21:46:46 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-09-10 02:49:12 +00:00
|
|
|
'PasswordReset' => function ( MediaWikiServices $services ) : PasswordReset {
|
2019-10-08 18:26:17 +00:00
|
|
|
$options = new ServiceOptions( PasswordReset::CONSTRUCTOR_OPTIONS, $services->getMainConfig() );
|
2019-09-10 02:49:12 +00:00
|
|
|
return new PasswordReset(
|
|
|
|
|
$options,
|
|
|
|
|
AuthManager::singleton(),
|
|
|
|
|
$services->getPermissionManager(),
|
|
|
|
|
$services->getDBLoadBalancer(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
LoggerFactory::getInstance( 'authentication' ),
|
|
|
|
|
$services->getHookContainer()
|
2019-09-10 02:49:12 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'PerDbNameStatsdDataFactory' =>
|
2018-08-18 10:22:38 +00:00
|
|
|
function ( MediaWikiServices $services ) : StatsdDataFactoryInterface {
|
2018-08-03 08:05:44 +00:00
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
$wiki = $config->get( 'DBname' );
|
2018-08-18 10:22:38 +00:00
|
|
|
return new PrefixingStatsdDataFactoryProxy(
|
|
|
|
|
$services->getStatsdDataFactory(),
|
|
|
|
|
$wiki
|
2017-07-04 21:46:46 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-03-07 20:02:07 +00:00
|
|
|
'PermissionManager' => function ( MediaWikiServices $services ) : PermissionManager {
|
|
|
|
|
return new PermissionManager(
|
2019-08-21 05:28:47 +00:00
|
|
|
new ServiceOptions(
|
2019-10-08 18:23:08 +00:00
|
|
|
PermissionManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
|
2019-08-21 05:28:47 +00:00
|
|
|
),
|
2019-03-07 20:02:07 +00:00
|
|
|
$services->getSpecialPageFactory(),
|
2018-11-01 23:29:22 +00:00
|
|
|
$services->getRevisionLookup(),
|
2019-09-20 15:03:48 +00:00
|
|
|
$services->getNamespaceInfo(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getBlockErrorFormatter(),
|
|
|
|
|
$services->getHookContainer()
|
2019-04-09 09:28:38 +00:00
|
|
|
);
|
2019-03-07 20:02:07 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'PreferencesFactory' => function ( MediaWikiServices $services ) : PreferencesFactory {
|
2018-07-26 20:23:07 +00:00
|
|
|
$factory = new DefaultPreferencesFactory(
|
2019-04-10 15:03:54 +00:00
|
|
|
new ServiceOptions(
|
2019-10-08 18:28:15 +00:00
|
|
|
DefaultPreferencesFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
|
2018-07-26 20:23:07 +00:00
|
|
|
$services->getContentLanguage(),
|
|
|
|
|
AuthManager::singleton(),
|
2018-08-05 12:56:23 +00:00
|
|
|
$services->getLinkRendererFactory()->create(),
|
2019-08-22 22:53:05 +00:00
|
|
|
$services->getNamespaceInfo(),
|
2020-02-04 12:42:03 +00:00
|
|
|
$services->getPermissionManager(),
|
2020-01-03 23:03:14 +00:00
|
|
|
$services->getLanguageConverterFactory()->getLanguageConverter(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getLanguageNameUtils(),
|
|
|
|
|
$services->getHookContainer()
|
2018-07-26 20:23:07 +00:00
|
|
|
);
|
2018-08-03 08:05:44 +00:00
|
|
|
$factory->setLogger( LoggerFactory::getInstance( 'preferences' ) );
|
2017-10-07 02:26:52 +00:00
|
|
|
|
|
|
|
|
return $factory;
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'ProxyLookup' => function ( MediaWikiServices $services ) : ProxyLookup {
|
2018-08-03 08:05:44 +00:00
|
|
|
$mainConfig = $services->getMainConfig();
|
|
|
|
|
return new ProxyLookup(
|
2017-11-01 20:55:24 +00:00
|
|
|
$mainConfig->get( 'CdnServers' ),
|
|
|
|
|
$mainConfig->get( 'CdnServersNoPurge' )
|
2018-08-03 08:05:44 +00:00
|
|
|
);
|
|
|
|
|
},
|
2017-11-14 11:17:34 +00:00
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'ReadOnlyMode' => function ( MediaWikiServices $services ) : ReadOnlyMode {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new ReadOnlyMode(
|
|
|
|
|
$services->getConfiguredReadOnlyMode(),
|
|
|
|
|
$services->getDBLoadBalancer()
|
2017-11-14 11:17:34 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-05-01 12:54:54 +00:00
|
|
|
'RepoGroup' => function ( MediaWikiServices $services ) : RepoGroup {
|
|
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
return new RepoGroup(
|
|
|
|
|
$config->get( 'LocalFileRepo' ),
|
|
|
|
|
$config->get( 'ForeignFileRepos' ),
|
|
|
|
|
$services->getMainWANObjectCache()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-02-16 23:16:09 +00:00
|
|
|
'ResourceLoader' => function ( MediaWikiServices $services ) : ResourceLoader {
|
2019-04-10 15:03:54 +00:00
|
|
|
// @todo This should not take a Config object, but it's not so easy to remove because it
|
|
|
|
|
// exposes it in a getter, which is actually used.
|
2019-04-06 20:41:36 +00:00
|
|
|
global $IP;
|
2019-03-29 01:21:18 +00:00
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
|
|
|
|
|
$rl = new ResourceLoader(
|
|
|
|
|
$config,
|
2019-06-29 04:50:31 +00:00
|
|
|
LoggerFactory::getInstance( 'resourceloader' ),
|
|
|
|
|
$config->get( 'ResourceLoaderUseObjectCacheForDeps' )
|
|
|
|
|
? new KeyValueDependencyStore( $services->getMainObjectStash() )
|
|
|
|
|
: new SqlModuleDependencyStore( $services->getDBLoadBalancer() )
|
2019-02-16 23:16:09 +00:00
|
|
|
);
|
2019-04-17 14:17:15 +00:00
|
|
|
|
2020-03-09 20:12:45 +00:00
|
|
|
$extRegistry = ExtensionRegistry::getInstance();
|
|
|
|
|
// Attribute has precedence over config
|
2020-03-09 20:12:45 +00:00
|
|
|
$modules = $extRegistry->getAttribute( 'ResourceModules' )
|
|
|
|
|
+ $config->get( 'ResourceModules' );
|
2020-03-09 20:12:45 +00:00
|
|
|
$moduleSkinStyles = $extRegistry->getAttribute( 'ResourceModuleSkinStyles' )
|
|
|
|
|
+ $config->get( 'ResourceModuleSkinStyles' );
|
|
|
|
|
|
|
|
|
|
$rl->setModuleSkinStyles( $moduleSkinStyles );
|
2019-03-29 01:21:18 +00:00
|
|
|
$rl->addSource( $config->get( 'ResourceLoaderSources' ) );
|
2019-04-17 14:17:15 +00:00
|
|
|
|
|
|
|
|
// Core modules, then extension/skin modules
|
2019-04-06 20:41:36 +00:00
|
|
|
$rl->register( include "$IP/resources/Resources.php" );
|
2020-03-09 20:12:45 +00:00
|
|
|
$rl->register( $modules );
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$hookRunner = new HookRunner( $services->getHookContainer() );
|
|
|
|
|
$hookRunner->onResourceLoaderRegisterModules( $rl );
|
2019-04-17 14:17:15 +00:00
|
|
|
|
2019-10-12 03:17:51 +00:00
|
|
|
$msgPosterAttrib = $extRegistry->getAttribute( 'MessagePosterModule' );
|
|
|
|
|
$rl->register( 'mediawiki.messagePoster', [
|
|
|
|
|
'localBasePath' => '',
|
|
|
|
|
'debugRaw' => false,
|
|
|
|
|
'scripts' => array_merge(
|
|
|
|
|
[
|
|
|
|
|
"$IP/resources/src/mediawiki.messagePoster/factory.js",
|
|
|
|
|
"$IP/resources/src/mediawiki.messagePoster/MessagePoster.js",
|
|
|
|
|
"$IP/resources/src/mediawiki.messagePoster/WikitextMessagePoster.js",
|
|
|
|
|
],
|
|
|
|
|
$msgPosterAttrib['scripts'] ?? []
|
|
|
|
|
),
|
|
|
|
|
'dependencies' => array_merge(
|
|
|
|
|
[
|
|
|
|
|
'oojs',
|
|
|
|
|
'mediawiki.api',
|
|
|
|
|
'mediawiki.ForeignApi',
|
|
|
|
|
],
|
|
|
|
|
$msgPosterAttrib['dependencies'] ?? []
|
|
|
|
|
),
|
|
|
|
|
'targets' => [ 'desktop', 'mobile' ],
|
|
|
|
|
] );
|
|
|
|
|
|
2019-04-17 14:17:15 +00:00
|
|
|
if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
|
|
|
|
|
$rl->registerTestModules();
|
|
|
|
|
}
|
2019-03-29 01:21:18 +00:00
|
|
|
|
|
|
|
|
return $rl;
|
2019-02-16 23:16:09 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'RevisionFactory' => function ( MediaWikiServices $services ) : RevisionFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
return $services->getRevisionStore();
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'RevisionLookup' => function ( MediaWikiServices $services ) : RevisionLookup {
|
2018-08-03 08:05:44 +00:00
|
|
|
return $services->getRevisionStore();
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:52:40 +00:00
|
|
|
'RevisionRenderer' => function ( MediaWikiServices $services ) : RevisionRenderer {
|
2018-11-19 11:39:56 +00:00
|
|
|
$renderer = new RevisionRenderer(
|
|
|
|
|
$services->getDBLoadBalancer(),
|
|
|
|
|
$services->getSlotRoleRegistry()
|
|
|
|
|
);
|
2018-10-29 22:48:22 +00:00
|
|
|
|
2018-11-19 11:39:56 +00:00
|
|
|
$renderer->setLogger( LoggerFactory::getInstance( 'SaveParse' ) );
|
2018-10-29 22:48:22 +00:00
|
|
|
return $renderer;
|
2018-08-07 16:52:40 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'RevisionStore' => function ( MediaWikiServices $services ) : RevisionStore {
|
2018-06-27 12:16:35 +00:00
|
|
|
return $services->getRevisionStoreFactory()->getRevisionStore();
|
|
|
|
|
},
|
2017-11-15 12:02:40 +00:00
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'RevisionStoreFactory' => function ( MediaWikiServices $services ) : RevisionStoreFactory {
|
2018-06-27 12:16:35 +00:00
|
|
|
$config = $services->getMainConfig();
|
2019-12-17 16:20:32 +00:00
|
|
|
|
|
|
|
|
if ( $config->has( 'MultiContentRevisionSchemaMigrationStage' ) ) {
|
|
|
|
|
if ( $config->get( 'MultiContentRevisionSchemaMigrationStage' ) !== SCHEMA_COMPAT_NEW ) {
|
|
|
|
|
throw new UnexpectedValueException(
|
|
|
|
|
'The MultiContentRevisionSchemaMigrationStage setting is no longer supported!'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-27 12:16:35 +00:00
|
|
|
$store = new RevisionStoreFactory(
|
|
|
|
|
$services->getDBLoadBalancerFactory(),
|
|
|
|
|
$services->getBlobStoreFactory(),
|
2018-09-04 01:59:03 +00:00
|
|
|
$services->getNameTableStoreFactory(),
|
2018-11-19 11:39:56 +00:00
|
|
|
$services->getSlotRoleRegistry(),
|
2018-01-29 14:25:49 +00:00
|
|
|
$services->getMainWANObjectCache(),
|
2017-09-12 17:12:29 +00:00
|
|
|
$services->getCommentStore(),
|
2018-06-27 12:16:35 +00:00
|
|
|
$services->getActorMigration(),
|
2019-09-10 02:24:18 +00:00
|
|
|
LoggerFactory::getInstance( 'RevisionStore' ),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getContentHandlerFactory(),
|
|
|
|
|
$services->getHookContainer()
|
2017-11-15 12:02:40 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return $store;
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'SearchEngineConfig' => function ( MediaWikiServices $services ) : SearchEngineConfig {
|
2019-04-10 15:03:54 +00:00
|
|
|
// @todo This should not take a Config object, but it's not so easy to remove because it
|
|
|
|
|
// exposes it in a getter, which is actually used.
|
2020-04-27 12:44:55 +00:00
|
|
|
return new SearchEngineConfig(
|
|
|
|
|
$services->getMainConfig(),
|
|
|
|
|
$services->getContentLanguage(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getHookContainer(),
|
2020-04-27 12:44:55 +00:00
|
|
|
ExtensionRegistry::getInstance()->getAttribute( 'SearchMappings' )
|
|
|
|
|
);
|
2018-01-09 08:53:38 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'SearchEngineFactory' => function ( MediaWikiServices $services ) : SearchEngineFactory {
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
return new SearchEngineFactory(
|
|
|
|
|
$services->getSearchEngineConfig(),
|
|
|
|
|
$services->getHookContainer()
|
|
|
|
|
);
|
2018-01-09 08:53:38 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'ShellCommandFactory' => function ( MediaWikiServices $services ) : CommandFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
$config = $services->getMainConfig();
|
|
|
|
|
|
|
|
|
|
$limits = [
|
|
|
|
|
'time' => $config->get( 'MaxShellTime' ),
|
|
|
|
|
'walltime' => $config->get( 'MaxShellWallClockTime' ),
|
|
|
|
|
'memory' => $config->get( 'MaxShellMemory' ),
|
|
|
|
|
'filesize' => $config->get( 'MaxShellFileSize' ),
|
|
|
|
|
];
|
|
|
|
|
$cgroup = $config->get( 'ShellCgroup' );
|
|
|
|
|
$restrictionMethod = $config->get( 'ShellRestrictionMethod' );
|
|
|
|
|
|
|
|
|
|
$factory = new CommandFactory( $limits, $cgroup, $restrictionMethod );
|
|
|
|
|
$factory->setLogger( LoggerFactory::getInstance( 'exec' ) );
|
|
|
|
|
$factory->logStderr();
|
|
|
|
|
|
|
|
|
|
return $factory;
|
2017-12-23 17:14:28 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'SiteLookup' => function ( MediaWikiServices $services ) : SiteLookup {
|
2019-03-14 19:46:19 +00:00
|
|
|
// Use SiteStore as the SiteLookup as well. This was originally separated
|
2020-01-02 23:50:53 +00:00
|
|
|
// to allow for a cacheable read-only interface, but this was never used.
|
|
|
|
|
// SiteStore has caching (see below).
|
2019-03-14 19:46:19 +00:00
|
|
|
return $services->getSiteStore();
|
2017-11-15 12:02:40 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'SiteStore' => function ( MediaWikiServices $services ) : SiteStore {
|
2018-08-03 08:05:44 +00:00
|
|
|
$rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() );
|
|
|
|
|
|
2019-07-20 21:09:31 +00:00
|
|
|
$cache = $services->getLocalServerObjectCache();
|
|
|
|
|
if ( $cache instanceof EmptyBagOStuff ) {
|
|
|
|
|
$cache = ObjectCache::getLocalClusterInstance();
|
|
|
|
|
}
|
2018-08-03 08:05:44 +00:00
|
|
|
|
|
|
|
|
return new CachingSiteStore( $rawSiteStore, $cache );
|
2017-11-15 12:02:40 +00:00
|
|
|
},
|
|
|
|
|
|
2020-02-06 09:44:05 +00:00
|
|
|
/** @suppress PhanTypeInvalidCallableArraySize - https://github.com/phan/phan/issues/1648 */
|
2018-08-07 16:33:20 +00:00
|
|
|
'SkinFactory' => function ( MediaWikiServices $services ) : SkinFactory {
|
2020-02-06 09:44:05 +00:00
|
|
|
$factory = new SkinFactory( $services->getObjectFactory() );
|
2018-08-03 08:05:44 +00:00
|
|
|
|
|
|
|
|
$names = $services->getMainConfig()->get( 'ValidSkinNames' );
|
|
|
|
|
|
|
|
|
|
foreach ( $names as $name => $skin ) {
|
2020-05-14 11:20:24 +00:00
|
|
|
if ( is_array( $skin ) ) {
|
|
|
|
|
$spec = $skin;
|
|
|
|
|
$displayName = $skin['displayname'] ?? $name;
|
|
|
|
|
} else {
|
|
|
|
|
$displayName = $skin;
|
|
|
|
|
$spec = [
|
|
|
|
|
'class' => "Skin$skin"
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$factory->register( $name, $displayName, $spec );
|
2018-08-03 08:05:44 +00:00
|
|
|
}
|
2020-05-14 11:20:24 +00:00
|
|
|
|
2018-08-03 08:05:44 +00:00
|
|
|
// Register a hidden "fallback" skin
|
2020-02-06 09:44:05 +00:00
|
|
|
$factory->register( 'fallback', 'Fallback', [
|
|
|
|
|
'class' => SkinFallback::class
|
|
|
|
|
] );
|
2018-08-03 08:05:44 +00:00
|
|
|
// Register a hidden skin for api output
|
2020-02-06 09:44:05 +00:00
|
|
|
$factory->register( 'apioutput', 'ApiOutput', [
|
|
|
|
|
'class' => SkinApi::class
|
|
|
|
|
] );
|
2018-08-03 08:05:44 +00:00
|
|
|
|
|
|
|
|
return $factory;
|
2018-01-16 13:53:22 +00:00
|
|
|
},
|
|
|
|
|
|
2018-11-19 11:39:56 +00:00
|
|
|
'SlotRoleRegistry' => function ( MediaWikiServices $services ) : SlotRoleRegistry {
|
|
|
|
|
$config = $services->getMainConfig();
|
2020-01-18 20:25:04 +00:00
|
|
|
$contentHandlerFactory = $services->getContentHandlerFactory();
|
2018-11-19 11:39:56 +00:00
|
|
|
|
|
|
|
|
$registry = new SlotRoleRegistry(
|
2020-05-27 20:41:19 +00:00
|
|
|
$services->getSlotRoleStore()
|
2018-11-19 11:39:56 +00:00
|
|
|
);
|
|
|
|
|
|
2020-01-18 20:25:04 +00:00
|
|
|
$registry->defineRole( 'main', function () use ( $config, $contentHandlerFactory ) {
|
2018-11-19 11:39:56 +00:00
|
|
|
return new MainSlotRoleHandler(
|
2020-01-18 20:25:04 +00:00
|
|
|
$config->get( 'NamespaceContentModels' ),
|
|
|
|
|
$contentHandlerFactory
|
2018-11-19 11:39:56 +00:00
|
|
|
);
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
return $registry;
|
|
|
|
|
},
|
|
|
|
|
|
2020-05-27 14:45:29 +00:00
|
|
|
'SlotRoleStore' => function ( MediaWikiServices $services ) : NameTableStore {
|
|
|
|
|
return $services->getNameTableStoreFactory()->getSlotRoles();
|
|
|
|
|
},
|
|
|
|
|
|
2020-04-25 04:21:55 +00:00
|
|
|
'SpamChecker' => function ( MediaWikiServices $services ) : SpamChecker {
|
|
|
|
|
return new SpamChecker(
|
|
|
|
|
(array)$services->getMainConfig()->get( 'SpamRegex' ),
|
|
|
|
|
(array)$services->getMainConfig()->get( 'SummarySpamRegex' )
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 10:58:31 +00:00
|
|
|
'SpecialPageFactory' => function ( MediaWikiServices $services ) : SpecialPageFactory {
|
|
|
|
|
return new SpecialPageFactory(
|
2019-04-10 15:03:54 +00:00
|
|
|
new ServiceOptions(
|
2019-10-08 18:30:32 +00:00
|
|
|
SpecialPageFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
|
2019-09-06 09:21:29 +00:00
|
|
|
$services->getContentLanguage(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getObjectFactory(),
|
|
|
|
|
$services->getHookContainer()
|
2018-08-07 10:58:31 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'StatsdDataFactory' => function ( MediaWikiServices $services ) : IBufferingStatsdDataFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new BufferingStatsdDataFactory(
|
|
|
|
|
rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' )
|
2018-06-21 06:59:02 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2020-04-04 03:39:01 +00:00
|
|
|
'TalkPageNotificationManager' => function (
|
|
|
|
|
MediaWikiServices $services
|
|
|
|
|
) : TalkPageNotificationManager {
|
|
|
|
|
return new TalkPageNotificationManager(
|
|
|
|
|
new ServiceOptions(
|
|
|
|
|
TalkPageNotificationManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
|
|
|
|
|
),
|
|
|
|
|
$services->getDBLoadBalancer(),
|
|
|
|
|
$services->getReadOnlyMode(),
|
|
|
|
|
$services->getRevisionLookup()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-08-16 10:00:15 +00:00
|
|
|
'TempFSFileFactory' => function ( MediaWikiServices $services ) : TempFSFileFactory {
|
|
|
|
|
return new TempFSFileFactory( $services->getMainConfig()->get( 'TmpDirectory' ) );
|
|
|
|
|
},
|
|
|
|
|
|
2020-01-19 14:48:00 +00:00
|
|
|
'TitleFactory' => function () : TitleFactory {
|
2019-10-17 16:48:39 +00:00
|
|
|
return new TitleFactory();
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'TitleFormatter' => function ( MediaWikiServices $services ) : TitleFormatter {
|
2018-08-03 08:05:44 +00:00
|
|
|
return $services->getService( '_MediaWikiTitleCodec' );
|
2017-11-07 03:10:14 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'TitleParser' => function ( MediaWikiServices $services ) : TitleParser {
|
2018-08-03 08:05:44 +00:00
|
|
|
return $services->getService( '_MediaWikiTitleCodec' );
|
2018-01-16 23:11:08 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'UploadRevisionImporter' => function ( MediaWikiServices $services ) : UploadRevisionImporter {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new ImportableUploadRevisionImporter(
|
|
|
|
|
$services->getMainConfig()->get( 'EnableUploads' ),
|
|
|
|
|
LoggerFactory::getInstance( 'UploadRevisionImporter' )
|
2018-01-24 23:41:01 +00:00
|
|
|
);
|
2017-09-12 17:12:29 +00:00
|
|
|
},
|
|
|
|
|
|
2020-05-26 03:33:28 +00:00
|
|
|
'UserEditTracker' => function ( MediaWikiServices $services ) : UserEditTracker {
|
|
|
|
|
return new UserEditTracker(
|
|
|
|
|
$services->getActorMigration(),
|
|
|
|
|
$services->getDBLoadBalancer()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-10-24 03:14:31 +00:00
|
|
|
'UserGroupManager' => function ( MediaWikiServices $services ) : UserGroupManager {
|
|
|
|
|
return $services->getUserGroupManagerFactory()->getUserGroupManager();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'UserGroupManagerFactory' => function ( MediaWikiServices $services ) : UserGroupManagerFactory {
|
|
|
|
|
return new UserGroupManagerFactory(
|
|
|
|
|
new ServiceOptions(
|
|
|
|
|
UserGroupManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
|
|
|
|
|
),
|
|
|
|
|
$services->getConfiguredReadOnlyMode(),
|
|
|
|
|
$services->getDBLoadBalancerFactory(),
|
|
|
|
|
$services->getHookContainer(),
|
|
|
|
|
[ function ( UserIdentity $user ) use ( $services ) {
|
|
|
|
|
$services->getPermissionManager()->invalidateUsersRightsCache( $user );
|
|
|
|
|
User::newFromIdentity( $user )->invalidateCache();
|
|
|
|
|
} ]
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
Add a new UserNameUtils service
This replaces User::isValidUserName, ::isUsableName, ::isCreatableName,
::getCanonicalName, and ::isIP.
Unlike User::isIP, UserNameUtils::isIP will //not// return true
for IPv6 ranges.
UserNameUtils::isIPRange, like User::isIPRange, accepts a name and
simply calls IPUtils::isValidRange.
User::isValidUserName, ::isUsableName, ::isCreatableName,
::getCanonical, ::isIP, and ::isValidRange are all soft deprecated
A follow up patch will add this to the release notes, to avoid merge
conflicts.
Bug: T245231
Bug: T239527
Change-Id: I46684bc492bb74b728ff102971f6cdd4d746a50a
2020-02-23 23:52:44 +00:00
|
|
|
'UserNameUtils' => function ( MediaWikiServices $services ) : UserNameUtils {
|
2020-03-31 23:29:51 +00:00
|
|
|
$messageFormatterFactory = new MessageFormatterFactory( Message::FORMAT_PLAIN );
|
Add a new UserNameUtils service
This replaces User::isValidUserName, ::isUsableName, ::isCreatableName,
::getCanonicalName, and ::isIP.
Unlike User::isIP, UserNameUtils::isIP will //not// return true
for IPv6 ranges.
UserNameUtils::isIPRange, like User::isIPRange, accepts a name and
simply calls IPUtils::isValidRange.
User::isValidUserName, ::isUsableName, ::isCreatableName,
::getCanonical, ::isIP, and ::isValidRange are all soft deprecated
A follow up patch will add this to the release notes, to avoid merge
conflicts.
Bug: T245231
Bug: T239527
Change-Id: I46684bc492bb74b728ff102971f6cdd4d746a50a
2020-02-23 23:52:44 +00:00
|
|
|
return new UserNameUtils(
|
|
|
|
|
new ServiceOptions(
|
|
|
|
|
UserNameUtils::CONSTRUCTOR_OPTIONS, $services->getMainConfig()
|
|
|
|
|
),
|
|
|
|
|
$services->getContentLanguage(),
|
|
|
|
|
LoggerFactory::getInstance( 'UserNameUtils' ),
|
|
|
|
|
$services->getService( 'TitleFactory' ),
|
2020-03-31 23:29:51 +00:00
|
|
|
$messageFormatterFactory->getTextFormatter(
|
|
|
|
|
$services->getContentLanguage()->getCode()
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
),
|
|
|
|
|
$services->getHookContainer()
|
Add a new UserNameUtils service
This replaces User::isValidUserName, ::isUsableName, ::isCreatableName,
::getCanonicalName, and ::isIP.
Unlike User::isIP, UserNameUtils::isIP will //not// return true
for IPv6 ranges.
UserNameUtils::isIPRange, like User::isIPRange, accepts a name and
simply calls IPUtils::isValidRange.
User::isValidUserName, ::isUsableName, ::isCreatableName,
::getCanonical, ::isIP, and ::isValidRange are all soft deprecated
A follow up patch will add this to the release notes, to avoid merge
conflicts.
Bug: T245231
Bug: T239527
Change-Id: I46684bc492bb74b728ff102971f6cdd4d746a50a
2020-02-23 23:52:44 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2020-01-17 06:21:28 +00:00
|
|
|
'UserOptionsLookup' => function ( MediaWikiServices $services ) : UserOptionsLookup {
|
|
|
|
|
return $services->getUserOptionsManager();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
'UserOptionsManager' => function ( MediaWikiServices $services ) : UserOptionsManager {
|
|
|
|
|
return new UserOptionsManager(
|
|
|
|
|
new ServiceOptions( UserOptionsManager::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
|
2020-05-11 19:19:13 +00:00
|
|
|
$services->get( '_DefaultOptionsLookup' ),
|
2020-01-17 06:21:28 +00:00
|
|
|
$services->getLanguageConverterFactory(),
|
|
|
|
|
$services->getDBLoadBalancer(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
LoggerFactory::getInstance( 'UserOptionsManager' ),
|
|
|
|
|
$services->getHookContainer()
|
2020-01-17 06:21:28 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'VirtualRESTServiceClient' =>
|
|
|
|
|
function ( MediaWikiServices $services ) : VirtualRESTServiceClient {
|
2018-08-03 08:05:44 +00:00
|
|
|
$config = $services->getMainConfig()->get( 'VirtualRestConfig' );
|
|
|
|
|
|
2020-05-21 03:57:15 +00:00
|
|
|
$vrsClient = new VirtualRESTServiceClient(
|
|
|
|
|
$services->getHttpRequestFactory()->createMultiClient() );
|
2018-08-03 08:05:44 +00:00
|
|
|
foreach ( $config['paths'] as $prefix => $serviceConfig ) {
|
|
|
|
|
$class = $serviceConfig['class'];
|
|
|
|
|
// Merge in the global defaults
|
|
|
|
|
$constructArg = $serviceConfig['options'] ?? [];
|
|
|
|
|
$constructArg += $config['global'];
|
|
|
|
|
// Make the VRS service available at the mount point
|
|
|
|
|
$vrsClient->mount( $prefix, [ 'class' => $class, 'config' => $constructArg ] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $vrsClient;
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'WatchedItemQueryService' =>
|
|
|
|
|
function ( MediaWikiServices $services ) : WatchedItemQueryService {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new WatchedItemQueryService(
|
|
|
|
|
$services->getDBLoadBalancer(),
|
|
|
|
|
$services->getCommentStore(),
|
2018-03-03 00:21:36 +00:00
|
|
|
$services->getActorMigration(),
|
2019-09-13 20:39:50 +00:00
|
|
|
$services->getWatchedItemStore(),
|
2020-03-06 06:03:44 +00:00
|
|
|
$services->getPermissionManager(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getHookContainer(),
|
2020-03-06 06:03:44 +00:00
|
|
|
$services->getMainConfig()->get( 'WatchlistExpiry' )
|
2017-09-12 17:12:29 +00:00
|
|
|
);
|
|
|
|
|
},
|
2018-01-24 23:41:01 +00:00
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'WatchedItemStore' => function ( MediaWikiServices $services ) : WatchedItemStore {
|
2018-08-03 08:05:44 +00:00
|
|
|
$store = new WatchedItemStore(
|
2020-04-20 22:22:27 +00:00
|
|
|
new ServiceOptions( WatchedItemStore::CONSTRUCTOR_OPTIONS,
|
|
|
|
|
$services->getMainConfig() ),
|
2018-10-11 19:11:43 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2018-03-03 00:21:36 +00:00
|
|
|
JobQueueGroup::singleton(),
|
|
|
|
|
$services->getMainObjectStash(),
|
2018-08-03 08:05:44 +00:00
|
|
|
new HashBagOStuff( [ 'maxKeys' => 100 ] ),
|
|
|
|
|
$services->getReadOnlyMode(),
|
2019-04-29 17:25:13 +00:00
|
|
|
$services->getNamespaceInfo(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getRevisionLookup(),
|
|
|
|
|
$services->getHookContainer()
|
2018-08-03 08:05:44 +00:00
|
|
|
);
|
|
|
|
|
$store->setStatsdDataFactory( $services->getStatsdDataFactory() );
|
|
|
|
|
|
|
|
|
|
if ( $services->getMainConfig()->get( 'ReadOnlyWatchedItemStore' ) ) {
|
|
|
|
|
$store = new NoWriteWatchedItemStore( $store );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $store;
|
2018-07-24 16:44:09 +00:00
|
|
|
},
|
|
|
|
|
|
2020-05-23 08:43:34 +00:00
|
|
|
'WatchlistNotificationManager' =>
|
|
|
|
|
function ( MediaWikiServices $services ) : WatchlistNotificationManager {
|
|
|
|
|
return new WatchlistNotificationManager(
|
|
|
|
|
new ServiceOptions(
|
|
|
|
|
WatchlistNotificationManager::CONSTRUCTOR_OPTIONS,
|
|
|
|
|
$services->getMainConfig()
|
|
|
|
|
),
|
|
|
|
|
$services->getHookContainer(),
|
|
|
|
|
$services->getPermissionManager(),
|
|
|
|
|
$services->getReadOnlyMode(),
|
|
|
|
|
$services->getRevisionLookup(),
|
|
|
|
|
$services->getTalkPageNotificationManager(),
|
|
|
|
|
$services->getWatchedItemStore()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'WikiRevisionOldRevisionImporterNoUpdates' =>
|
|
|
|
|
function ( MediaWikiServices $services ) : ImportableOldRevisionImporter {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new ImportableOldRevisionImporter(
|
|
|
|
|
false,
|
|
|
|
|
LoggerFactory::getInstance( 'OldRevisionImporter' ),
|
|
|
|
|
$services->getDBLoadBalancer()
|
|
|
|
|
);
|
2018-07-25 14:37:16 +00:00
|
|
|
},
|
|
|
|
|
|
2020-05-11 19:19:13 +00:00
|
|
|
'_DefaultOptionsLookup' => function ( MediaWikiServices $services ) : DefaultOptionsLookup {
|
|
|
|
|
return new DefaultOptionsLookup(
|
|
|
|
|
new ServiceOptions( DefaultOptionsLookup::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getContentLanguage(),
|
|
|
|
|
$services->getHookContainer()
|
2020-01-17 06:21:28 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) : MediaWikiTitleCodec {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new MediaWikiTitleCodec(
|
|
|
|
|
$services->getContentLanguage(),
|
|
|
|
|
$services->getGenderCache(),
|
2018-08-15 07:15:04 +00:00
|
|
|
$services->getMainConfig()->get( 'LocalInterwikis' ),
|
2018-08-05 13:00:56 +00:00
|
|
|
$services->getInterwikiLookup(),
|
|
|
|
|
$services->getNamespaceInfo()
|
2016-10-02 07:41:55 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2020-04-28 22:54:18 +00:00
|
|
|
'_PageCommandFactory' => function ( MediaWikiServices $services ) : PageCommandFactory {
|
|
|
|
|
return new PageCommandFactory(
|
|
|
|
|
new ServiceOptions( PageCommandFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
|
2020-04-17 01:30:38 +00:00
|
|
|
$services->getDBLoadBalancer(),
|
|
|
|
|
$services->getNamespaceInfo(),
|
|
|
|
|
$services->getWatchedItemStore(),
|
|
|
|
|
$services->getPermissionManager(),
|
|
|
|
|
$services->getRepoGroup(),
|
|
|
|
|
$services->getContentHandlerFactory(),
|
2020-05-13 21:30:46 +00:00
|
|
|
$services->getRevisionStore(),
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
$services->getSpamChecker(),
|
|
|
|
|
$services->getHookContainer()
|
2020-04-17 01:30:38 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'_SqlBlobStore' => function ( MediaWikiServices $services ) : SqlBlobStore {
|
2018-08-03 08:05:44 +00:00
|
|
|
return $services->getBlobStoreFactory()->newSqlBlobStore();
|
|
|
|
|
},
|
|
|
|
|
|
2015-10-12 08:05:45 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// NOTE: When adding a service here, don't forget to add a getter function
|
|
|
|
|
// in the MediaWikiServices class. The convenience getter should just call
|
|
|
|
|
// $this->getService( 'FooBarService' ).
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
];
|