$revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
$queryInfo = [
'tables' => $revQuery['tables'],
- 'fields' => $revQuery['fields'],
+ 'fields' => array_merge( $revQuery['fields'], [ 'page_is_new' ] ),
'conds' => [],
'options' => [],
'join_conds' => $revQuery['joins'],
];
if ( $this->contribs == 'newbie' ) {
- $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
- $queryInfo['conds'][] = 'rev_user >' . (int)( $max - $max / 100 );
+ $max = $this->mDb->selectField( 'user', 'max(user_id)', '', __METHOD__ );
+ $queryInfo['conds'][] = $revQuery['fields']['rev_user'] . ' >' . (int)( $max - $max / 100 );
# ignore local groups with the bot right
# @todo FIXME: Global groups may have 'bot' rights
$groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
$queryInfo['conds'][] = 'ug_group IS NULL';
$queryInfo['join_conds']['user_groups'] = [
'LEFT JOIN', [
- 'ug_user = rev_user',
+ 'ug_user = ' . $revQuery['fields']['rev_user'],
'ug_group' => $groupsWithBotPermission,
'ug_expiry IS NULL OR ug_expiry >= ' .
$this->mDb->addQuotes( $this->mDb->timestamp() )
$queryInfo['conds'][] = 'rev_timestamp > ' .
$this->mDb->addQuotes( $this->mDb->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) );
} else {
- $uid = User::idFromName( $this->target );
- if ( $uid ) {
- $queryInfo['conds']['rev_user'] = $uid;
- $queryInfo['options']['USE INDEX']['revision'] = 'user_timestamp';
+ $user = User::newFromName( $this->target, false );
+ $ipRangeConds = $user->isAnon() ? $this->getIpRangeConds( $this->mDb, $this->target ) : null;
+ if ( $ipRangeConds ) {
+ $queryInfo['tables'][] = 'ip_changes';
+ $queryInfo['join_conds']['ip_changes'] = [
+ 'LEFT JOIN', [ 'ipc_rev_id = rev_id' ]
+ ];
+ $queryInfo['conds'][] = $ipRangeConds;
} else {
- $ipRangeConds = $this->getIpRangeConds( $this->mDb, $this->target );
-
- if ( $ipRangeConds ) {
- $queryInfo['tables'][] = 'ip_changes';
- $queryInfo['join_conds']['ip_changes'] = [
- 'LEFT JOIN', [ 'ipc_rev_id = rev_id' ]
- ];
- $queryInfo['conds'][] = $ipRangeConds;
- } else {
- $queryInfo['conds']['rev_user_text'] = $this->target;
- $queryInfo['options']['USE INDEX']['revision'] = 'usertext_timestamp';
- }
+ // tables and joins are already handled by Revision::getQueryInfo()
+ $queryInfo['conds'][] = ActorMigration::newMigration()
+ ->getWhere( $this->mDb, 'rev_user', $user )['conds'];
}
}
* we're definitely dealing with revision data and we may proceed, if not, we'll leave it
* to extensions to subscribe to the hook to parse the row.
*/
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
try {
$rev = new Revision( $row );
$validRevision = (bool)$rev->getId();
} catch ( Exception $e ) {
$validRevision = false;
}
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $validRevision ) {
$attribs['data-mw-revid'] = $rev->getId();
* @param array $opts Options array
* @return array Options array with processed start and end date filter options
*/
- public static function processDateFilter( $opts ) {
+ public static function processDateFilter( array $opts ) {
$start = isset( $opts['start'] ) ? $opts['start'] : '';
$end = isset( $opts['end'] ) ? $opts['end'] : '';
$year = isset( $opts['year'] ) ? $opts['year'] : '';