Merge "Add missing IDatabase type hints to all doAtomicSection() calls"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 30 Apr 2019 17:52:54 +0000 (17:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 30 Apr 2019 17:52:54 +0000 (17:52 +0000)
1  2 
includes/user/User.php

diff --combined includes/user/User.php
@@@ -1372,7 -1372,7 +1372,7 @@@ class User implements IDBAccessObject, 
                $user = $session->getUser();
                if ( $user->isLoggedIn() ) {
                        $this->loadFromUserObject( $user );
 -                      if ( $user->isBlocked() ) {
 +                      if ( $user->getBlock() ) {
                                // If this user is autoblocked, set a cookie to track the Block. This has to be done on
                                // every session load, because an autoblocked editor might not edit again from the same
                                // IP address after being blocked.
        /**
         * Check if user is blocked
         *
 +       * @deprecated since 1.34, use User::getBlock() or
 +       *             PermissionManager::isBlockedFrom() or
 +       *             PermissionManager::userCan() instead.
 +       *
         * @param bool $fromReplica Whether to check the replica DB instead of
         *   the master. Hacked from false due to horrible probs on site.
         * @return bool True if blocked, false otherwise
                        // $user->isAllowed(). It is also checked in Title::checkUserBlock()
                        // to give a better error message in the common case.
                        $config = RequestContext::getMain()->getConfig();
 +                      // @TODO Partial blocks should not prevent the user from logging in.
 +                      //       see: https://phabricator.wikimedia.org/T208895
                        if (
                                $this->isLoggedIn() &&
                                $config->get( 'BlockDisablesLogin' ) &&
 -                              $this->isBlocked()
 +                              $this->getBlock()
                        ) {
                                $anon = new User;
                                $this->mRights = array_intersect( $this->mRights, $anon->getRights() );
                $newTouched = $this->newTouchedTimestamp();
  
                $dbw = wfGetDB( DB_MASTER );
-               $dbw->doAtomicSection( __METHOD__, function ( $dbw, $fname ) use ( $newTouched ) {
+               $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) use ( $newTouched ) {
                        global $wgActorTableSchemaMigrationStage;
  
                        $dbw->update( 'user',
                        $fields["user_$name"] = $value;
                }
  
-               return $dbw->doAtomicSection( __METHOD__, function ( $dbw, $fname ) use ( $fields ) {
+               return $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) use ( $fields ) {
                        $dbw->insert( 'user', $fields, $fname, [ 'IGNORE' ] );
                        if ( $dbw->affectedRows() ) {
                                $newUser = self::newFromId( $dbw->insertId() );
                $this->mTouched = $this->newTouchedTimestamp();
  
                $dbw = wfGetDB( DB_MASTER );
-               $status = $dbw->doAtomicSection( __METHOD__, function ( $dbw, $fname ) {
+               $status = $dbw->doAtomicSection( __METHOD__, function ( IDatabase $dbw, $fname ) {
                        $noPass = PasswordFactory::newInvalidPassword()->toString();
                        $dbw->insert( 'user',
                                [
         * @return bool A block was spread
         */
        public function spreadAnyEditBlock() {
 -              if ( $this->isLoggedIn() && $this->isBlocked() ) {
 +              if ( $this->isLoggedIn() && $this->getBlock() ) {
                        return $this->spreadBlock();
                }
  
                return $wgImplicitGroups;
        }
  
 -      /**
 -       * Get the title of a page describing a particular group
 -       * @deprecated since 1.29 Use UserGroupMembership::getGroupPage instead
 -       *
 -       * @param string $group Internal group name
 -       * @return Title|bool Title of the page if it exists, false otherwise
 -       */
 -      public static function getGroupPage( $group ) {
 -              wfDeprecated( __METHOD__, '1.29' );
 -              return UserGroupMembership::getGroupPage( $group );
 -      }
 -
 -      /**
 -       * Create a link to the group in HTML, if available;
 -       * else return the group name.
 -       * @deprecated since 1.29 Use UserGroupMembership::getLink instead, or
 -       * make the link yourself if you need custom text
 -       *
 -       * @param string $group Internal name of the group
 -       * @param string $text The text of the link
 -       * @return string HTML link to the group
 -       */
 -      public static function makeGroupLinkHTML( $group, $text = '' ) {
 -              wfDeprecated( __METHOD__, '1.29' );
 -
 -              if ( $text == '' ) {
 -                      $text = UserGroupMembership::getGroupName( $group );
 -              }
 -              $title = UserGroupMembership::getGroupPage( $group );
 -              if ( $title ) {
 -                      return MediaWikiServices::getInstance()
 -                              ->getLinkRenderer()->makeLink( $title, $text );
 -              }
 -
 -              return htmlspecialchars( $text );
 -      }
 -
 -      /**
 -       * Create a link to the group in Wikitext, if available;
 -       * else return the group name.
 -       * @deprecated since 1.29 Use UserGroupMembership::getLink instead, or
 -       * make the link yourself if you need custom text
 -       *
 -       * @param string $group Internal name of the group
 -       * @param string $text The text of the link
 -       * @return string Wikilink to the group
 -       */
 -      public static function makeGroupLinkWiki( $group, $text = '' ) {
 -              wfDeprecated( __METHOD__, '1.29' );
 -
 -              if ( $text == '' ) {
 -                      $text = UserGroupMembership::getGroupName( $group );
 -              }
 -              $title = UserGroupMembership::getGroupPage( $group );
 -              if ( $title ) {
 -                      $page = $title->getFullText();
 -                      return "[[$page|$text]]";
 -              }
 -
 -              return $text;
 -      }
 -
        /**
         * Returns an array of the groups that a particular group can add/remove.
         *