Reedy has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/163026

Change subject: Revert "API: Fix list=allusers with multiple values for augroup"
......................................................................

Revert "API: Fix list=allusers with multiple values for augroup"

Causing a large load spike on enwiki api db slaves

This reverts commit aa5800519f301cbafa835ef3ee95c7b3f24050b4.

Change-Id: Ied559c4e701bb644b354af4e158b84537dde94e9
---
M includes/api/ApiQueryAllUsers.php
1 file changed, 23 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/26/163026/1

diff --git a/includes/api/ApiQueryAllUsers.php 
b/includes/api/ApiQueryAllUsers.php
index d241311..affddda 100644
--- a/includes/api/ApiQueryAllUsers.php
+++ b/includes/api/ApiQueryAllUsers.php
@@ -111,18 +111,35 @@
                        }
                }
 
+               if ( !is_null( $params['group'] ) && !is_null( 
$params['excludegroup'] ) ) {
+                       $this->dieUsage( 'group and excludegroup cannot be used 
together', 'group-excludegroup' );
+               }
+
                if ( !is_null( $params['group'] ) && count( $params['group'] ) 
) {
+                       $useIndex = false;
                        // Filter only users that belong to a given group
-                       $this->addWhere( 'EXISTS (' . $db->selectSQLText(
-                               'user_groups', '1', array( 'ug_user=user_id', 
'ug_group' => $params['group'] )
-                       ) . ')' );
+                       $this->addTables( 'user_groups', 'ug1' );
+                       $this->addJoinConds( array( 'ug1' => array( 'INNER 
JOIN', array( 'ug1.ug_user=user_id',
+                               'ug1.ug_group' => $params['group'] ) ) ) );
                }
 
                if ( !is_null( $params['excludegroup'] ) && count( 
$params['excludegroup'] ) ) {
+                       $useIndex = false;
                        // Filter only users don't belong to a given group
-                       $this->addWhere( 'NOT EXISTS (' . $db->selectSQLText(
-                               'user_groups', '1', array( 'ug_user=user_id', 
'ug_group' => $params['excludegroup'] )
-                       ) . ')' );
+                       $this->addTables( 'user_groups', 'ug1' );
+
+                       if ( count( $params['excludegroup'] ) == 1 ) {
+                               $exclude = array( 'ug1.ug_group' => 
$params['excludegroup'][0] );
+                       } else {
+                               $exclude = array( $db->makeList(
+                                       array( 'ug1.ug_group' => 
$params['excludegroup'] ),
+                                       LIST_OR
+                               ) );
+                       }
+                       $this->addJoinConds( array( 'ug1' => array( 'LEFT OUTER 
JOIN',
+                               array_merge( array( 'ug1.ug_user=user_id' ), 
$exclude )
+                       ) ) );
+                       $this->addWhere( 'ug1.ug_user IS NULL' );
                }
 
                if ( $params['witheditsonly'] ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/163026
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied559c4e701bb644b354af4e158b84537dde94e9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.24wmf22
Gerrit-Owner: Reedy <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to