* Added pageJoinCond() and userJoinCond() to Revision and exposed them publicly
* Removed commented-out code
This commit is contained in:
parent
681523d5ad
commit
eac8538cd6
7 changed files with 30 additions and 15 deletions
|
|
@ -294,11 +294,28 @@ class Revision {
|
|||
$conditions,
|
||||
__METHOD__,
|
||||
array( 'LIMIT' => 1 ),
|
||||
array( 'page' => array( 'INNER JOIN', 'page_id = rev_page' ),
|
||||
'user' => array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' ) )
|
||||
array( 'page' => self::pageJoinCond(), 'user' => self::userJoinCond() )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of a select() JOIN conds array for the user table.
|
||||
* This will get user table rows for logged-in users.
|
||||
* @return Array
|
||||
*/
|
||||
public static function userJoinCond() {
|
||||
return array( 'LEFT JOIN', array( 'rev_user != 0', 'user_id = rev_user' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of a select() page conds array for the paeg table.
|
||||
* This will assure that the revision(s) are not orphaned from live pages.
|
||||
* @return Array
|
||||
*/
|
||||
public static function pageJoinCond() {
|
||||
return array( 'INNER JOIN', array( 'page_id = rev_page' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of revision fields that should be selected to create
|
||||
* a new revision.
|
||||
|
|
|
|||
|
|
@ -260,8 +260,9 @@ class RevisionList extends RevisionListBase {
|
|||
$conds,
|
||||
__METHOD__,
|
||||
array( 'ORDER BY' => 'rev_id DESC' ),
|
||||
array( 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
|
||||
'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
|
||||
array(
|
||||
'page' => Revision::pageJoinCond(),
|
||||
'user' => Revision::userJoinCond() )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1529,10 +1529,6 @@ class WikiPage extends Page {
|
|||
*/
|
||||
public function estimateRevisionCount() {
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
|
||||
// For an exact count...
|
||||
// return $dbr->selectField( 'revision', 'COUNT(*)',
|
||||
// array( 'rev_page' => $this->getId() ), __METHOD__ );
|
||||
return $dbr->estimateRowCount( 'revision', '*',
|
||||
array( 'rev_page' => $this->getId() ), __METHOD__ );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ class HistoryPager extends ReverseChronologicalPager {
|
|||
$this->conds ),
|
||||
'options' => array( 'USE INDEX' => array( 'revision' => 'page_timestamp' ) ),
|
||||
'join_conds' => array(
|
||||
'user' => array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' ),
|
||||
'user' => Revision::userJoinCond(),
|
||||
'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
|
||||
);
|
||||
ChangeTags::modifyDisplayQuery(
|
||||
|
|
|
|||
|
|
@ -34,8 +34,9 @@ class RevDel_RevisionList extends RevDel_List {
|
|||
),
|
||||
__METHOD__,
|
||||
array( 'ORDER BY' => 'rev_id DESC' ),
|
||||
array( 'page' => array( 'INNER JOIN', 'rev_page = page_id' ),
|
||||
'user' => array( 'LEFT JOIN', 'user_id = rev_user' ) )
|
||||
array(
|
||||
'page' => Revision::pageJoinCond(),
|
||||
'user' => Revision::userJoinCond() )
|
||||
);
|
||||
|
||||
if ( $live->numRows() >= count( $ids ) ) {
|
||||
|
|
|
|||
|
|
@ -476,9 +476,9 @@ class ContribsPager extends ReverseChronologicalPager {
|
|||
}
|
||||
|
||||
# Don't include orphaned revisions
|
||||
$join_cond['page'] = array( 'INNER JOIN', 'page_id = rev_page' );
|
||||
$join_cond['page'] = Revision::pageJoinCond();
|
||||
# Get the current user name for accounts
|
||||
$join_cond['user'] = array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' );
|
||||
$join_cond['user'] = Revision::userJoinCond();
|
||||
|
||||
$queryInfo = array(
|
||||
'tables' => $tables,
|
||||
|
|
|
|||
|
|
@ -483,8 +483,8 @@ class MergeHistoryPager extends ReverseChronologicalPager {
|
|||
'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' ) )
|
||||
'page' => Revision::pageJoinCond(),
|
||||
'user' => Revision::userJoinCond() )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue