2020-01-15 16:08:53 +00:00
|
|
|
<?php
|
|
|
|
|
2020-09-20 22:31:41 +00:00
|
|
|
use MediaWiki\Config\ServiceOptions;
|
2024-06-12 18:01:35 +00:00
|
|
|
use MediaWiki\Context\RequestContext;
|
2018-03-08 21:16:25 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilterActorMigration;
|
2020-09-18 14:49:13 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager as PermManager;
|
2020-10-24 11:58:46 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseLogger;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseLoggerFactory;
|
2020-10-21 14:18:08 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\BlockAutopromoteStore;
|
2023-08-06 11:44:16 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\BlockedDomainFilter;
|
2023-05-24 20:09:59 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\BlockedDomainStorage;
|
2020-10-16 22:29:41 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\CentralDBManager;
|
2020-11-26 15:23:22 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\ChangeTags\ChangeTagger;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\ChangeTags\ChangeTagsManager;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\ChangeTags\ChangeTagValidator;
|
2020-12-18 14:05:33 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesExecutor;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesExecutorFactory as ConsExecutorFactory;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesFactory;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesLookup;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Consequences\ConsequencesRegistry;
|
2020-11-10 12:58:11 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\EchoNotifier;
|
2021-02-01 15:47:46 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\EditBox\EditBoxBuilderFactory;
|
2021-01-05 13:33:45 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\EditRevUpdater;
|
2021-02-10 13:13:03 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\EmergencyCache;
|
2020-11-07 11:40:26 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterCompare;
|
2020-10-15 22:00:32 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterImporter;
|
2020-09-20 11:30:59 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterLookup;
|
2020-09-20 22:31:41 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterProfiler;
|
2021-01-06 15:40:23 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterRunner;
|
2020-11-27 14:49:41 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterRunnerFactory;
|
2020-09-19 22:16:35 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterStore;
|
2020-10-25 15:30:43 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterUser;
|
2020-10-10 17:20:21 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterValidator;
|
2020-01-15 16:08:53 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Hooks\AbuseFilterHookRunner;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\KeywordsManager;
|
2021-09-01 11:53:38 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Parser\RuleCheckerFactory;
|
2020-10-02 15:08:48 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\SpecsFormatter;
|
2020-09-29 18:48:51 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\TextExtractor;
|
2021-01-03 13:10:20 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\VariableGenerator\VariableGeneratorFactory;
|
2021-01-02 13:41:31 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Variables\LazyVariableComputer;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Variables\VariablesBlobStore;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Variables\VariablesFormatter;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Variables\VariablesManager;
|
2020-11-19 15:32:39 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Watcher\EmergencyWatcher;
|
2020-11-28 23:53:42 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Watcher\UpdateHitCountWatcher;
|
2020-09-20 22:31:41 +00:00
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
2020-01-15 16:08:53 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2023-04-25 09:52:41 +00:00
|
|
|
use MediaWiki\WikiMap\WikiMap;
|
2021-09-01 18:29:19 +00:00
|
|
|
use Wikimedia\Equivset\Equivset;
|
2020-01-15 16:08:53 +00:00
|
|
|
|
2020-11-19 17:49:55 +00:00
|
|
|
// This file is actually covered by AbuseFilterServicesTest, but it's not possible to specify a path
|
|
|
|
// in @covers annotations (https://github.com/sebastianbergmann/phpunit/issues/3794)
|
|
|
|
// @codeCoverageIgnoreStart
|
|
|
|
|
2020-01-15 16:08:53 +00:00
|
|
|
return [
|
2021-04-30 18:54:17 +00:00
|
|
|
AbuseFilterHookRunner::SERVICE_NAME => static function ( MediaWikiServices $services ): AbuseFilterHookRunner {
|
2021-01-09 13:40:10 +00:00
|
|
|
return new AbuseFilterHookRunner( $services->getHookContainer() );
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
KeywordsManager::SERVICE_NAME => static function ( MediaWikiServices $services ): KeywordsManager {
|
2021-01-09 13:40:10 +00:00
|
|
|
return new KeywordsManager( $services->get( AbuseFilterHookRunner::SERVICE_NAME ) );
|
2020-01-15 16:08:53 +00:00
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
FilterProfiler::SERVICE_NAME => static function ( MediaWikiServices $services ): FilterProfiler {
|
2020-09-20 22:31:41 +00:00
|
|
|
return new FilterProfiler(
|
2022-06-23 01:13:09 +00:00
|
|
|
$services->getWRStatsFactory(),
|
2020-09-20 22:31:41 +00:00
|
|
|
new ServiceOptions(
|
|
|
|
FilterProfiler::CONSTRUCTOR_OPTIONS,
|
|
|
|
$services->getMainConfig()
|
|
|
|
),
|
|
|
|
WikiMap::getCurrentWikiDbDomain()->getId(),
|
|
|
|
$services->getStatsdDataFactory(),
|
|
|
|
LoggerFactory::getInstance( 'AbuseFilter' )
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
PermManager::SERVICE_NAME => static function ( MediaWikiServices $services ): PermManager {
|
2024-05-23 14:49:17 +00:00
|
|
|
return new PermManager(
|
|
|
|
new ServiceOptions(
|
|
|
|
PermManager::CONSTRUCTOR_OPTIONS,
|
|
|
|
$services->getMainConfig(),
|
|
|
|
[ 'AbuseFilterProtectedVariables' => [] ]
|
|
|
|
)
|
|
|
|
);
|
2020-09-18 14:49:13 +00:00
|
|
|
},
|
2021-07-21 18:51:12 +00:00
|
|
|
ChangeTagger::SERVICE_NAME => static function ( MediaWikiServices $services ): ChangeTagger {
|
2020-10-21 14:30:43 +00:00
|
|
|
return new ChangeTagger(
|
|
|
|
$services->getService( ChangeTagsManager::SERVICE_NAME )
|
|
|
|
);
|
2020-10-13 16:01:18 +00:00
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
ChangeTagsManager::SERVICE_NAME => static function ( MediaWikiServices $services ): ChangeTagsManager {
|
2020-10-14 14:21:48 +00:00
|
|
|
return new ChangeTagsManager(
|
2024-03-29 10:08:41 +00:00
|
|
|
$services->getChangeTagsStore(),
|
2023-02-26 12:51:08 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2020-10-14 14:21:48 +00:00
|
|
|
$services->getMainWANObjectCache(),
|
2020-10-16 22:29:41 +00:00
|
|
|
$services->get( CentralDBManager::SERVICE_NAME )
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
ChangeTagValidator::SERVICE_NAME => static function ( MediaWikiServices $services ): ChangeTagValidator {
|
2020-11-06 12:13:02 +00:00
|
|
|
return new ChangeTagValidator(
|
|
|
|
$services->getService( ChangeTagsManager::SERVICE_NAME )
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
CentralDBManager::SERVICE_NAME => static function ( MediaWikiServices $services ): CentralDBManager {
|
2020-10-16 22:29:41 +00:00
|
|
|
return new CentralDBManager(
|
|
|
|
$services->getDBLoadBalancerFactory(),
|
2020-09-20 11:30:59 +00:00
|
|
|
$services->getMainConfig()->get( 'AbuseFilterCentralDB' ),
|
|
|
|
$services->getMainConfig()->get( 'AbuseFilterIsCentral' )
|
2020-10-14 14:21:48 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
BlockAutopromoteStore::SERVICE_NAME => static function ( MediaWikiServices $services ): BlockAutopromoteStore {
|
2020-10-21 14:18:08 +00:00
|
|
|
return new BlockAutopromoteStore(
|
2022-01-19 17:46:17 +00:00
|
|
|
$services->getMainObjectStash(),
|
2020-10-25 15:30:43 +00:00
|
|
|
LoggerFactory::getInstance( 'AbuseFilter' ),
|
|
|
|
$services->get( FilterUser::SERVICE_NAME )
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
FilterUser::SERVICE_NAME => static function ( MediaWikiServices $services ): FilterUser {
|
2020-10-25 15:30:43 +00:00
|
|
|
return new FilterUser(
|
|
|
|
// TODO We need a proper MessageLocalizer, see T247127
|
|
|
|
RequestContext::getMain(),
|
|
|
|
$services->getUserGroupManager(),
|
2024-01-31 17:50:53 +00:00
|
|
|
$services->getUserNameUtils(),
|
2020-10-21 14:18:08 +00:00
|
|
|
LoggerFactory::getInstance( 'AbuseFilter' )
|
|
|
|
);
|
|
|
|
},
|
2021-09-01 11:53:38 +00:00
|
|
|
RuleCheckerFactory::SERVICE_NAME => static function ( MediaWikiServices $services ): RuleCheckerFactory {
|
|
|
|
return new RuleCheckerFactory(
|
2019-12-16 16:19:48 +00:00
|
|
|
$services->getContentLanguage(),
|
2024-05-04 08:14:01 +00:00
|
|
|
$services->getObjectCacheFactory()->getLocalServerInstance( CACHE_HASH ),
|
2019-12-16 16:19:48 +00:00
|
|
|
LoggerFactory::getInstance( 'AbuseFilter' ),
|
|
|
|
$services->getService( KeywordsManager::SERVICE_NAME ),
|
2020-10-18 22:25:05 +00:00
|
|
|
$services->get( VariablesManager::SERVICE_NAME ),
|
2021-09-01 11:18:23 +00:00
|
|
|
$services->getStatsdDataFactory(),
|
2021-09-01 18:29:19 +00:00
|
|
|
new Equivset(),
|
2021-01-01 16:07:14 +00:00
|
|
|
$services->getMainConfig()->get( 'AbuseFilterConditionLimit' )
|
2019-12-16 16:19:48 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
FilterLookup::SERVICE_NAME => static function ( MediaWikiServices $services ): FilterLookup {
|
2020-09-20 11:30:59 +00:00
|
|
|
return new FilterLookup(
|
|
|
|
$services->getDBLoadBalancer(),
|
|
|
|
$services->getMainWANObjectCache(),
|
2024-03-18 14:32:43 +00:00
|
|
|
$services->get( CentralDBManager::SERVICE_NAME )
|
2020-09-20 11:30:59 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
EmergencyCache::SERVICE_NAME => static function ( MediaWikiServices $services ): EmergencyCache {
|
2021-02-10 13:13:03 +00:00
|
|
|
return new EmergencyCache(
|
|
|
|
$services->getMainObjectStash(),
|
|
|
|
$services->getMainConfig()->get( 'AbuseFilterEmergencyDisableAge' )
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
EmergencyWatcher::SERVICE_NAME => static function ( MediaWikiServices $services ): EmergencyWatcher {
|
2020-09-19 09:45:25 +00:00
|
|
|
return new EmergencyWatcher(
|
2021-02-10 13:13:03 +00:00
|
|
|
$services->getService( EmergencyCache::SERVICE_NAME ),
|
2023-02-26 12:51:08 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2020-09-19 09:45:25 +00:00
|
|
|
$services->getService( FilterLookup::SERVICE_NAME ),
|
2020-11-10 12:58:11 +00:00
|
|
|
$services->getService( EchoNotifier::SERVICE_NAME ),
|
2020-09-19 09:45:25 +00:00
|
|
|
new ServiceOptions(
|
|
|
|
EmergencyWatcher::CONSTRUCTOR_OPTIONS,
|
|
|
|
$services->getMainConfig()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
EchoNotifier::SERVICE_NAME => static function ( MediaWikiServices $services ): EchoNotifier {
|
2020-11-10 12:58:11 +00:00
|
|
|
return new EchoNotifier(
|
|
|
|
$services->getService( FilterLookup::SERVICE_NAME ),
|
2022-02-19 13:49:58 +00:00
|
|
|
$services->getService( ConsequencesRegistry::SERVICE_NAME ),
|
2020-11-10 12:58:11 +00:00
|
|
|
ExtensionRegistry::getInstance()->isLoaded( 'Echo' )
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
FilterValidator::SERVICE_NAME => static function ( MediaWikiServices $services ): FilterValidator {
|
2020-10-10 17:20:21 +00:00
|
|
|
return new FilterValidator(
|
2020-11-06 12:13:02 +00:00
|
|
|
$services->get( ChangeTagValidator::SERVICE_NAME ),
|
2021-09-01 11:53:38 +00:00
|
|
|
$services->get( RuleCheckerFactory::SERVICE_NAME ),
|
2020-10-10 17:20:21 +00:00
|
|
|
$services->get( PermManager::SERVICE_NAME ),
|
2021-02-26 16:47:50 +00:00
|
|
|
new ServiceOptions(
|
|
|
|
FilterValidator::CONSTRUCTOR_OPTIONS,
|
2024-05-23 14:49:17 +00:00
|
|
|
$services->getMainConfig(),
|
|
|
|
[ 'AbuseFilterProtectedVariables' => [] ]
|
2021-02-26 16:47:50 +00:00
|
|
|
)
|
2020-10-10 17:20:21 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
FilterCompare::SERVICE_NAME => static function ( MediaWikiServices $services ): FilterCompare {
|
2020-11-07 11:40:26 +00:00
|
|
|
return new FilterCompare(
|
2020-11-29 23:10:14 +00:00
|
|
|
$services->get( ConsequencesRegistry::SERVICE_NAME )
|
2020-11-07 11:40:26 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
FilterImporter::SERVICE_NAME => static function ( MediaWikiServices $services ): FilterImporter {
|
2020-10-15 22:00:32 +00:00
|
|
|
return new FilterImporter(
|
|
|
|
new ServiceOptions(
|
|
|
|
FilterImporter::CONSTRUCTOR_OPTIONS,
|
|
|
|
$services->getMainConfig()
|
2020-11-29 23:10:14 +00:00
|
|
|
),
|
|
|
|
$services->get( ConsequencesRegistry::SERVICE_NAME )
|
2020-10-15 22:00:32 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
FilterStore::SERVICE_NAME => static function ( MediaWikiServices $services ): FilterStore {
|
2020-09-19 22:16:35 +00:00
|
|
|
return new FilterStore(
|
2020-11-29 23:10:14 +00:00
|
|
|
$services->get( ConsequencesRegistry::SERVICE_NAME ),
|
2023-02-26 12:51:08 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2020-09-19 22:16:35 +00:00
|
|
|
$services->get( FilterProfiler::SERVICE_NAME ),
|
|
|
|
$services->get( FilterLookup::SERVICE_NAME ),
|
|
|
|
$services->get( ChangeTagsManager::SERVICE_NAME ),
|
|
|
|
$services->get( FilterValidator::SERVICE_NAME ),
|
2021-02-10 13:13:03 +00:00
|
|
|
$services->get( FilterCompare::SERVICE_NAME ),
|
2018-03-08 21:16:25 +00:00
|
|
|
$services->get( EmergencyCache::SERVICE_NAME ),
|
|
|
|
$services->get( AbuseFilterActorMigration::SERVICE_NAME )
|
2020-09-19 22:16:35 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
ConsequencesFactory::SERVICE_NAME => static function ( MediaWikiServices $services ): ConsequencesFactory {
|
2020-10-11 21:17:41 +00:00
|
|
|
return new ConsequencesFactory(
|
|
|
|
new ServiceOptions(
|
|
|
|
ConsequencesFactory::CONSTRUCTOR_OPTIONS,
|
|
|
|
$services->getMainConfig()
|
|
|
|
),
|
|
|
|
LoggerFactory::getInstance( 'AbuseFilter' ),
|
|
|
|
$services->getBlockUserFactory(),
|
2020-11-29 15:18:32 +00:00
|
|
|
$services->getDatabaseBlockStore(),
|
2020-10-11 21:17:41 +00:00
|
|
|
$services->getUserGroupManager(),
|
|
|
|
$services->getMainObjectStash(),
|
|
|
|
$services->get( ChangeTagger::SERVICE_NAME ),
|
|
|
|
$services->get( BlockAutopromoteStore::SERVICE_NAME ),
|
|
|
|
$services->get( FilterUser::SERVICE_NAME ),
|
2021-01-09 23:26:29 +00:00
|
|
|
// TODO: Use a proper MessageLocalizer once available (T247127)
|
|
|
|
RequestContext::getMain(),
|
|
|
|
$services->getUserEditTracker(),
|
2023-04-24 13:37:53 +00:00
|
|
|
$services->getUserFactory(),
|
2023-07-26 14:22:30 +00:00
|
|
|
$services->getUserIdentityUtils()
|
2020-10-11 21:17:41 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
EditBoxBuilderFactory::SERVICE_NAME => static function ( MediaWikiServices $services ): EditBoxBuilderFactory {
|
2020-11-24 12:16:41 +00:00
|
|
|
return new EditBoxBuilderFactory(
|
|
|
|
$services->get( PermManager::SERVICE_NAME ),
|
|
|
|
$services->get( KeywordsManager::SERVICE_NAME ),
|
|
|
|
ExtensionRegistry::getInstance()->isLoaded( 'CodeEditor' )
|
|
|
|
);
|
|
|
|
},
|
2021-07-21 18:51:12 +00:00
|
|
|
ConsequencesLookup::SERVICE_NAME => static function ( MediaWikiServices $services ): ConsequencesLookup {
|
2020-10-17 11:50:21 +00:00
|
|
|
return new ConsequencesLookup(
|
2023-02-26 12:51:08 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2020-10-17 11:50:21 +00:00
|
|
|
$services->get( CentralDBManager::SERVICE_NAME ),
|
2020-11-29 22:55:34 +00:00
|
|
|
$services->get( ConsequencesRegistry::SERVICE_NAME ),
|
2020-10-17 11:50:21 +00:00
|
|
|
LoggerFactory::getInstance( 'AbuseFilter' )
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
ConsequencesRegistry::SERVICE_NAME => static function ( MediaWikiServices $services ): ConsequencesRegistry {
|
2020-11-29 22:55:34 +00:00
|
|
|
return new ConsequencesRegistry(
|
2021-01-09 13:40:10 +00:00
|
|
|
$services->get( AbuseFilterHookRunner::SERVICE_NAME ),
|
2020-12-04 16:21:21 +00:00
|
|
|
$services->getMainConfig()->get( 'AbuseFilterActions' )
|
2020-11-29 22:55:34 +00:00
|
|
|
);
|
|
|
|
},
|
2021-07-21 18:51:12 +00:00
|
|
|
AbuseLoggerFactory::SERVICE_NAME => static function ( MediaWikiServices $services ): AbuseLoggerFactory {
|
2020-10-24 11:58:46 +00:00
|
|
|
return new AbuseLoggerFactory(
|
|
|
|
$services->get( CentralDBManager::SERVICE_NAME ),
|
|
|
|
$services->get( FilterLookup::SERVICE_NAME ),
|
2020-09-29 14:52:05 +00:00
|
|
|
$services->get( VariablesBlobStore::SERVICE_NAME ),
|
2020-10-18 22:25:05 +00:00
|
|
|
$services->get( VariablesManager::SERVICE_NAME ),
|
2021-01-05 13:33:45 +00:00
|
|
|
$services->get( EditRevUpdater::SERVICE_NAME ),
|
2023-02-26 12:51:08 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2020-10-24 11:58:46 +00:00
|
|
|
new ServiceOptions(
|
|
|
|
AbuseLogger::CONSTRUCTOR_OPTIONS,
|
|
|
|
$services->getMainConfig()
|
|
|
|
),
|
|
|
|
WikiMap::getCurrentWikiDbDomain()->getId(),
|
|
|
|
RequestContext::getMain()->getRequest()->getIP()
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
UpdateHitCountWatcher::SERVICE_NAME => static function ( MediaWikiServices $services ): UpdateHitCountWatcher {
|
2020-11-28 23:53:42 +00:00
|
|
|
return new UpdateHitCountWatcher(
|
2023-02-26 12:51:08 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2023-08-18 20:47:19 +00:00
|
|
|
$services->get( CentralDBManager::SERVICE_NAME )
|
2020-11-28 23:53:42 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
VariablesBlobStore::SERVICE_NAME => static function ( MediaWikiServices $services ): VariablesBlobStore {
|
2020-09-29 14:52:05 +00:00
|
|
|
return new VariablesBlobStore(
|
2020-10-18 22:25:05 +00:00
|
|
|
$services->get( VariablesManager::SERVICE_NAME ),
|
2020-09-29 14:52:05 +00:00
|
|
|
$services->getBlobStoreFactory(),
|
|
|
|
$services->getBlobStore(),
|
|
|
|
$services->getMainConfig()->get( 'AbuseFilterCentralDB' )
|
|
|
|
);
|
|
|
|
},
|
2021-07-21 18:51:12 +00:00
|
|
|
ConsExecutorFactory::SERVICE_NAME => static function ( MediaWikiServices $services ): ConsExecutorFactory {
|
2020-10-16 22:10:37 +00:00
|
|
|
return new ConsExecutorFactory(
|
|
|
|
$services->get( ConsequencesLookup::SERVICE_NAME ),
|
|
|
|
$services->get( ConsequencesFactory::SERVICE_NAME ),
|
|
|
|
$services->get( ConsequencesRegistry::SERVICE_NAME ),
|
|
|
|
$services->get( FilterLookup::SERVICE_NAME ),
|
|
|
|
LoggerFactory::getInstance( 'AbuseFilter' ),
|
2023-07-26 14:22:30 +00:00
|
|
|
$services->getUserIdentityUtils(),
|
2020-10-16 22:10:37 +00:00
|
|
|
new ServiceOptions(
|
|
|
|
ConsequencesExecutor::CONSTRUCTOR_OPTIONS,
|
|
|
|
$services->getMainConfig()
|
|
|
|
)
|
|
|
|
);
|
|
|
|
},
|
2021-07-21 18:51:12 +00:00
|
|
|
FilterRunnerFactory::SERVICE_NAME => static function ( MediaWikiServices $services ): FilterRunnerFactory {
|
2020-11-27 14:49:41 +00:00
|
|
|
return new FilterRunnerFactory(
|
2021-01-09 13:40:10 +00:00
|
|
|
$services->get( AbuseFilterHookRunner::SERVICE_NAME ),
|
2020-11-27 14:49:41 +00:00
|
|
|
$services->get( FilterProfiler::SERVICE_NAME ),
|
|
|
|
$services->get( ChangeTagger::SERVICE_NAME ),
|
|
|
|
$services->get( FilterLookup::SERVICE_NAME ),
|
2021-09-01 11:53:38 +00:00
|
|
|
$services->get( RuleCheckerFactory::SERVICE_NAME ),
|
2021-09-01 18:29:19 +00:00
|
|
|
$services->get( ConsExecutorFactory::SERVICE_NAME ),
|
2020-11-27 14:49:41 +00:00
|
|
|
$services->get( AbuseLoggerFactory::SERVICE_NAME ),
|
2020-10-18 22:25:05 +00:00
|
|
|
$services->get( VariablesManager::SERVICE_NAME ),
|
2021-01-03 13:10:20 +00:00
|
|
|
$services->get( VariableGeneratorFactory::SERVICE_NAME ),
|
2021-02-10 13:13:03 +00:00
|
|
|
$services->get( EmergencyCache::SERVICE_NAME ),
|
2020-11-27 14:49:41 +00:00
|
|
|
$services->get( UpdateHitCountWatcher::SERVICE_NAME ),
|
|
|
|
$services->get( EmergencyWatcher::SERVICE_NAME ),
|
2024-06-13 11:31:29 +00:00
|
|
|
$services->getObjectCacheFactory()->getLocalClusterInstance(),
|
2020-11-27 14:49:41 +00:00
|
|
|
LoggerFactory::getInstance( 'AbuseFilter' ),
|
2020-12-21 14:51:31 +00:00
|
|
|
LoggerFactory::getInstance( 'StashEdit' ),
|
2020-11-27 14:49:41 +00:00
|
|
|
$services->getStatsdDataFactory(),
|
2021-01-06 15:40:23 +00:00
|
|
|
new ServiceOptions(
|
|
|
|
FilterRunner::CONSTRUCTOR_OPTIONS,
|
|
|
|
$services->getMainConfig()
|
2023-08-18 20:47:19 +00:00
|
|
|
)
|
2020-11-27 14:49:41 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
VariablesFormatter::SERVICE_NAME => static function ( MediaWikiServices $services ): VariablesFormatter {
|
2020-12-31 13:29:00 +00:00
|
|
|
return new VariablesFormatter(
|
|
|
|
$services->get( KeywordsManager::SERVICE_NAME ),
|
2020-10-18 22:25:05 +00:00
|
|
|
$services->get( VariablesManager::SERVICE_NAME ),
|
2020-12-31 13:29:00 +00:00
|
|
|
// TODO: Use a proper MessageLocalizer once available (T247127)
|
|
|
|
RequestContext::getMain()
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
SpecsFormatter::SERVICE_NAME => static function ( MediaWikiServices $services ): SpecsFormatter {
|
2020-10-02 15:08:48 +00:00
|
|
|
return new SpecsFormatter(
|
|
|
|
// TODO: Use a proper MessageLocalizer once available (T247127)
|
|
|
|
RequestContext::getMain()
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
LazyVariableComputer::SERVICE_NAME => static function ( MediaWikiServices $services ): LazyVariableComputer {
|
2020-09-25 22:32:01 +00:00
|
|
|
return new LazyVariableComputer(
|
2020-09-29 18:48:51 +00:00
|
|
|
$services->get( TextExtractor::SERVICE_NAME ),
|
2021-01-09 13:40:10 +00:00
|
|
|
$services->get( AbuseFilterHookRunner::SERVICE_NAME ),
|
2020-09-25 22:32:01 +00:00
|
|
|
LoggerFactory::getInstance( 'AbuseFilter' ),
|
2023-02-26 12:51:08 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2020-09-25 22:32:01 +00:00
|
|
|
$services->getMainWANObjectCache(),
|
|
|
|
$services->getRevisionLookup(),
|
|
|
|
$services->getRevisionStore(),
|
|
|
|
$services->getContentLanguage(),
|
2023-07-29 12:20:07 +00:00
|
|
|
$services->getParserFactory(),
|
2021-03-09 17:56:04 +00:00
|
|
|
$services->getUserEditTracker(),
|
|
|
|
$services->getUserGroupManager(),
|
|
|
|
$services->getPermissionManager(),
|
2022-03-29 13:59:59 +00:00
|
|
|
$services->getRestrictionStore(),
|
2024-02-27 17:25:35 +00:00
|
|
|
$services->getUserIdentityUtils(),
|
2020-09-25 22:32:01 +00:00
|
|
|
WikiMap::getCurrentWikiDbDomain()->getId()
|
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
TextExtractor::SERVICE_NAME => static function ( MediaWikiServices $services ): TextExtractor {
|
2021-01-09 13:40:10 +00:00
|
|
|
return new TextExtractor( $services->get( AbuseFilterHookRunner::SERVICE_NAME ) );
|
2020-10-18 22:25:05 +00:00
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
VariablesManager::SERVICE_NAME => static function ( MediaWikiServices $services ): VariablesManager {
|
2020-10-18 22:25:05 +00:00
|
|
|
return new VariablesManager(
|
|
|
|
$services->get( KeywordsManager::SERVICE_NAME ),
|
2021-09-01 11:18:23 +00:00
|
|
|
$services->get( LazyVariableComputer::SERVICE_NAME )
|
2020-10-18 22:25:05 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
VariableGeneratorFactory::SERVICE_NAME => static function (
|
|
|
|
MediaWikiServices $services
|
|
|
|
): VariableGeneratorFactory {
|
2021-01-03 13:10:20 +00:00
|
|
|
return new VariableGeneratorFactory(
|
2021-01-09 13:40:10 +00:00
|
|
|
$services->get( AbuseFilterHookRunner::SERVICE_NAME ),
|
2021-01-03 13:10:20 +00:00
|
|
|
$services->get( TextExtractor::SERVICE_NAME ),
|
|
|
|
$services->getMimeAnalyzer(),
|
2021-08-29 09:08:24 +00:00
|
|
|
$services->getRepoGroup(),
|
2024-02-27 17:25:35 +00:00
|
|
|
$services->getWikiPageFactory(),
|
|
|
|
$services->getUserFactory()
|
2021-01-03 13:10:20 +00:00
|
|
|
);
|
|
|
|
},
|
2021-04-30 18:54:17 +00:00
|
|
|
EditRevUpdater::SERVICE_NAME => static function ( MediaWikiServices $services ): EditRevUpdater {
|
2021-01-05 13:33:45 +00:00
|
|
|
return new EditRevUpdater(
|
|
|
|
$services->get( CentralDBManager::SERVICE_NAME ),
|
|
|
|
$services->getRevisionLookup(),
|
2023-02-26 12:51:08 +00:00
|
|
|
$services->getDBLoadBalancerFactory(),
|
2021-01-05 13:33:45 +00:00
|
|
|
WikiMap::getCurrentWikiDbDomain()->getId()
|
|
|
|
);
|
|
|
|
},
|
2018-03-08 21:16:25 +00:00
|
|
|
AbuseFilterActorMigration::SERVICE_NAME => static function (
|
|
|
|
MediaWikiServices $services
|
|
|
|
): AbuseFilterActorMigration {
|
|
|
|
return new AbuseFilterActorMigration(
|
2024-06-06 08:03:15 +00:00
|
|
|
SCHEMA_COMPAT_NEW,
|
2018-03-08 21:16:25 +00:00
|
|
|
$services->getActorStoreFactory(),
|
|
|
|
);
|
|
|
|
},
|
2023-05-24 20:09:59 +00:00
|
|
|
BlockedDomainStorage::SERVICE_NAME => static function (
|
|
|
|
MediaWikiServices $services
|
|
|
|
): BlockedDomainStorage {
|
|
|
|
return new BlockedDomainStorage(
|
|
|
|
$services->getLocalServerObjectCache(),
|
|
|
|
$services->getRevisionLookup(),
|
|
|
|
$services->getUserFactory(),
|
|
|
|
$services->getWikiPageFactory(),
|
|
|
|
$services->getUrlUtils()
|
|
|
|
);
|
|
|
|
},
|
2023-08-06 11:44:16 +00:00
|
|
|
BlockedDomainFilter::SERVICE_NAME => static function (
|
|
|
|
MediaWikiServices $services
|
|
|
|
): BlockedDomainFilter {
|
|
|
|
return new BlockedDomainFilter(
|
|
|
|
$services->get( VariablesManager::SERVICE_NAME ),
|
|
|
|
$services->get( BlockedDomainStorage::SERVICE_NAME )
|
|
|
|
);
|
|
|
|
},
|
2023-03-27 16:43:06 +00:00
|
|
|
// b/c for extensions
|
|
|
|
'AbuseFilterRunnerFactory' => static function ( MediaWikiServices $services ): FilterRunnerFactory {
|
|
|
|
return $services->get( FilterRunnerFactory::SERVICE_NAME );
|
|
|
|
},
|
2020-01-15 16:08:53 +00:00
|
|
|
];
|
2020-11-19 17:49:55 +00:00
|
|
|
|
|
|
|
// @codeCoverageIgnoreEnd
|