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
|
|
|
|
|
*
|
|
|
|
|
* @see docs/injection.txt for an overview of using dependency injection in the
|
|
|
|
|
* 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;
|
2016-12-14 20:55:56 +00:00
|
|
|
use MediaWiki\Config\ConfigRepository;
|
2019-04-10 15:03:54 +00:00
|
|
|
use MediaWiki\Config\ServiceOptions;
|
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;
|
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;
|
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;
|
2015-10-12 08:05:45 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2019-07-15 10:24:38 +00:00
|
|
|
use Wikimedia\Message\IMessageFormatterFactory;
|
|
|
|
|
use MediaWiki\Message\MessageFormatterFactory;
|
2019-05-01 11:39:45 +00:00
|
|
|
use MediaWiki\Page\MovePageFactory;
|
2019-03-07 20:02:07 +00:00
|
|
|
use MediaWiki\Permissions\PermissionManager;
|
2018-08-07 16:33:20 +00:00
|
|
|
use MediaWiki\Preferences\PreferencesFactory;
|
2017-11-07 03:10:14 +00:00
|
|
|
use MediaWiki\Preferences\DefaultPreferencesFactory;
|
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;
|
2018-11-19 11:39:56 +00:00
|
|
|
use MediaWiki\Revision\SlotRoleRegistry;
|
2018-09-20 17:29:04 +00:00
|
|
|
use MediaWiki\Revision\RevisionRenderer;
|
|
|
|
|
use MediaWiki\Revision\RevisionStore;
|
|
|
|
|
use MediaWiki\Revision\RevisionStoreFactory;
|
2017-10-07 02:26:52 +00:00
|
|
|
use MediaWiki\Shell\CommandFactory;
|
2018-08-07 10:58:31 +00:00
|
|
|
use MediaWiki\Special\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;
|
2018-09-04 01:59:03 +00:00
|
|
|
use MediaWiki\Storage\NameTableStoreFactory;
|
2018-08-07 16:33:20 +00:00
|
|
|
use MediaWiki\Storage\SqlBlobStore;
|
2019-04-13 04:38:55 +00:00
|
|
|
use MediaWiki\Storage\PageEditStash;
|
2019-08-21 16:10:30 +00:00
|
|
|
use Wikimedia\ObjectFactory;
|
2015-10-12 08:05:45 +00:00
|
|
|
|
|
|
|
|
return [
|
2018-08-07 16:33:20 +00:00
|
|
|
'ActorMigration' => function ( MediaWikiServices $services ) : ActorMigration {
|
2019-07-23 17:40:52 +00:00
|
|
|
return new ActorMigration( SCHEMA_COMPAT_NEW );
|
2016-05-01 19:29:11 +00:00
|
|
|
},
|
|
|
|
|
|
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(),
|
|
|
|
|
$services->getTitleParser()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
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(),
|
|
|
|
|
LoggerFactory::getInstance( 'BlockManager' )
|
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()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
$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(),
|
|
|
|
|
$services->getMainObjectStash(),
|
|
|
|
|
$services->getMainWANObjectCache()
|
2018-07-02 17:01:45 +00:00
|
|
|
);
|
2018-08-03 08:05:44 +00:00
|
|
|
$class = MWLBFactory::getLBFactoryClass( $lbConf );
|
|
|
|
|
|
2019-09-18 16:44:15 +00:00
|
|
|
return new $class( $lbConf );
|
2018-07-02 17:01:45 +00:00
|
|
|
},
|
|
|
|
|
|
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(),
|
|
|
|
|
$services->getTempFSFileFactory()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
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
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'HttpRequestFactory' =>
|
2019-04-22 08:21:50 +00:00
|
|
|
function ( MediaWikiServices $services ) : HttpRequestFactory {
|
|
|
|
|
return new HttpRequestFactory();
|
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(),
|
|
|
|
|
$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
|
|
|
|
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(),
|
|
|
|
|
$services->getLanguageFallback()
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
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 {
|
|
|
|
|
return new LanguageNameUtils( new ServiceOptions(
|
2019-10-10 23:56:18 +00:00
|
|
|
LanguageNameUtils::CONSTRUCTOR_OPTIONS,
|
2019-05-02 14:23:42 +00:00
|
|
|
$services->getMainConfig()
|
|
|
|
|
) );
|
|
|
|
|
},
|
|
|
|
|
|
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(),
|
|
|
|
|
$services->getNamespaceInfo()
|
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' ) );
|
|
|
|
|
$logger->debug( 'LocalisationCache: using store ' . get_class( $store ) );
|
|
|
|
|
|
|
|
|
|
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 ) {
|
|
|
|
|
$services->getResourceLoader()->getMessageBlobStore()->clear();
|
2019-05-02 14:23:42 +00:00
|
|
|
} ],
|
|
|
|
|
$services->getLanguageNameUtils()
|
2019-05-01 13:56:41 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
|
2019-08-13 00:46:14 +00:00
|
|
|
$config = $services->getMainConfig();
|
2019-08-29 04:50:12 +00:00
|
|
|
$cacheId = ObjectCache::detectLocalServerCache();
|
2019-07-20 21:09:31 +00:00
|
|
|
|
2019-08-29 04:50:12 +00:00
|
|
|
return ObjectCache::newFromParams( $config->get( 'ObjectCaches' )[$cacheId] );
|
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 {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new MagicWordFactory( $services->getContentLanguage() );
|
|
|
|
|
},
|
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];
|
|
|
|
|
$logger = $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] ?? 'objectcache' );
|
|
|
|
|
|
|
|
|
|
$store = ObjectCache::newFromParams( $params );
|
|
|
|
|
$logger->debug( 'MainObjectStash using store {class}', [
|
|
|
|
|
'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();
|
|
|
|
|
|
|
|
|
|
$id = $mainConfig->get( 'MainWANCache' );
|
|
|
|
|
if ( !isset( $mainConfig->get( 'WANObjectCaches' )[$id] ) ) {
|
|
|
|
|
throw new UnexpectedValueException(
|
|
|
|
|
"WAN cache type \"$id\" is not present in \$wgWANObjectCaches." );
|
2016-10-04 17:48:02 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-03 08:05:44 +00:00
|
|
|
$params = $mainConfig->get( 'WANObjectCaches' )[$id];
|
2019-10-08 21:34:17 +00:00
|
|
|
|
|
|
|
|
$logger = LoggerFactory::getInstance( $params['loggroup'] ?? 'objectcache' );
|
|
|
|
|
|
2018-08-03 08:05:44 +00:00
|
|
|
$objectCacheId = $params['cacheId'];
|
|
|
|
|
if ( !isset( $mainConfig->get( 'ObjectCaches' )[$objectCacheId] ) ) {
|
|
|
|
|
throw new UnexpectedValueException(
|
|
|
|
|
"Cache type \"$objectCacheId\" is not present in \$wgObjectCaches." );
|
|
|
|
|
}
|
2019-10-08 21:34:17 +00:00
|
|
|
$storeParams = $mainConfig->get( 'ObjectCaches' )[$objectCacheId];
|
|
|
|
|
$store = ObjectCache::newFromParams( $storeParams );
|
|
|
|
|
$logger->debug( 'MainWANObjectCache using store {class}', [
|
|
|
|
|
'class' => get_class( $store )
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
$params['logger'] = $logger;
|
|
|
|
|
$params['cache'] = $store;
|
|
|
|
|
$params['secret'] = $params['secret'] ?? $mainConfig->get( 'SecretKey' );
|
|
|
|
|
if ( !$mainConfig->get( 'CommandLineMode' ) ) {
|
|
|
|
|
// Send the statsd data post-send on HTTP requests; avoid in CLI mode (T181385)
|
|
|
|
|
$params['stats'] = $services->getStatsdDataFactory();
|
|
|
|
|
// Let pre-emptive refreshes happen post-send on HTTP requests
|
|
|
|
|
$params['asyncHandler'] = [ DeferredUpdates::class, 'addCallableUpdate' ];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$class = $params['class'];
|
2019-09-26 14:17:03 +00:00
|
|
|
// @phan-suppress-next-line PhanParamTooMany Not inferring the right type
|
2019-10-08 21:34:17 +00:00
|
|
|
$instance = new $class( $params );
|
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
|
|
|
},
|
|
|
|
|
|
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(),
|
|
|
|
|
$logger,
|
2019-08-26 12:24:37 +00:00
|
|
|
[ 'useDB' => $mainConfig->get( 'UseDatabaseMessages' ) ],
|
2019-10-28 18:05:35 +00:00
|
|
|
$services->getLanguageFactory(),
|
|
|
|
|
$services->getLocalisationCache()
|
2019-04-08 15:21:49 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-07-15 10:24:38 +00:00
|
|
|
'MessageFormatterFactory' =>
|
|
|
|
|
function ( MediaWikiServices $services ) : IMessageFormatterFactory {
|
2019-09-01 12:45:11 +00:00
|
|
|
// @phan-suppress-next-line PhanAccessMethodInternal
|
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();
|
|
|
|
|
$params = [
|
|
|
|
|
'typeFile' => $mainConfig->get( 'MimeTypeFile' ),
|
|
|
|
|
'infoFile' => $mainConfig->get( 'MimeInfoFile' ),
|
|
|
|
|
'xmlTypes' => $mainConfig->get( 'XMLMimeTypes' ),
|
|
|
|
|
'guessCallback' =>
|
|
|
|
|
function ( $mimeAnalyzer, &$head, &$tail, $file, &$mime ) use ( $logger ) {
|
|
|
|
|
// 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(
|
|
|
|
|
'MimeMagicGuessFromContent',
|
|
|
|
|
[ $mimeAnalyzer, &$head, &$tail, $file, &$mime ]
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
'extCallback' => function ( $mimeAnalyzer, $ext, &$mime ) {
|
|
|
|
|
// Media handling extensions can improve the MIME detected
|
|
|
|
|
Hooks::run( 'MimeMagicImproveFromExtension', [ $mimeAnalyzer, $ext, &$mime ] );
|
|
|
|
|
},
|
|
|
|
|
'initCallback' => function ( $mimeAnalyzer ) {
|
|
|
|
|
// Allow media handling extensions adding MIME-types and MIME-info
|
|
|
|
|
Hooks::run( 'MimeMagicInit', [ $mimeAnalyzer ] );
|
|
|
|
|
},
|
|
|
|
|
'logger' => $logger
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if ( $params['infoFile'] === 'includes/mime.info' ) {
|
|
|
|
|
$params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $params['typeFile'] === 'includes/mime.types' ) {
|
|
|
|
|
$params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$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 {
|
|
|
|
|
return new MovePageFactory(
|
2019-10-05 08:26:52 +00:00
|
|
|
new ServiceOptions( MovePageFactory::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
|
2019-05-01 11:39:45 +00:00
|
|
|
$services->getDBLoadBalancer(),
|
|
|
|
|
$services->getNamespaceInfo(),
|
|
|
|
|
$services->getWatchedItemStore(),
|
2019-05-05 13:45:19 +00:00
|
|
|
$services->getPermissionManager(),
|
|
|
|
|
$services->getRepoGroup()
|
2019-05-01 11:39:45 +00:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-04-10 10:36:02 +00:00
|
|
|
'NamespaceInfo' => function ( MediaWikiServices $services ) : NamespaceInfo {
|
2019-10-03 21:50:47 +00:00
|
|
|
return new NamespaceInfo( new ServiceOptions( NamespaceInfo::CONSTRUCTOR_OPTIONS,
|
2019-04-12 09:49:59 +00:00
|
|
|
$services->getMainConfig() ) );
|
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(),
|
|
|
|
|
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,
|
|
|
|
|
$config->get( 'CacheEpoch' )
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
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,
|
2019-04-12 09:50:30 +00:00
|
|
|
// 'class' and 'preprocessorClass'
|
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
|
2019-08-29 04:50:12 +00:00
|
|
|
[ 'class' => Parser::class, 'preprocessorClass' => Preprocessor_Hash::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(),
|
|
|
|
|
LoggerFactory::getInstance( 'Parser' )
|
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(),
|
|
|
|
|
LoggerFactory::getInstance( 'authentication' )
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
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(),
|
|
|
|
|
$services->getBlockErrorFormatter()
|
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(),
|
|
|
|
|
$services->getPermissionManager()
|
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-02-16 23:16:09 +00:00
|
|
|
LoggerFactory::getInstance( 'resourceloader' )
|
|
|
|
|
);
|
2019-04-17 14:17:15 +00:00
|
|
|
|
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" );
|
2019-04-17 14:17:15 +00:00
|
|
|
$rl->register( $config->get( 'ResourceModules' ) );
|
|
|
|
|
Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
|
|
|
|
|
|
2019-10-12 03:17:51 +00:00
|
|
|
$extRegistry = ExtensionRegistry::getInstance();
|
|
|
|
|
$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();
|
|
|
|
|
$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(),
|
|
|
|
|
$config->get( 'MultiContentRevisionSchemaMigrationStage' ),
|
2019-09-10 02:24:18 +00:00
|
|
|
LoggerFactory::getInstance( 'RevisionStore' ),
|
2018-06-27 12:16:35 +00:00
|
|
|
$config->get( 'ContentHandlerUseDB' )
|
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.
|
2018-08-03 08:05:44 +00:00
|
|
|
return new SearchEngineConfig( $services->getMainConfig(),
|
|
|
|
|
$services->getContentLanguage() );
|
2018-01-09 08:53:38 +00:00
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'SearchEngineFactory' => function ( MediaWikiServices $services ) : SearchEngineFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
return new SearchEngineFactory( $services->getSearchEngineConfig() );
|
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
|
|
|
|
|
// to allow for a cacheable read-only interface (using FileBasedSiteLookup),
|
|
|
|
|
// but this was never used. SiteStore has caching (see below).
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'SkinFactory' => function ( MediaWikiServices $services ) : SkinFactory {
|
2018-08-03 08:05:44 +00:00
|
|
|
$factory = new SkinFactory();
|
|
|
|
|
|
|
|
|
|
$names = $services->getMainConfig()->get( 'ValidSkinNames' );
|
|
|
|
|
|
|
|
|
|
foreach ( $names as $name => $skin ) {
|
|
|
|
|
$factory->register( $name, $skin, function () use ( $name, $skin ) {
|
|
|
|
|
$class = "Skin$skin";
|
|
|
|
|
return new $class( $name );
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
// Register a hidden "fallback" skin
|
|
|
|
|
$factory->register( 'fallback', 'Fallback', function () {
|
|
|
|
|
return new SkinFallback;
|
|
|
|
|
} );
|
|
|
|
|
// Register a hidden skin for api output
|
|
|
|
|
$factory->register( 'apioutput', 'ApiOutput', function () {
|
|
|
|
|
return new SkinApi;
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
$registry = new SlotRoleRegistry(
|
|
|
|
|
$services->getNameTableStoreFactory()->getSlotRoles()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$registry->defineRole( 'main', function () use ( $config ) {
|
|
|
|
|
return new MainSlotRoleHandler(
|
|
|
|
|
$config->get( 'NamespaceContentModels' )
|
|
|
|
|
);
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
return $registry;
|
|
|
|
|
},
|
|
|
|
|
|
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(),
|
|
|
|
|
$services->getObjectFactory()
|
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
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2019-08-16 10:00:15 +00:00
|
|
|
'TempFSFileFactory' => function ( MediaWikiServices $services ) : TempFSFileFactory {
|
|
|
|
|
return new TempFSFileFactory( $services->getMainConfig()->get( 'TmpDirectory' ) );
|
|
|
|
|
},
|
|
|
|
|
|
2019-10-17 16:48:39 +00:00
|
|
|
'TitleFactory' => function ( MediaWikiServices $services ) : TitleFactory {
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
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' );
|
|
|
|
|
|
|
|
|
|
$vrsClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) );
|
|
|
|
|
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(),
|
|
|
|
|
$services->getPermissionManager()
|
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(
|
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->getMainConfig()->get( 'UpdateRowsPerQuery' ),
|
|
|
|
|
$services->getNamespaceInfo(),
|
|
|
|
|
$services->getRevisionLookup()
|
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
|
|
|
},
|
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
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
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2018-08-07 16:33:20 +00:00
|
|
|
'_SqlBlobStore' => function ( MediaWikiServices $services ) : SqlBlobStore {
|
2019-09-01 12:45:11 +00:00
|
|
|
// @phan-suppress-next-line PhanAccessMethodInternal
|
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' ).
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
];
|