mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-23 21:53:35 +00:00
Inject ChangeTagsManager to ChangeTagger
We decided to have the tag name provided by ChangeTagsManager, so make ChangeTagger depend on it. Change-Id: If3cbfd992f45651f47477031befffc0fd30f4a28
This commit is contained in:
parent
85e000c6ed
commit
93556284a0
|
@ -17,6 +17,18 @@ class ChangeTagger {
|
|||
/** @var array (Persistent) map of (action ID => string[]) */
|
||||
private static $tagsToSet = [];
|
||||
|
||||
/**
|
||||
* @var ChangeTagsManager
|
||||
*/
|
||||
private $changeTagsManager;
|
||||
|
||||
/**
|
||||
* @param ChangeTagsManager $changeTagsManager
|
||||
*/
|
||||
public function __construct( ChangeTagsManager $changeTagsManager ) {
|
||||
$this->changeTagsManager = $changeTagsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear any buffered tag
|
||||
*/
|
||||
|
@ -29,7 +41,7 @@ class ChangeTagger {
|
|||
* @phan-param array{action:string,username:string,target:LinkTarget,accountname?:?string} $actionSpecs
|
||||
*/
|
||||
public function addConditionsLimitTag( array $actionSpecs ) : void {
|
||||
$this->addTags( $actionSpecs, [ 'abusefilter-condition-limit' ] );
|
||||
$this->addTags( $actionSpecs, [ $this->changeTagsManager->getCondsLimitTag() ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,7 +32,9 @@ return [
|
|||
return new PermManager( $services->getPermissionManager() );
|
||||
},
|
||||
ChangeTagger::SERVICE_NAME => function ( MediaWikiServices $services ) : ChangeTagger {
|
||||
return new ChangeTagger();
|
||||
return new ChangeTagger(
|
||||
$services->getService( ChangeTagsManager::SERVICE_NAME )
|
||||
);
|
||||
},
|
||||
ChangeTagsManager::SERVICE_NAME => function ( MediaWikiServices $services ): ChangeTagsManager {
|
||||
return new ChangeTagsManager(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\AbuseFilter\ChangeTagger;
|
||||
use MediaWiki\Extension\AbuseFilter\ChangeTagsManager;
|
||||
|
||||
/**
|
||||
* @group Test
|
||||
|
@ -12,7 +13,9 @@ class AbuseFilterChangeTaggerTest extends MediaWikiUnitTestCase {
|
|||
* @return ChangeTagger
|
||||
*/
|
||||
private function getTagger() : ChangeTagger {
|
||||
return new ChangeTagger();
|
||||
$manager = $this->createMock( ChangeTagsManager::class );
|
||||
$manager->method( 'getCondsLimitTag' )->willReturn( 'tag' );
|
||||
return new ChangeTagger( $manager );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue