Make User::isBot() also check the "bot" right for sanity
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 12 May 2016 20:02:41 +0000 (13:02 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 12 May 2016 23:03:44 +0000 (16:03 -0700)
Change-Id: I835cc23719c1975bb86f642d3ede36c882ce2e9b

includes/user/User.php

index 3d7d71c..b62d252 100644 (file)
@@ -3403,12 +3403,14 @@ class User implements IDBAccessObject {
         * @since 1.28
         */
        public function isBot() {
-               $isBot = false;
-               if ( !Hooks::run( "UserIsBot", [ $this, &$isBot ] ) ) {
-                       return $isBot;
+               if ( in_array( 'bot', $this->getGroups() ) && $this->isAllowed( 'bot' ) ) {
+                       return true;
                }
 
-               return ( $isBot || in_array( 'bot', $this->getGroups() ) );
+               $isBot = false;
+               Hooks::run( "UserIsBot", [ $this, &$isBot ] );
+
+               return $isBot;
        }
 
        /**