Merge "Remove deprecated ChangesList::newFromUser function"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 7 Nov 2013 21:14:00 +0000 (21:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 7 Nov 2013 21:14:00 +0000 (21:14 +0000)
1  2 
includes/changes/ChangesList.php

@@@ -49,19 -49,6 +49,6 @@@ class ChangesList extends ContextSourc
                $this->preCacheMessages();
        }
  
-       /**
-        * Fetch an appropriate changes list class for the main context
-        * This first argument used to be an User object.
-        *
-        * @deprecated in 1.18; use newFromContext() instead
-        * @param string|User $unused Unused
-        * @return ChangesList|EnhancedChangesList|OldChangesList derivative
-        */
-       public static function newFromUser( $unused ) {
-               wfDeprecated( __METHOD__, '1.18' );
-               return self::newFromContext( RequestContext::getMain() );
-       }
        /**
         * Fetch an appropriate changes list class for the specified context
         * Some users might want to use an enhanced list format, for instance
        }
  
        protected function showAsUnpatrolled( RecentChange $rc ) {
 -              $unpatrolled = false;
 -              if ( !$rc->mAttribs['rc_patrolled'] ) {
 -                      if ( $this->getUser()->useRCPatrol() ) {
 -                              $unpatrolled = true;
 -                      } elseif ( $this->getUser()->useNPPatrol() && $rc->mAttribs['rc_type'] == RC_NEW ) {
 -                              $unpatrolled = true;
 +              return self::isUnpatrolled( $rc, $this->getUser() );
 +      }
 +
 +      /**
 +       * @param object|RecentChange $rc Database row from recentchanges or a RecentChange object
 +       * @param User $user
 +       * @return bool
 +       */
 +      public static function isUnpatrolled( $rc, User $user ) {
 +              if ( $rc instanceof RecentChange ) {
 +                      $isPatrolled = $rc->mAttribs['rc_patrolled'];
 +                      $rcType = $rc->mAttribs['rc_type'];
 +              } else {
 +                      $isPatrolled = $rc->rc_patrolled;
 +                      $rcType = $rc->rc_type;
 +              }
 +
 +              if ( !$isPatrolled ) {
 +                      if ( $user->useRCPatrol() ) {
 +                              return true;
 +                      }
 +                      if ( $user->useNPPatrol() && $rcType == RC_NEW ) {
 +                              return true;
                        }
                }
 -              return $unpatrolled;
 +
 +              return false;
        }
  }