Merge "Add User::isBot() method"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 11 May 2016 00:59:53 +0000 (00:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 11 May 2016 00:59:53 +0000 (00:59 +0000)
RELEASE-NOTES-1.28
docs/hooks.txt
includes/user/User.php

index c950921..e365486 100644 (file)
@@ -11,6 +11,8 @@ production.
   user's language. If such access is attempted, an exception will be thrown.
 
 === New features in 1.28 ===
+* User::isBot() method for checking if an account is a bot role account.
+* Added a new hook, 'UserIsBot', to aid in determining if a user is a bot.
 
 
 === External library changes in 1.28 ===
index a7092ec..726500c 100644 (file)
@@ -3216,6 +3216,10 @@ $mime: (string) The uploaded file's MIME type, as detected by MediaWiki.
   representing the problem with the file, where the first element is the message
   key and the remaining elements are used as parameters to the message.
 
+'UserIsBot': when determining whether a user is a bot account
+$user: the user
+&$isBot: whether this is user a bot or not (boolean)
+
 'User::mailPasswordInternal': before creation and mailing of a user's new
 temporary password
 &$user: the user who sent the message out
index ee617a2..6ecd6b7 100644 (file)
@@ -3398,6 +3398,19 @@ class User implements IDBAccessObject {
                return !$this->isLoggedIn();
        }
 
+       /**
+        * @return bool Whether this user is flagged as being a bot role account
+        * @since 1.28
+        */
+       public function isBot() {
+               $isBot = false;
+               if ( !Hooks::run( "UserIsBot", [ $this, &$isBot ] ) ) {
+                       return $isBot;
+               }
+
+               return ( $isBot || in_array( 'bot', $this->getGroups() ) );
+       }
+
        /**
         * Check if user is allowed to access a feature / make an action
         *