function getQueryInfo() {
$queryInfo = array(
- 'tables' => array( 'revision' ),
- 'fields' => Revision::selectFields(),
+ 'tables' => array( 'revision', 'user' ),
+ 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
'conds' => array_merge(
array( 'rev_page' => $this->title->getArticleID() ),
$this->conds ),
'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
- 'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
+ 'join_conds' => array(
+ 'user' => array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' ),
+ 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
);
ChangeTags::modifyDisplayQuery(
$queryInfo['tables'],
* @return mixed
*/
public function doQuery( $db ) {
- $conds = array(
- 'rev_page' => $this->title->getArticleID(),
- 'rev_page = page_id'
- );
+ $conds = array( 'rev_page' => $this->title->getArticleID() );
if ( $this->ids !== null ) {
$conds['rev_id'] = array_map( 'intval', $this->ids );
}
return $db->select(
- array( 'revision', 'page' ),
- '*',
+ array( 'revision', 'page', 'user' ),
+ array_merge( Revision::selectFields(), Revision::selectUserFields() ),
$conds,
__METHOD__,
- array( 'ORDER BY' => 'rev_id DESC' )
+ array( 'ORDER BY' => 'rev_id DESC' ),
+ array( 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
+ 'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
);
}
}
public function getAuthorNameField() {
- return 'rev_user_text';
+ return 'rev_user_name'; // see Revision::selectUserFields()
}
public function canView() {
*/
public function doQuery( $db ) {
$ids = array_map( 'intval', $this->ids );
- $live = $db->select( array('revision','page'), '*',
+ $live = $db->select(
+ array( 'revision', 'page', 'user' ),
+ array_merge( Revision::selectFields(), Revision::selectUserFields() ),
array(
'rev_page' => $this->title->getArticleID(),
'rev_id' => $ids,
- 'rev_page = page_id'
),
__METHOD__,
- array( 'ORDER BY' => 'rev_id DESC' )
+ array( 'ORDER BY' => 'rev_id DESC' ),
+ array( 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
+ 'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
);
if ( $live->numRows() >= count( $ids ) ) {
}
public function getAuthorNameField() {
- return 'rev_user_text';
+ return 'rev_user_name'; // see Revision::selectUserFields()
}
public function canView() {
$conds[] = $this->mDb->bitAnd('rev_deleted',Revision::SUPPRESSED_USER) .
' != ' . Revision::SUPPRESSED_USER;
}
- $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
+
+ # Don't include orphaned revisions
+ $join_cond['page'] = array( 'INNER JOIN', 'page_id = rev_page' );
+ # Get the current user name for accounts
+ $join_cond['user'] = array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' );
$queryInfo = array(
'tables' => $tables,
- 'fields' => array(
+ 'fields' => array_merge( Revision::selectUserFields(), array(
'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
- 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
+ 'page_len', 'rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted',
- 'rev_len', 'rev_parent_id'
- ),
+ 'rev_len'
+ ) ),
'conds' => $conds,
'options' => array( 'USE INDEX' => array('revision' => $index) ),
'join_conds' => $join_cond
function getUserCond() {
$condition = array();
$join_conds = array();
+ $tables = array( 'revision', 'page', 'user' );
if( $this->target == 'newbies' ) {
- $tables = array( 'user_groups', 'page', 'revision' );
+ $tables[] = 'user_groups';
$max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
$condition[] = 'rev_user >' . (int)($max - $max / 100);
$condition[] = 'ug_group IS NULL';
# @todo FIXME: Other groups may have 'bot' rights
$join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
} else {
- $tables = array( 'page', 'revision' );
- $condition['rev_user_text'] = $this->target;
- $index = 'usertext_timestamp';
+ if ( IP::isIPAddress( $this->target ) ) {
+ $condition['rev_user_text'] = $this->target;
+ $index = 'usertext_timestamp';
+ } else {
+ $condition['rev_user'] = User::idFromName( $this->target );
+ $index = 'user_timestamp';
+ }
}
if( $this->deletedOnly ) {
$condition[] = "rev_deleted != '0'";
$d = '<span class="history-deleted">' . $d . '</span>';
}
+ # Show user names for /newbies as there may be different users.
+ # Note that we already excluded rows with hidden user names.
if( $this->target == 'newbies' ) {
- $userlink = ' . . ' . Linker::userLink( $row->rev_user, $row->rev_user_text );
- $userlink .= ' ' . wfMsg( 'parentheses', Linker::userTalkLink( $row->rev_user, $row->rev_user_text ) ) . ' ';
+ $userlink = ' . . ' . Linker::userLink( $rev->getUser(), $rev->getUserText() );
+ $userlink .= ' ' . wfMsg( 'parentheses',
+ Linker::userTalkLink( $rev->getUser(), $rev->getUserText() ) ) . ' ';
} else {
$userlink = '';
}
function getQueryInfo() {
$conds = $this->mConds;
$conds['rev_page'] = $this->articleID;
- $conds[] = 'page_id = rev_page';
$conds[] = "rev_timestamp < {$this->maxTimestamp}";
return array(
- 'tables' => array( 'revision', 'page' ),
- 'fields' => array(
- 'rev_minor_edit', 'rev_timestamp', 'rev_user', 'rev_user_text',
- 'rev_comment', 'rev_id', 'rev_page', 'rev_parent_id',
- 'rev_text_id', 'rev_len', 'rev_deleted'
- ),
- 'conds' => $conds
+ 'tables' => array( 'revision', 'page', 'user' ),
+ 'fields' => array_merge( Revision::selectFields(), Revision::selectUserFields() ),
+ 'conds' => $conds,
+ 'join_conds' => array(
+ 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
+ 'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
);
}