Remove reference to deprecated IDatabase->nextSequenceValue()
[lhc/web/wiklou.git] / includes / user / User.php
index 52c14f7..8506846 100644 (file)
@@ -302,15 +302,9 @@ class User implements IDBAccessObject {
        /** @var Block */
        private $mBlockedFromCreateAccount = false;
 
-       /** @var integer User::READ_* constant bitfield used to load data */
+       /** @var int User::READ_* constant bitfield used to load data */
        protected $queryFlagsUsed = self::READ_NORMAL;
 
-       /** @var string Indicates type of block (used for eventlogging)
-        * Permitted values: 'cookie-block', 'proxy-block', 'openproxy-block', 'xff-block',
-        * 'config-block'
-        */
-       public $blockTrigger = false;
-
        public static $idCacheByName = [];
 
        /**
@@ -363,7 +357,7 @@ class User implements IDBAccessObject {
        /**
         * Load the user table data for this object from the source given by mFrom.
         *
-        * @param integer $flags User::READ_* constant bitfield
+        * @param int $flags User::READ_* constant bitfield
         */
        public function load( $flags = self::READ_NORMAL ) {
                global $wgFullyInitialised;
@@ -425,7 +419,7 @@ class User implements IDBAccessObject {
 
        /**
         * Load user table data, given mId has already been set.
-        * @param integer $flags User::READ_* constant bitfield
+        * @param int $flags User::READ_* constant bitfield
         * @return bool False if the ID does not exist, true otherwise
         */
        public function loadFromId( $flags = self::READ_NORMAL ) {
@@ -456,7 +450,7 @@ class User implements IDBAccessObject {
        /**
         * @since 1.27
         * @param string $wikiId
-        * @param integer $userId
+        * @param int $userId
         */
        public static function purge( $wikiId, $userId ) {
                $cache = ObjectCache::getMainWANInstance();
@@ -609,7 +603,7 @@ class User implements IDBAccessObject {
                        ]
                );
 
-               return $id ? User::newFromId( $id ) : null;
+               return $id ? self::newFromId( $id ) : null;
        }
 
        /**
@@ -765,7 +759,7 @@ class User implements IDBAccessObject {
        /**
         * Get database id given a user name
         * @param string $name Username
-        * @param integer $flags User::READ_* constant bitfield
+        * @param int $flags User::READ_* constant bitfield
         * @return int|null The corresponding user's ID, or null if user is nonexistent
         */
        public static function idFromName( $name, $flags = self::READ_NORMAL ) {
@@ -848,7 +842,7 @@ class User implements IDBAccessObject {
                global $wgContLang, $wgMaxNameChars;
 
                if ( $name == ''
-                       || User::isIP( $name )
+                       || self::isIP( $name )
                        || strpos( $name, '/' ) !== false
                        || strlen( $name ) > $wgMaxNameChars
                        || $name != $wgContLang->ucfirst( $name )
@@ -1115,17 +1109,17 @@ class User implements IDBAccessObject {
                        case false:
                                break;
                        case 'valid':
-                               if ( !User::isValidUserName( $name ) ) {
+                               if ( !self::isValidUserName( $name ) ) {
                                        $name = false;
                                }
                                break;
                        case 'usable':
-                               if ( !User::isUsableName( $name ) ) {
+                               if ( !self::isUsableName( $name ) ) {
                                        $name = false;
                                }
                                break;
                        case 'creatable':
-                               if ( !User::isCreatableName( $name ) ) {
+                               if ( !self::isCreatableName( $name ) ) {
                                        $name = false;
                                }
                                break;
@@ -1258,7 +1252,7 @@ class User implements IDBAccessObject {
         * Load user and user_group data from the database.
         * $this->mId must be set, this is how the user is identified.
         *
-        * @param integer $flags User::READ_* constant bitfield
+        * @param int $flags User::READ_* constant bitfield
         * @return bool True if the user exists, false if the user is anonymous
         */
        public function loadFromDatabase( $flags = self::READ_LATEST ) {
@@ -1597,7 +1591,7 @@ class User implements IDBAccessObject {
                // since extensions may change the set of searchable namespaces depending
                // on user groups/permissions.
                foreach ( $wgNamespacesToBeSearchedDefault as $nsnum => $val ) {
-                       $defOpt['searchNs' . $nsnum] = (boolean)$val;
+                       $defOpt['searchNs' . $nsnum] = (bool)$val;
                }
                $defOpt['skin'] = Skin::normalizeKey( $wgDefaultSkin );
 
@@ -1676,7 +1670,6 @@ class User implements IDBAccessObject {
                                        'address' => $ip,
                                        'systemBlock' => 'proxy',
                                ] );
-                               $this->blockTrigger = 'proxy-block';
                        } elseif ( $this->isAnon() && $this->isDnsBlacklisted( $ip ) ) {
                                $block = new Block( [
                                        'byText' => wfMessage( 'sorbs' )->text(),
@@ -1684,7 +1677,6 @@ class User implements IDBAccessObject {
                                        'address' => $ip,
                                        'systemBlock' => 'dnsbl',
                                ] );
-                               $this->blockTrigger = 'openproxy-block';
                        }
                }
 
@@ -1703,7 +1695,6 @@ class User implements IDBAccessObject {
                                # Mangle the reason to alert the user that the block
                                # originated from matching the X-Forwarded-For header.
                                $block->mReason = wfMessage( 'xffblockreason', $block->mReason )->text();
-                               $this->blockTrigger = 'xff-block';
                        }
                }
 
@@ -1719,7 +1710,6 @@ class User implements IDBAccessObject {
                                'anonOnly' => true,
                                'systemBlock' => 'wgSoftBlockRanges',
                        ] );
-                       $this->blockTrigger = 'config-block';
                }
 
                if ( $block instanceof Block ) {
@@ -1733,7 +1723,6 @@ class User implements IDBAccessObject {
                        $this->mBlockedby = '';
                        $this->mHideName = 0;
                        $this->mAllowUsertalk = false;
-                       $this->blockTrigger = false;
                }
 
                // Avoid PHP 7.1 warning of passing $this by reference
@@ -1766,7 +1755,6 @@ class User implements IDBAccessObject {
                                $useBlockCookie = ( $config->get( 'CookieSetOnAutoblock' ) === true );
                                if ( $blockIsValid && $useBlockCookie ) {
                                        // Use the block.
-                                       $this->blockTrigger = 'cookie-block';
                                        return $tmpBlock;
                                } else {
                                        // If the block is not valid, remove the cookie.
@@ -2224,7 +2212,7 @@ class User implements IDBAccessObject {
         * @return int The user's ID; 0 if the user is anonymous or nonexistent
         */
        public function getId() {
-               if ( $this->mId === null && $this->mName !== null && User::isIP( $this->mName ) ) {
+               if ( $this->mId === null && $this->mName !== null && self::isIP( $this->mName ) ) {
                        // Special case, we know the user is anonymous
                        return 0;
                } elseif ( !$this->isItemLoaded( 'id' ) ) {
@@ -3531,7 +3519,7 @@ class User implements IDBAccessObject {
        /**
         * Check if user is allowed to access a feature / make an action
         *
-        * @param string ... Permissions to test
+        * @param string $permissions,... Permissions to test
         * @return bool True if user is allowed to perform *any* of the given actions
         */
        public function isAllowedAny() {
@@ -3546,7 +3534,7 @@ class User implements IDBAccessObject {
 
        /**
         *
-        * @param string ... Permissions to test
+        * @param string $permissions,... Permissions to test
         * @return bool True if the user is allowed to perform *all* of the given actions
         */
        public function isAllowedAll() {
@@ -3673,7 +3661,7 @@ class User implements IDBAccessObject {
         * If e-notif e-mails are on, they will receive notification mails on
         * the next change of the page if it's watched etc.
         * @note If the user doesn't have 'editmywatchlist', this will do nothing.
-        * @param Title $title Title of the article to look at
+        * @param Title &$title Title of the article to look at
         * @param int $oldid The revision id being viewed. If not given or 0, latest revision is assumed.
         */
        public function clearNotification( &$title, $oldid = 0 ) {
@@ -4121,12 +4109,10 @@ class User implements IDBAccessObject {
                        unset( $params['options'] );
                }
                $dbw = wfGetDB( DB_MASTER );
-               $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
 
                $noPass = PasswordFactory::newInvalidPassword()->toString();
 
                $fields = [
-                       'user_id' => $seqVal,
                        'user_name' => $name,
                        'user_password' => $noPass,
                        'user_newpassword' => $noPass,
@@ -4143,7 +4129,7 @@ class User implements IDBAccessObject {
                }
                $dbw->insert( 'user', $fields, __METHOD__, [ 'IGNORE' ] );
                if ( $dbw->affectedRows() ) {
-                       $newUser = User::newFromId( $dbw->insertId() );
+                       $newUser = self::newFromId( $dbw->insertId() );
                } else {
                        $newUser = null;
                }
@@ -4191,10 +4177,8 @@ class User implements IDBAccessObject {
                $noPass = PasswordFactory::newInvalidPassword()->toString();
 
                $dbw = wfGetDB( DB_MASTER );
-               $seqVal = $dbw->nextSequenceValue( 'user_user_id_seq' );
                $dbw->insert( 'user',
                        [
-                               'user_id' => $seqVal,
                                'user_name' => $this->mName,
                                'user_password' => $noPass,
                                'user_newpassword' => $noPass,
@@ -4957,7 +4941,8 @@ class User implements IDBAccessObject {
                }
                $title = UserGroupMembership::getGroupPage( $group );
                if ( $title ) {
-                       return Linker::link( $title, htmlspecialchars( $text ) );
+                       return MediaWikiServices::getInstance()
+                               ->getLinkRenderer()->makeLink( $title, $text );
                } else {
                        return htmlspecialchars( $text );
                }
@@ -5047,7 +5032,7 @@ class User implements IDBAccessObject {
                        // Do nothing
                } elseif ( $wgGroupsAddToSelf[$group] === true ) {
                        // No idea WHY this would be used, but it's there
-                       $groups['add-self'] = User::getAllGroups();
+                       $groups['add-self'] = self::getAllGroups();
                } elseif ( is_array( $wgGroupsAddToSelf[$group] ) ) {
                        $groups['add-self'] = $wgGroupsAddToSelf[$group];
                }
@@ -5055,7 +5040,7 @@ class User implements IDBAccessObject {
                if ( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
                        // Do nothing
                } elseif ( $wgGroupsRemoveFromSelf[$group] === true ) {
-                       $groups['remove-self'] = User::getAllGroups();
+                       $groups['remove-self'] = self::getAllGroups();
                } elseif ( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
                        $groups['remove-self'] = $wgGroupsRemoveFromSelf[$group];
                }
@@ -5076,7 +5061,7 @@ class User implements IDBAccessObject {
                        // compatibility with old "userrights lets you change
                        // everything")
                        // Using array_merge to make the groups reindexed
-                       $all = array_merge( User::getAllGroups() );
+                       $all = array_merge( self::getAllGroups() );
                        return [
                                'add' => $all,
                                'remove' => $all,
@@ -5502,7 +5487,7 @@ class User implements IDBAccessObject {
                global $wgLang;
 
                $groups = [];
-               foreach ( User::getGroupsWithPermission( $permission ) as $group ) {
+               foreach ( self::getGroupsWithPermission( $permission ) as $group ) {
                        $groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(), 'wiki' );
                }