From 85b46268f2b598d7f9fc3b28fb6cc9208cb3b4c9 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Sun, 27 Jan 2019 11:23:13 +0100 Subject: [PATCH] Rename the filterAction hook and add a parameter The 'AbuseFilter-filterAction' hook is deprecated in favour of a new 'AbuseFilterAlterVariables' hook, which provides a User object and has a better name, since it reflects what it should be used for, and doesn't include the name of a function which will be removed. The hook will be hard deprecated in a subsequent patch, to avoid test failures. Depends-On: Ic0ecc8746e2883c746bef815a0fee4131f1a0646 Change-Id: I212b1e09e9c05d487d96b2f4c28f2a613e6ff3cf --- hooks.txt | 12 ++++++++++-- includes/AbuseFilter.php | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hooks.txt b/hooks.txt index d2b2c5ba4..6380fded9 100644 --- a/hooks.txt +++ b/hooks.txt @@ -27,12 +27,20 @@ will be used for non-text content. $content: The Content object &$text: Set this to the desired text. -'AbuseFilter-filterAction': 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-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-generateStaticVars. $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-generateStaticVars. +$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 diff --git a/includes/AbuseFilter.php b/includes/AbuseFilter.php index e80563772..0e992b231 100644 --- a/includes/AbuseFilter.php +++ b/includes/AbuseFilter.php @@ -1158,6 +1158,7 @@ class AbuseFilter { // Add vars from extensions Hooks::run( 'AbuseFilter-filterAction', [ &$vars, $title ] ); + Hooks::run( 'AbuseFilterAlterVariables', [ &$vars, $title, $user ] ); $vars->addHolders( self::generateStaticVars() ); $vars->forFilter = true;