Merge "Revert "Split editcascadeprotected permission from protect permission""
[lhc/web/wiklou.git] / includes / user / User.php
index 7c32c3b..b1c270f 100644 (file)
@@ -127,6 +127,7 @@ class User implements IDBAccessObject {
                'createpage',
                'createtalk',
                'delete',
+               'deletechangetags',
                'deletedhistory',
                'deletedtext',
                'deletelogentry',
@@ -475,7 +476,7 @@ class User implements IDBAccessObject {
         */
        protected static function getInProcessCache() {
                if ( !self::$inProcessCache ) {
-                       self::$inProcessCache = new HashBagOStuff( ['maxKeys' => 10] );
+                       self::$inProcessCache = new HashBagOStuff( [ 'maxKeys' => 10 ] );
                }
                return self::$inProcessCache;
        }
@@ -2489,9 +2490,9 @@ class User implements IDBAccessObject {
                        throw new PasswordError( wfMessage( 'externaldberror' )->text() );
                }
 
-               $this->setToken();
                $this->setOption( 'watchlisttoken', false );
                $this->setPasswordInternal( $str );
+               SessionManager::singleton()->invalidateSessionsForUser( $this );
 
                return true;
        }
@@ -2508,9 +2509,9 @@ class User implements IDBAccessObject {
                global $wgAuth;
 
                if ( $wgAuth->allowSetLocalPassword() ) {
-                       $this->setToken();
                        $this->setOption( 'watchlisttoken', false );
                        $this->setPasswordInternal( $str );
+                       SessionManager::singleton()->invalidateSessionsForUser( $this );
                }
        }
 
@@ -3398,6 +3399,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
         *
@@ -3500,7 +3514,7 @@ class User implements IDBAccessObject {
         */
        public function isWatched( $title, $checkRights = self::CHECK_USER_RIGHTS ) {
                if ( $title->isWatchable() && ( !$checkRights || $this->isAllowed( 'viewmywatchlist' ) ) ) {
-                       return WatchedItemStore::getDefaultInstance()->isWatched( $this, $title );
+                       return MediaWikiServices::getInstance()->getWatchedItemStore()->isWatched( $this, $title );
                }
                return false;
        }
@@ -3514,7 +3528,7 @@ class User implements IDBAccessObject {
         */
        public function addWatch( $title, $checkRights = self::CHECK_USER_RIGHTS ) {
                if ( !$checkRights || $this->isAllowed( 'editmywatchlist' ) ) {
-                       WatchedItemStore::getDefaultInstance()->addWatchBatchForUser(
+                       MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
                                $this,
                                [ $title->getSubjectPage(), $title->getTalkPage() ]
                        );
@@ -3531,8 +3545,9 @@ class User implements IDBAccessObject {
         */
        public function removeWatch( $title, $checkRights = self::CHECK_USER_RIGHTS ) {
                if ( !$checkRights || $this->isAllowed( 'editmywatchlist' ) ) {
-                       WatchedItemStore::getDefaultInstance()->removeWatch( $this, $title->getSubjectPage() );
-                       WatchedItemStore::getDefaultInstance()->removeWatch( $this, $title->getTalkPage() );
+                       $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+                       $store->removeWatch( $this, $title->getSubjectPage() );
+                       $store->removeWatch( $this, $title->getTalkPage() );
                }
                $this->invalidateCache();
        }
@@ -3601,7 +3616,7 @@ class User implements IDBAccessObject {
                        $force = 'force';
                }
 
-               WatchedItemStore::getDefaultInstance()
+               MediaWikiServices::getInstance()->getWatchedItemStore()
                        ->resetNotificationTimestamp( $this, $title, $force, $oldid );
        }