$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.
$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() )
);
}
*/
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__ );
}
$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(
),
__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 ) ) {
}
# 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,
'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() )
);
}