<?php
/**
- * Copyright © 2008 Aaron Schulz
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
function getQueryInfo() {
$dbr = $this->getDatabase();
+ $rcQuery = ActorMigration::newMigration()->getJoin( 'rc_user' );
+
$activeUserSeconds = $this->getConfig()->get( 'ActiveUserDays' ) * 86400;
$timestamp = $dbr->timestamp( wfTimestamp( TS_UNIX ) - $activeUserSeconds );
- $tables = [ 'querycachetwo', 'user', 'recentchanges' ];
+ $tables = [ 'querycachetwo', 'user', 'rc' => [ 'recentchanges' ] + $rcQuery['tables'] ];
+ $jconds = [
+ 'user' => [ 'JOIN', 'user_name = qcc_title' ],
+ 'rc' => [ 'JOIN', $rcQuery['fields']['rc_user_text'] . ' = qcc_title' ],
+ ] + $rcQuery['joins'];
$conds = [
'qcc_type' => 'activeusers',
'qcc_namespace' => NS_USER,
- 'user_name = qcc_title',
- 'rc_user_text = qcc_title',
'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' ),
}
if ( $this->groups !== [] ) {
$tables[] = 'user_groups';
- $conds[] = 'ug_user = user_id';
+ $jconds['user_groups'] = [ 'JOIN', [ 'ug_user = user_id' ] ];
$conds['ug_group'] = $this->groups;
+ $conds[] = 'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() );
}
if ( $this->excludegroups !== [] ) {
foreach ( $this->excludegroups as $group ) {
$conds[] = 'NOT EXISTS (' . $dbr->selectSQLText(
- 'user_groups', '1', [ 'ug_user = user_id', 'ug_group' => $group ]
- ) . ')';
+ 'user_groups', '1', [
+ 'ug_user = user_id',
+ 'ug_group' => $group,
+ 'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
+ ]
+ ) . ')';
}
}
if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
) . ')';
}
- if ( $dbr->implicitGroupby() ) {
- $options = [ 'GROUP BY' => [ 'qcc_title' ] ];
- } else {
- $options = [ 'GROUP BY' => [ 'user_name', 'user_id', 'qcc_title' ] ];
- }
-
return [
'tables' => $tables,
- 'fields' => [ 'user_name', 'user_id', 'recentedits' => 'COUNT(*)', 'qcc_title' ],
- 'options' => $options,
- 'conds' => $conds
+ 'fields' => [
+ 'qcc_title',
+ 'user_name' => 'qcc_title',
+ 'user_id' => 'MAX(user_id)',
+ 'recentedits' => 'COUNT(*)'
+ ],
+ 'options' => [ 'GROUP BY' => [ 'qcc_title' ] ],
+ 'conds' => $conds,
+ 'join_conds' => $jconds,
];
}
$list = [];
$user = User::newFromId( $row->user_id );
- $groups_list = self::getGroups( intval( $row->user_id ), $this->userGroupCache );
- foreach ( $groups_list as $group ) {
- $list[] = self::buildGroupLink( $group, $userName );
+ $ugms = self::getGroupMemberships( intval( $row->user_id ), $this->userGroupCache );
+ foreach ( $ugms as $ugm ) {
+ $list[] = $this->buildGroupLink( $ugm, $userName );
}
$groups = $lang->commaList( $list );