*/
public function getDefaultOptions() {
$opts = new FormOptions();
+ $user = $this->getUser();
- $opts->add( 'days', $this->getUser()->getIntOption( 'rcdays' ) );
- $opts->add( 'limit', $this->getUser()->getIntOption( 'rclimit' ) );
+ $opts->add( 'days', $user->getIntOption( 'rcdays' ) );
+ $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
$opts->add( 'from', '' );
- $opts->add( 'hideminor', $this->getUser()->getBoolOption( 'hideminor' ) );
+ $opts->add( 'hideminor', $user->getBoolOption( 'hideminor' ) );
$opts->add( 'hidebots', true );
$opts->add( 'hideanons', false );
$opts->add( 'hideliu', false );
- $opts->add( 'hidepatrolled', $this->getUser()->getBoolOption( 'hidepatrolled' ) );
+ $opts->add( 'hidepatrolled', $user->getBoolOption( 'hidepatrolled' ) );
$opts->add( 'hidemyself', false );
$opts->add( 'namespace', '', FormOptions::INTNULL );
$opts = $this->getOptions();
$this->setHeaders();
$this->outputHeader();
- $this->addRecentChangesJS();
+ $this->addModules();
// Fetch results, prepare a batch link existence check query
$conds = $this->buildMainQueryConds( $opts );
return false;
}
- // Don't use the new_namespace_time timestamp index if:
- // (a) "All namespaces" selected
- // (b) We want pages in more than one namespace (inverted/associated)
- // (c) There is a tag to filter on (use tag index instead)
- // (d) UNION + sort/limit is not an option for the DBMS
- if ( $namespace === ''
- || ( $invert || $associated )
- || $opts['tagfilter'] != ''
- || !$dbr->unionSupportsOrderAndLimit()
- ) {
- $res = $dbr->select( $tables, $fields, $conds, __METHOD__,
- array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) +
- $query_options,
- $join_conds );
- } else {
- // We have a new_namespace_time index! UNION over new=(0,1) and sort result set!
-
- // New pages
- $sqlNew = $dbr->selectSQLText(
- $tables,
- $fields,
- array( 'rc_new' => 1 ) + $conds,
- __METHOD__,
- array(
- 'ORDER BY' => 'rc_timestamp DESC',
- 'LIMIT' => $limit,
- 'USE INDEX' => array( 'recentchanges' => 'new_name_timestamp' )
- ),
- $join_conds
- );
-
- // Old pages
- $sqlOld = $dbr->selectSQLText(
- $tables,
- $fields,
- array( 'rc_new' => 0 ) + $conds,
- __METHOD__,
- array(
- 'ORDER BY' => 'rc_timestamp DESC',
- 'LIMIT' => $limit,
- 'USE INDEX' => array( 'recentchanges' => 'new_name_timestamp' )
- ),
- $join_conds
- );
-
- # Join the two fast queries, and sort the result set
- $sql = $dbr->unionQueries( array( $sqlNew, $sqlOld ), false ) .
- ' ORDER BY rc_timestamp DESC';
- $sql = $dbr->limitResult( $sql, $limit, false );
- $res = $dbr->query( $sql, __METHOD__ );
- }
-
- return $res;
+ // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
+ // knowledge to use an index merge if it wants (it may use some other index though).
+ return $dbr->select(
+ $tables,
+ $fields,
+ $conds + array( 'rc_new' => array( 0, 1 ) ),
+ __METHOD__,
+ array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) + $query_options,
+ $join_conds
+ );
}
/**
}
if ( $rows->numRows() === 0 ) {
- $this->getOutput()->wrapWikiMsg(
- "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
+ $this->getOutput()->addHtml(
+ '<div class="mw-changeslist-empty">' . $this->msg( 'recentchanges-noresult' )->parse() . '</div>'
);
} else {
$this->getOutput()->addHTML( $rclistOutput );
/**
* Creates the choose namespace selection
*
- * @todo Uses radio buttons (HASHAR)
* @param FormOptions $opts
* @return string
*/
}
/**
- * Add JavaScript to the page
+ * Add page-specific modules.
*/
- function addRecentChangesJS() {
+ protected function addModules() {
$this->getOutput()->addModules( array(
'mediawiki.special.recentchanges',
) );