Don't indicate partial blocks on Special:ActiveUsers
authorThalia <thalia.e.chan@googlemail.com>
Mon, 26 Nov 2018 14:00:35 +0000 (14:00 +0000)
committerThalia <thalia.e.chan@googlemail.com>
Wed, 28 Nov 2018 13:22:12 +0000 (13:22 +0000)
Only indicate sitewide blocks here.

Bug: T210391
Change-Id: I01d2fa6e326722d85652d96842e968c80d034274

includes/specials/pagers/ActiveUsersPager.php

index 552e92f..506cd3c 100644 (file)
@@ -149,14 +149,17 @@ class ActiveUsersPager extends UsersPager {
                // is done in two queries to avoid huge quicksorts and to make COUNT(*) correct.
                $dbr = $this->getDatabase();
                $res = $dbr->select( 'ipblocks',
-                       [ 'ipb_user', 'MAX(ipb_deleted) AS block_status' ],
+                       [ 'ipb_user', 'MAX(ipb_deleted) AS deleted, MAX(ipb_sitewide) AS sitewide' ],
                        [ 'ipb_user' => $uids ],
                        __METHOD__,
                        [ 'GROUP BY' => [ 'ipb_user' ] ]
                );
                $this->blockStatusByUid = [];
                foreach ( $res as $row ) {
-                       $this->blockStatusByUid[$row->ipb_user] = $row->block_status; // 0 or 1
+                       $this->blockStatusByUid[$row->ipb_user] = [
+                               'deleted' => $row->deleted,
+                               'sitewide' => $row->sitewide,
+                       ];
                }
                $this->mResult->seek( 0 );
        }
@@ -181,13 +184,20 @@ class ActiveUsersPager extends UsersPager {
 
                $item = $lang->specialList( $ulinks, $groups );
 
+               // If there is a block, 'deleted' and 'sitewide' are both set on
+               // $this->blockStatusByUid[$row->user_id].
+               $blocked = '';
                $isBlocked = isset( $this->blockStatusByUid[$row->user_id] );
-               if ( $isBlocked && $this->blockStatusByUid[$row->user_id] == 1 ) {
-                       $item = "<span class=\"deleted\">$item</span>";
+               if ( $isBlocked ) {
+                       if ( $this->blockStatusByUid[$row->user_id]['deleted'] == 1 ) {
+                               $item = "<span class=\"deleted\">$item</span>";
+                       }
+                       if ( $this->blockStatusByUid[$row->user_id]['sitewide'] == 1 ) {
+                               $blocked = ' ' . $this->msg( 'listusers-blocked', $userName )->escaped();
+                       }
                }
                $count = $this->msg( 'activeusers-count' )->numParams( $row->recentedits )
                        ->params( $userName )->numParams( $this->RCMaxAge )->escaped();
-               $blocked = $isBlocked ? ' ' . $this->msg( 'listusers-blocked', $userName )->escaped() : '';
 
                return Html::rawElement( 'li', [], "{$item} [{$count}]{$blocked}" );
        }