<?php
/**
- *
- *
- * Created on Jul 2, 2007
- *
* Copyright © 2007 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
*
* This program is free software; you can redistribute it and/or modify
$user = $this->getUser();
$db = $this->getDB();
+ $commentStore = CommentStore::getStore();
$params = $this->extractRequestParams( false );
$prop = array_flip( $params['prop'] );
$fld_parentid = isset( $prop['parentid'] );
$this->addFieldsIf( 'ar_parent_id', $fld_parentid );
$this->addFieldsIf( 'ar_rev_id', $fld_revid );
- $this->addFieldsIf( 'ar_user_text', $fld_user );
- $this->addFieldsIf( 'ar_user', $fld_userid );
- $this->addFieldsIf( 'ar_comment', $fld_comment || $fld_parsedcomment );
+ if ( $fld_user || $fld_userid ) {
+ $actorQuery = ActorMigration::newMigration()->getJoin( 'ar_user' );
+ $this->addTables( $actorQuery['tables'] );
+ $this->addFields( $actorQuery['fields'] );
+ $this->addJoinConds( $actorQuery['joins'] );
+ }
$this->addFieldsIf( 'ar_minor_edit', $fld_minor );
$this->addFieldsIf( 'ar_len', $fld_len );
$this->addFieldsIf( 'ar_sha1', $fld_sha1 );
+ if ( $fld_comment || $fld_parsedcomment ) {
+ $commentQuery = $commentStore->getJoin( 'ar_comment' );
+ $this->addTables( $commentQuery['tables'] );
+ $this->addFields( $commentQuery['fields'] );
+ $this->addJoinConds( $commentQuery['joins'] );
+ }
+
if ( $fld_tags ) {
$this->addTables( 'tag_summary' );
$this->addJoinConds(
}
if ( !is_null( $params['user'] ) ) {
- $this->addWhereFld( 'ar_user_text', $params['user'] );
+ // Don't query by user ID here, it might be able to use the ar_usertext_timestamp index.
+ $actorQuery = ActorMigration::newMigration()
+ ->getWhere( $db, 'ar_user', User::newFromName( $params['user'], false ), false );
+ $this->addTables( $actorQuery['tables'] );
+ $this->addJoinConds( $actorQuery['joins'] );
+ $this->addWhere( $actorQuery['conds'] );
} elseif ( !is_null( $params['excludeuser'] ) ) {
- $this->addWhere( 'ar_user_text != ' .
- $db->addQuotes( $params['excludeuser'] ) );
+ // Here there's no chance of using ar_usertext_timestamp.
+ $actorQuery = ActorMigration::newMigration()
+ ->getWhere( $db, 'ar_user', User::newFromName( $params['excludeuser'], false ) );
+ $this->addTables( $actorQuery['tables'] );
+ $this->addJoinConds( $actorQuery['joins'] );
+ $this->addWhere( 'NOT(' . $actorQuery['conds'] . ')' );
}
if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
}
$this->addOption( 'LIMIT', $limit + 1 );
- $this->addOption(
- 'USE INDEX',
- [ 'archive' => ( $mode == 'user' ? 'ar_usertext_timestamp' : 'name_title_timestamp' ) ]
- );
if ( $mode == 'all' ) {
if ( $params['unique'] ) {
// @todo Does this work on non-MySQL?
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_COMMENT, $user ) ) {
+ $comment = $commentStore->getComment( 'ar_comment', $row )->text;
if ( $fld_comment ) {
- $rev['comment'] = $row->ar_comment;
+ $rev['comment'] = $comment;
}
if ( $fld_parsedcomment ) {
$title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
- $rev['parsedcomment'] = Linker::formatComment( $row->ar_comment, $title );
+ $rev['parsedcomment'] = Linker::formatComment( $comment, $title );
}
}
}