Gergő Tisza has uploaded a new change for review.

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

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

Handle the UserIsBot hook for bot detection

(This won't do anything useful in 1.27 but does no harm and makes other patches 
merge cleanly.)

Change-Id: Icad898198bef37c1bc7d3d0be9e8f3c9c1527bb6
(cherry picked from commit ef713969aa36cec71d54f651fd5226fd74f68ead)
---
M CentralAuth.php
M includes/CentralAuthHooks.php
2 files changed, 21 insertions(+), 0 deletions(-)


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

diff --git a/CentralAuth.php b/CentralAuth.php
index 77b36d9..d5783ac 100644
--- a/CentralAuth.php
+++ b/CentralAuth.php
@@ -395,6 +395,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 5eb20fc..b806190 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -922,6 +922,26 @@
        }
 
        /**
+        * @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()
+                               && array_intersect( [ 'bot', 'global-bot' ], 
$centralUser->getGlobalGroups() )
+                               && in_array( 'bot', 
$centralUser->getGlobalRights() )
+                       ) {
+                               $isBot = true;
+                       }
+               }
+
+               return true;
+       }
+
+       /**
         * @param integer $id User ID
         * @param User $user
         * @param SpecialPage $sp

-- 
To view, visit https://gerrit.wikimedia.org/r/297554
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: REL1_27
Gerrit-Owner: GergÅ‘ Tisza <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to