/**
* Query the list of contributors to a page
*
- * Created on Nov 14, 2013
- *
- * Copyright © 2013 Brad Jorsch
+ * Copyright © 2013 Wikimedia Foundation and contributors
*
* 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
}
public function execute() {
+ global $wgActorTableSchemaMigrationStage;
+
$db = $this->getDB();
$params = $this->extractRequestParams();
$this->requireMaxOneParameter( $params, 'group', 'excludegroup', 'rights', 'excluderights' );
}
$result = $this->getResult();
+ $revQuery = Revision::getQueryInfo();
+
+ // For MIGRATION_NEW, target indexes on the revision_actor_temp table.
+ // Otherwise, revision is fine because it'll have to check all revision rows anyway.
+ $pageField = $wgActorTableSchemaMigrationStage === MIGRATION_NEW ? 'revactor_page' : 'rev_page';
+ $idField = $wgActorTableSchemaMigrationStage === MIGRATION_NEW
+ ? 'revactor_actor' : $revQuery['fields']['rev_user'];
+ $countField = $wgActorTableSchemaMigrationStage === MIGRATION_NEW
+ ? 'revactor_actor' : $revQuery['fields']['rev_user_text'];
// First, count anons
- $this->addTables( 'revision' );
+ $this->addTables( $revQuery['tables'] );
+ $this->addJoinConds( $revQuery['joins'] );
$this->addFields( [
- 'page' => 'rev_page',
- 'anons' => 'COUNT(DISTINCT rev_user_text)',
+ 'page' => $pageField,
+ 'anons' => "COUNT(DISTINCT $countField)",
] );
- $this->addWhereFld( 'rev_page', $pages );
- $this->addWhere( 'rev_user = 0' );
+ $this->addWhereFld( $pageField, $pages );
+ $this->addWhere( ActorMigration::newMigration()->isAnon( $revQuery['fields']['rev_user'] ) );
$this->addWhere( $db->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' );
- $this->addOption( 'GROUP BY', 'rev_page' );
+ $this->addOption( 'GROUP BY', $pageField );
$res = $this->select( __METHOD__ );
foreach ( $res as $row ) {
$fit = $result->addValue( [ 'query', 'pages', $row->page ],
// Next, add logged-in users
$this->resetQueryParams();
- $this->addTables( 'revision' );
+ $this->addTables( $revQuery['tables'] );
+ $this->addJoinConds( $revQuery['joins'] );
$this->addFields( [
- 'page' => 'rev_page',
- 'user' => 'rev_user',
- 'username' => 'MAX(rev_user_text)', // Non-MySQL databases don't like partial group-by
+ 'page' => $pageField,
+ 'id' => $idField,
+ // Non-MySQL databases don't like partial group-by
+ 'userid' => 'MAX(' . $revQuery['fields']['rev_user'] . ')',
+ 'username' => 'MAX(' . $revQuery['fields']['rev_user_text'] . ')',
] );
- $this->addWhereFld( 'rev_page', $pages );
- $this->addWhere( 'rev_user != 0' );
+ $this->addWhereFld( $pageField, $pages );
+ $this->addWhere( ActorMigration::newMigration()->isNotAnon( $revQuery['fields']['rev_user'] ) );
$this->addWhere( $db->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' );
- $this->addOption( 'GROUP BY', 'rev_page, rev_user' );
+ $this->addOption( 'GROUP BY', [ $pageField, $idField ] );
$this->addOption( 'LIMIT', $params['limit'] + 1 );
// Force a sort order to ensure that properties are grouped by page
- // But only if pp_page is not constant in the WHERE clause.
+ // But only if rev_page is not constant in the WHERE clause.
if ( count( $pages ) > 1 ) {
- $this->addOption( 'ORDER BY', 'rev_page, rev_user' );
+ $this->addOption( 'ORDER BY', [ 'page', 'id' ] );
} else {
- $this->addOption( 'ORDER BY', 'rev_user' );
+ $this->addOption( 'ORDER BY', 'id' );
}
$limitGroups = [];
$this->addJoinConds( [ 'user_groups' => [
$excludeGroups ? 'LEFT OUTER JOIN' : 'INNER JOIN',
[
- 'ug_user=rev_user',
+ 'ug_user=' . $revQuery['fields']['rev_user'],
'ug_group' => $limitGroups,
- $this->getConfig()->get( 'DisableUserGroupExpiry' ) ?
- '1' :
- 'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
+ 'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
]
] ] );
$this->addWhereIf( 'ug_user IS NULL', $excludeGroups );
$cont = explode( '|', $params['continue'] );
$this->dieContinueUsageIf( count( $cont ) != 2 );
$cont_page = (int)$cont[0];
- $cont_user = (int)$cont[1];
+ $cont_id = (int)$cont[1];
$this->addWhere(
- "rev_page > $cont_page OR " .
- "(rev_page = $cont_page AND " .
- "rev_user >= $cont_user)"
+ "$pageField > $cont_page OR " .
+ "($pageField = $cont_page AND " .
+ "$idField >= $cont_id)"
);
}
if ( ++$count > $params['limit'] ) {
// We've reached the one extra which shows that
// there are additional pages to be had. Stop here...
- $this->setContinueEnumParameter( 'continue', $row->page . '|' . $row->user );
-
+ $this->setContinueEnumParameter( 'continue', $row->page . '|' . $row->id );
return;
}
$fit = $this->addPageSubItem( $row->page,
- [ 'userid' => (int)$row->user, 'name' => $row->username ],
+ [ 'userid' => (int)$row->userid, 'name' => $row->username ],
'user'
);
if ( !$fit ) {
- $this->setContinueEnumParameter( 'continue', $row->page . '|' . $row->user );
-
+ $this->setContinueEnumParameter( 'continue', $row->page . '|' . $row->id );
return;
}
}
}
public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Contributors';
+ return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Contributors';
}
}