mediawiki-extensions-AbuseF.../hooks.txt
Daimona Eaytoy 55ba083b13 Introduce a KeywordsManager service
This will decouple a bit the huge and chaotic tangle of AF classes. Some
boilerplate code for AbuseFilter services is also added with this patch.

Note that this requires injecting a KeywordsManager in
AbuseFilterVariableHolder, or unit tests would fail. This is still
incomplete, and the Manager is only injected in tests, because
VariableHolder still has to be refactored.

The test for the UpdateVarDumps script had to be updated, because
serializing VHs in there was a bad choice. As pointed out in a comment,
the test is likely going to break again once we remove the BC code, but
I hope that we'll be able to remove the test at that point.

Change-Id: I12a656a310adb8c5f75cab63f6db9e121e109717
2020-09-28 23:03:52 +00:00

73 lines
3.8 KiB
Plaintext

This document describes how event hooks work in the AbuseFilter extension.
For a more comprehensive guide to hooks, navigate to your root MediaWiki
directory and read docs/hooks.txt.
== Events and parameters ==
This is a list of known events and parameters; please add to it if you're going
to add events to the AbuseFilter extension.
'AbuseFilter-builder': Allows overwriting of the builder values, i.e. names and descriptions of
the AbuseFilter language like variables.
&$realValues: Builder values
'AbuseFilter-deprecatedVariables': Allows adding deprecated variables. If a filter uses an old variable, the parser
will automatically translate it to the new one.
&$deprecatedVariables: array of deprecated variables, syntax: [ 'old_name' => 'new_name' ]
'AbuseFilter-computeVariable': Like AbuseFilter-interceptVariable but called if the requested method wasn't found.
Return true to indicate that the method is known to the hook and was computed successful.
$method: Method to generate the variable
$vars: AbuseFilterVariableHolder
$parameters: Parameters with data to compute the value
&$result: Result of the computation
'AbuseFilter-contentToString': Called when converting a Content object to a string to which
filters can be applied. If the hook function returns true, Content::getTextForSearchIndex()
will be used for non-text content.
$content: The Content object
&$text: Set this to the desired text.
'AbuseFilter-filterAction': DEPRECATED! Use AbuseFilterAlterVariables instead.
Allows overwriting of abusefilter variables in AbuseFilter::filterAction just before they're
checked against filters. Note that you may specify custom variables in a saner way using other hooks:
AbuseFilter-generateTitleVars, AbuseFilter-generateUserVars and AbuseFilter-generateGenericVars.
$vars: AbuseFilterVariableHolder with variables
$title: Title object
'AbuseFilterAlterVariables': Allows overwriting of abusefilter variables just before they're
checked against filters. Note that you may specify custom variables in a saner way using other hooks:
AbuseFilter-generateTitleVars, AbuseFilter-generateUserVars and AbuseFilter-generateGenericVars.
$vars: AbuseFilterVariableHolder with variables
$title: Title object target of the action
$user: User object performer of the action
'AbuseFilter-generateTitleVars': Allows altering the variables generated for a title
$vars: AbuseFilterVariableHolder
$title: Title object
$prefix: Variable name prefix
$rc: RecentChange|null If the variables should be generated for an RC entry, this is the entry. Null if it's for the current action being filtered.
'AbuseFilter-generateUserVars': Allows altering the variables generated for a specific user
$vars: AbuseFilterVariableHolder
$user: User object
$rc: RecentChange|null If the variables should be generated for an RC entry, this is the entry. Null if it's for the current action being filtered.
'AbuseFilter-generateGenericVars': Allows altering generic variables, i.e. independent from page and user
$vars: AbuseFilterVariableHolder
$rc: RecentChange|null If the variables should be generated for an RC entry, this is the entry. Null if it's for the current action being filtered.
'AbuseFilter-interceptVariable': Called before a variable is set in AFComputedVariable::compute to be able to set
it before the core code runs. Return false to make the function return right after.
$method: Method to generate the variable
$vars: AbuseFilterVariableHolder
$parameters: Parameters with data to compute the value
&$result: Result of the computation
'AbuseFilterShouldFilterAction': Called before filtering an action. If the current action should not be filtered,
return false and add a useful reason to $skipReasons.
$vars: AbuseFilterVariableHolder
$title: Title object target of the action
$user: User object performer of the action
&$skipReasons: Array of reasons why the action should be skipped