Merge "Add new rules when user is blocked for UTP"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 11 Dec 2018 13:18:14 +0000 (13:18 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 11 Dec 2018 13:18:14 +0000 (13:18 +0000)
1  2 
includes/user/User.php

diff --combined includes/user/User.php
@@@ -55,6 -55,13 +55,6 @@@ class User implements IDBAccessObject, 
         */
        const INVALID_TOKEN = '*** INVALID ***';
  
 -      /**
 -       * Global constant made accessible as class constants so that autoloader
 -       * magic can be used.
 -       * @deprecated since 1.27, use \MediaWiki\Session\Token::SUFFIX
 -       */
 -      const EDIT_TOKEN_SUFFIX = Token::SUFFIX;
 -
        /**
         * @const int Serialized record version.
         */
        private function getBlockedStatus( $bFromReplica = true ) {
                global $wgProxyWhitelist, $wgUser, $wgApplyIpBlocksToXff, $wgSoftBlockRanges;
  
 -              if ( -1 != $this->mBlockedby ) {
 +              if ( $this->mBlockedby != -1 ) {
                        return;
                }
  
                                        if ( $block->isSitewide() ) {
                                                $blocked = $block->prevents( 'editownusertalk' );
                                        } else {
-                                               // If the block is partial, then only a true value is honored,
-                                               // otherwise fallback to the partial block settings.
-                                               $blocked = $block->prevents( 'editownusertalk' ) ?: $block->appliesToTitle( $title );
+                                               // If the block is partial, ignore 'editownusertalk' unless
+                                               // there is a restriction on the user talk namespace.
+                                               // TODO: To be implemented with Namespace restrictions
+                                               $blocked = $block->appliesToTitle( $title );
                                        }
                                } else {
                                        $blocked = $block->appliesToTitle( $title );
                                        $this->mActorId = (int)$dbw->insertId();
                                } else {
                                        // Outdated cache?
 -                                      list( , $options ) = DBAccessObjectUtils::getDBOptions( $this->queryFlagsUsed );
 -                                      $this->mActorId = (int)$dbw->selectField( 'actor', 'actor_id', $q, __METHOD__, $options );
 +                                      // Use LOCK IN SHARE MODE to bypass any MySQL REPEATABLE-READ snapshot.
 +                                      $this->mActorId = (int)$dbw->selectField(
 +                                              'actor',
 +                                              'actor_id',
 +                                              $q,
 +                                              __METHOD__,
 +                                              [ 'LOCK IN SHARE MODE' ]
 +                                      );
                                        if ( !$this->mActorId ) {
                                                throw new CannotCreateActorException(
                                                        "Cannot create actor ID for user_id={$this->getId()} user_name={$this->getName()}"
         */
        public function setCookies( $request = null, $secure = null, $rememberMe = false ) {
                $this->load();
 -              if ( 0 == $this->mId ) {
 +              if ( $this->mId == 0 ) {
                        return;
                }
  
                }
  
                $this->load();
 -              if ( 0 == $this->mId ) {
 +              if ( $this->mId == 0 ) {
                        return; // anon
                }