Merge "output: Narrow Title type hint to LinkTarget"
[lhc/web/wiklou.git] / includes / specials / pagers / ActiveUsersPager.php
index 368c6d1..c9c3b07 100644 (file)
@@ -19,6 +19,8 @@
  * @ingroup Pager
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * This class is used to get a list of active users. The ones with specials
  * rights (sysop, bureaucrat, developer) will have them displayed
@@ -43,6 +45,12 @@ class ActiveUsersPager extends UsersPager {
         */
        private $blockStatusByUid;
 
+       /** @var int */
+       private $RCMaxAge;
+
+       /** @var string[] */
+       private $excludegroups;
+
        /**
         * @param IContextSource|null $context
         * @param FormOptions $opts
@@ -79,19 +87,16 @@ class ActiveUsersPager extends UsersPager {
        function getQueryInfo( $data = null ) {
                $dbr = $this->getDatabase();
 
-               $useActor = (bool)(
-                       $this->getConfig()->get( 'ActorTableSchemaMigrationStage' ) & SCHEMA_COMPAT_READ_NEW
-               );
-
                $activeUserSeconds = $this->getConfig()->get( 'ActiveUserDays' ) * 86400;
                $timestamp = $dbr->timestamp( wfTimestamp( TS_UNIX ) - $activeUserSeconds );
                $fname = __METHOD__ . ' (' . $this->getSqlComment() . ')';
 
                // Inner subselect to pull the active users out of querycachetwo
-               $tables = [ 'querycachetwo', 'user' ];
-               $fields = [ 'qcc_title', 'user_id' ];
+               $tables = [ 'querycachetwo', 'user', 'actor' ];
+               $fields = [ 'qcc_title', 'user_id', 'actor_id' ];
                $jconds = [
                        'user' => [ 'JOIN', 'user_name = qcc_title' ],
+                       'actor' => [ 'JOIN', 'actor_user = user_id' ],
                ];
                $conds = [
                        'qcc_type' => 'activeusers',
@@ -121,25 +126,20 @@ class ActiveUsersPager extends UsersPager {
                        ] ];
                        $conds['ug2.ug_user'] = null;
                }
-               if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
+               if ( !MediaWikiServices::getInstance()
+                                 ->getPermissionManager()
+                                 ->userHasRight( $this->getUser(), 'hideuser' )
+               ) {
                        $conds[] = 'NOT EXISTS (' . $dbr->selectSQLText(
                                        'ipblocks', '1', [ 'ipb_user=user_id', 'ipb_deleted' => 1 ]
                                ) . ')';
                }
-               if ( $useActor ) {
-                       $tables[] = 'actor';
-                       $jconds['actor'] = [
-                               'JOIN',
-                               'actor_user = user_id',
-                       ];
-                       $fields[] = 'actor_id';
-               }
                $subquery = $dbr->buildSelectSubquery( $tables, $fields, $conds, $fname, $options, $jconds );
 
                // Outer query to select the recent edit counts for the selected active users
                $tables = [ 'qcc_users' => $subquery, 'recentchanges' ];
                $jconds = [ 'recentchanges' => [ 'LEFT JOIN', [
-                       $useActor ? 'rc_actor = actor_id' : 'rc_user_text = qcc_title',
+                       'rc_actor = actor_id',
                        'rc_type != ' . $dbr->addQuotes( RC_EXTERNAL ), // Don't count wikidata.
                        'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE ), // Don't count categorization changes.
                        'rc_log_type IS NULL OR rc_log_type != ' . $dbr->addQuotes( 'newusers' ),
@@ -155,7 +155,7 @@ class ActiveUsersPager extends UsersPager {
                                'user_id' => 'user_id',
                                'recentedits' => 'COUNT(rc_id)'
                        ],
-                       'options' => [ 'GROUP BY' => [ 'qcc_title' ] ],
+                       'options' => [ 'GROUP BY' => [ 'qcc_title', 'user_id' ] ],
                        'conds' => $conds,
                        'join_conds' => $jconds,
                ];