Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/288140

Change subject: Handle the UserIsBot hook for bot detection
......................................................................

Handle the UserIsBot hook for bot detection

Change-Id: Icad898198bef37c1bc7d3d0be9e8f3c9c1527bb6
---
M CentralAuth.php
M includes/CentralAuthHooks.php
2 files changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/40/288140/1

diff --git a/CentralAuth.php b/CentralAuth.php
index a3b849a..8d38837 100644
--- a/CentralAuth.php
+++ b/CentralAuth.php
@@ -396,6 +396,7 @@
 $wgHooks['UserSaveSettings'][] = 'CentralAuthHooks::onUserSaveSettings';
 $wgHooks['UserSetEmailAuthenticationTimestamp'][] = 
'CentralAuthHooks::onUserSetEmailAuthenticationTimestamp';
 $wgHooks['UserGetRights'][] = 'CentralAuthHooks::onUserGetRights';
+$wgHooks['UserIsBot'][] = 'CentralAuthHooks::onUserIsBot';
 $wgHooks['getUserPermissionsErrorsExpensive'][] = 
'CentralAuthHooks::onGetUserPermissionsErrorsExpensive';
 $wgHooks['MakeGlobalVariablesScript'][] = 
'CentralAuthHooks::onMakeGlobalVariablesScript';
 $wgHooks['SpecialPasswordResetOnSubmit'][] = 
'CentralAuthHooks::onSpecialPasswordResetOnSubmit';
diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index 6e8d9d0..ca6c0c2 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -922,6 +922,25 @@
        }
 
        /**
+        * @param User $user
+        * @param bool &$isBot
+        * @return bool
+        */
+       static function onUserIsBot( User $user, &$isBot ) {
+               if ( !$user->isAnon() ) {
+                       $centralUser = CentralAuthUser::getInstance( $user );
+                       if ( $centralUser->exists()
+                               && $centralUser->isAttached()
+                               && in_array( 'bot', 
$centralUser->getGlobalGroups() )
+                       ) {
+                               $isBot = true;
+                       }
+               }
+
+               return true;
+       }
+
+       /**
         * @param integer $id User ID
         * @param User $user
         * @param SpecialPage $sp

-- 
To view, visit https://gerrit.wikimedia.org/r/288140
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icad898198bef37c1bc7d3d0be9e8f3c9c1527bb6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to