mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 07:20:08 +00:00
Use HookHandlers for UserMerge hook
Bug: T254306 Depends-On: Ib78dae49854863af1a37a00636737c94694776ae Change-Id: If2bc517fb612199f4d744efbfa261ee5c556b6a5
This commit is contained in:
parent
e80a4337c0
commit
8e6d820154
|
@ -7,6 +7,7 @@ $cfg['directory_list'] = array_merge(
|
|||
[
|
||||
'../../extensions/CheckUser',
|
||||
'../../extensions/Echo',
|
||||
'../../extensions/UserMerge',
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -15,6 +16,7 @@ $cfg['exclude_analysis_directory_list'] = array_merge(
|
|||
[
|
||||
'../../extensions/CheckUser',
|
||||
'../../extensions/Echo',
|
||||
'../../extensions/UserMerge',
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -396,6 +396,12 @@
|
|||
},
|
||||
"Echo": {
|
||||
"class": "MediaWiki\\Extension\\AbuseFilter\\Hooks\\Handlers\\EchoHandler"
|
||||
},
|
||||
"UserMerge": {
|
||||
"class": "MediaWiki\\Extension\\AbuseFilter\\Hooks\\Handlers\\UserMergeHandler",
|
||||
"services": [
|
||||
"MainConfig"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Hooks": {
|
||||
|
@ -418,7 +424,7 @@
|
|||
"CheckUserInsertChangesRow": "CheckUser",
|
||||
"CheckUserInsertPrivateEventRow": "CheckUser",
|
||||
"CheckUserInsertLogEventRow": "CheckUser",
|
||||
"UserMergeAccountFields": "MediaWiki\\Extension\\AbuseFilter\\Hooks\\Handlers\\UserMergeHandler::onUserMergeAccountFields",
|
||||
"UserMergeAccountFields": "UserMerge",
|
||||
"BeforeCreateEchoEvent": "Echo",
|
||||
"ParserOutputStashForEdit": "FilteredActions",
|
||||
"UnitTestsAfterDatabaseSetup": "Tests",
|
||||
|
|
|
@ -2,23 +2,31 @@
|
|||
|
||||
namespace MediaWiki\Extension\AbuseFilter\Hooks\Handlers;
|
||||
|
||||
class UserMergeHandler {
|
||||
use Config;
|
||||
use MediaWiki\Extension\UserMerge\Hooks\AccountFieldsHook;
|
||||
|
||||
class UserMergeHandler implements AccountFieldsHook {
|
||||
|
||||
private Config $config;
|
||||
|
||||
public function __construct( Config $config ) {
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tables that Extension:UserMerge needs to update
|
||||
* @todo Use new hook system once UserMerge is updated
|
||||
*
|
||||
* @param array &$updateFields
|
||||
* @param array[] &$updateFields
|
||||
*/
|
||||
public static function onUserMergeAccountFields( array &$updateFields ) {
|
||||
global $wgAbuseFilterActorTableSchemaMigrationStage;
|
||||
public function onUserMergeAccountFields( array &$updateFields ) {
|
||||
$actorStage = $this->config->get( 'AbuseFilterActorTableSchemaMigrationStage' );
|
||||
$updateFields[] = [
|
||||
'abuse_filter',
|
||||
'af_user',
|
||||
'af_user_text',
|
||||
'batchKey' => 'af_id',
|
||||
'actorId' => 'af_actor',
|
||||
'actorStage' => $wgAbuseFilterActorTableSchemaMigrationStage,
|
||||
'actorStage' => $actorStage,
|
||||
];
|
||||
$updateFields[] = [
|
||||
'abuse_filter_log',
|
||||
|
@ -32,7 +40,7 @@ class UserMergeHandler {
|
|||
'afh_user_text',
|
||||
'batchKey' => 'afh_id',
|
||||
'actorId' => 'afh_actor',
|
||||
'actorStage' => $wgAbuseFilterActorTableSchemaMigrationStage,
|
||||
'actorStage' => $actorStage,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MediaWiki\Extension\AbuseFilter\Tests\Integration;
|
||||
|
||||
use ExtensionRegistry;
|
||||
use MediaWiki\Tests\ExtensionJsonTestBase;
|
||||
|
||||
/**
|
||||
|
@ -14,4 +15,12 @@ class AbuseFilterExtensionJsonTest extends ExtensionJsonTestBase {
|
|||
/** @inheritDoc */
|
||||
protected string $extensionJsonPath = __DIR__ . '/../../../extension.json';
|
||||
|
||||
public function provideHookHandlerNames(): iterable {
|
||||
foreach ( $this->getExtensionJson()['HookHandlers'] ?? [] as $hookHandlerName => $specification ) {
|
||||
if ( $hookHandlerName === 'UserMerge' && !ExtensionRegistry::getInstance()->isLoaded( 'UserMerge' ) ) {
|
||||
continue;
|
||||
}
|
||||
yield [ $hookHandlerName ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue