Matěj Suchánek has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/341368 )
Change subject: Add an AbuseFilter variable for global edit count of the user
......................................................................
Add an AbuseFilter variable for global edit count of the user
Bug: T130439
Change-Id: I7de1cdc2e291d4b411ef948b016caca142a811ae
---
M i18n/en.json
M i18n/qqq.json
M includes/CentralAuthHooks.php
3 files changed, 16 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth
refs/changes/68/341368/2
diff --git a/i18n/en.json b/i18n/en.json
index 9839cab..fb24dab 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -345,6 +345,7 @@
"right-centralauth-merge": "Merge their account",
"right-globalgrouppermissions": "Manage global groups",
"abusefilter-edit-builder-vars-global-user-groups": "Global groups that
the user is in",
+ "abusefilter-edit-builder-vars-global-user-editcount": "Global edit
count of the user",
"action-centralauth-unmerge": "unmerge global accounts",
"action-centralauth-lock": "lock or unlock global accounts",
"centrallogin": "Central user log in",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index de3dfb0..a898ec5 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -361,6 +361,7 @@
"right-centralauth-merge":
"{{doc-right|centralauth-merge}}\n\n{{doc-singularthey}}\n\nThis user right
allows the user to use [[Special:MergeAccount]] to merge his/her own account
with accounts on other projects.",
"right-globalgrouppermissions": "{{doc-right|globalgrouppermissions}}",
"abusefilter-edit-builder-vars-global-user-groups": "Global groups that
the user is in. Abuse filter syntax option in a dropdown from the group
{{msg-mw|Abusefilter-edit-builder-group-vars}}.\n\nSee also:\n*
{{msg-mw|Abusefilter-edit-builder-vars-user-groups}}.",
+ "abusefilter-edit-builder-vars-global-user-editcount": "Global edit
count of the user. Abuse filter syntax option in a dropdown from the group
{{msg-mw|Abusefilter-edit-builder-group-vars}}.\n\nSee also:\n*
{{msg-mw|Abusefilter-edit-builder-vars-user-editcount}}.",
"action-centralauth-unmerge": "{{Doc-action|centralauth-unmerge}}",
"action-centralauth-lock": "{{Doc-action|centralauth-lock}}",
"centrallogin": "{{doc-special|CentralLogin|unlisted=1}}",
diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index 4ad2d8a..2fb184a 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -1203,7 +1203,7 @@
}
/**
- * Computes the global_user_groups variable
+ * Computes the global_user_groups and global_user_editcount variables
* @param string $method
* @param AbuseFilterVariableHolder $vars
* @param array $parameters
@@ -1219,30 +1219,41 @@
$result = array();
}
return false;
+ } elseif ( $method == 'global-user-editcount' ) {
+ $user = CentralAuthUser::getInstance(
$parameters['user'] );
+ if ( $user->exists() && $user->isAttached() ) {
+ $result = $user->getGlobalEditCount();
+ } else {
+ $result = 0;
+ }
+ return false;
} else {
return true;
}
}
/**
- * Load our global_user_groups variable
+ * Load our global_user_groups and global_user_editcount variables
* @param AbuseFilterVariableHolder $vars
* @param User $user
* @return bool
*/
static function abuseFilterGenerateUserVars( $vars, $user ) {
$vars->setLazyLoadVar( 'global_user_groups',
'global-user-groups', array( 'user' => $user ) );
+ $vars->setLazyLoadVar( 'global_user_editcount',
'global-user-editcount', array( 'user' => $user ) );
return true;
}
/**
- * Tell AbuseFilter about our global_user_groups variable
+ * Tell AbuseFilter about our global_user_groups and
global_user_editcount variables
* @param array &$builderValues
* @return bool
*/
static function abuseFilterBuilder( &$builderValues ) {
// Uses: 'abusefilter-edit-builder-vars-global-user-groups'
$builderValues['vars']['global_user_groups'] =
'global-user-groups';
+ // Uses: 'abusefilter-edit-builder-vars-global-user-editcount'
+ $builderValues['vars']['global_user_editcount'] =
'global-user-editcount';
return true;
}
--
To view, visit https://gerrit.wikimedia.org/r/341368
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7de1cdc2e291d4b411ef948b016caca142a811ae
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits