diff options
Diffstat (limited to 'includes/specials/SpecialRecentchanges.php')
-rw-r--r-- | includes/specials/SpecialRecentchanges.php | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 8c14e1fc..91c0ecbe 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -23,11 +23,11 @@ class SpecialRecentChanges extends SpecialPage { $opts->add( 'limit', (int)$wgUser->getOption( 'rclimit' ) ); $opts->add( 'from', '' ); - $opts->add( 'hideminor', (bool)$wgUser->getOption( 'hideminor' ) ); + $opts->add( 'hideminor', $wgUser->getBoolOption( 'hideminor' ) ); $opts->add( 'hidebots', true ); $opts->add( 'hideanons', false ); $opts->add( 'hideliu', false ); - $opts->add( 'hidepatrolled', false ); + $opts->add( 'hidepatrolled', $wgUser->getBoolOption( 'hidepatrolled' ) ); $opts->add( 'hidemyself', false ); $opts->add( 'namespace', '', FormOptions::INTNULL ); @@ -35,6 +35,7 @@ class SpecialRecentChanges extends SpecialPage { $opts->add( 'categories', '' ); $opts->add( 'categories_any', false ); + $opts->add( 'tagfilter', '' ); return $opts; } @@ -54,7 +55,7 @@ class SpecialRecentChanges extends SpecialPage { $this->parseParameters( $parameters, $opts ); } - $opts->validateIntBounds( 'limit', 0, 5000 ); + $opts->validateIntBounds( 'limit', 0, 500 ); return $opts; } @@ -66,7 +67,8 @@ class SpecialRecentChanges extends SpecialPage { public function feedSetup() { global $wgFeedLimit, $wgRequest; $opts = $this->getDefaultOptions(); - $opts->fetchValuesFromRequest( $wgRequest, array( 'days', 'limit', 'hideminor' ) ); + # Feed is cached on limit,hideminor; other params would randomly not work + $opts->fetchValuesFromRequest( $wgRequest, array( 'limit', 'hideminor' ) ); $opts->validateIntBounds( 'limit', 0, $wgFeedLimit ); return $opts; } @@ -108,13 +110,14 @@ class SpecialRecentChanges extends SpecialPage { foreach( $rows as $row ) { $batch->add( NS_USER, $row->rc_user_text ); $batch->add( NS_USER_TALK, $row->rc_user_text ); + $batch->add( $row->rc_namespace, $row->rc_title ); } $batch->execute(); } - + $target = isset($opts['target']) ? $opts['target'] : ''; // RCL has targets if( $feedFormat ) { list( $feed, $feedObj ) = $this->getFeedObject( $feedFormat ); - $feed->execute( $feedObj, $rows, $opts['limit'], $opts['hideminor'], $lastmod ); + $feed->execute( $feedObj, $rows, $opts['limit'], $opts['hideminor'], $lastmod, $target ); } else { $this->webOutput( $rows, $opts ); } @@ -267,6 +270,7 @@ class SpecialRecentChanges extends SpecialPage { $tables = array( 'recentchanges' ); $join_conds = array(); + $query_options = array( 'USE INDEX' => array('recentchanges' => 'rc_timestamp') ); $uid = $wgUser->getId(); $dbr = wfGetDB( DB_SLAVE ); @@ -274,21 +278,38 @@ class SpecialRecentChanges extends SpecialPage { $namespace = $opts['namespace']; $invert = $opts['invert']; + $join_conds = array(); + // JOIN on watchlist for users if( $uid ) { $tables[] = 'watchlist'; - $join_conds = array( 'watchlist' => array('LEFT JOIN', - "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace") ); + $join_conds['watchlist'] = array('LEFT JOIN', + "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace"); } + if ($wgUser->isAllowed("rollback")) { + $tables[] = 'page'; + $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id'); + } + // Tag stuff. + $fields = array(); + // Fields are * in this case, so let the function modify an empty array to keep it happy. + ChangeTags::modifyDisplayQuery( $tables, + $fields, + $conds, + $join_conds, + $query_options, + $opts['tagfilter'] + ); wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts ) ); // Is there either one namespace selected or excluded? + // Tag filtering also has a better index. // Also, if this is "all" or main namespace, just use timestamp index. - if( is_null($namespace) || $invert || $namespace == NS_MAIN ) { + if( is_null($namespace) || $invert || $namespace == NS_MAIN || $opts['tagfilter'] ) { $res = $dbr->select( $tables, '*', $conds, __METHOD__, - array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit, - 'USE INDEX' => array('recentchanges' => 'rc_timestamp') ), + array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) + + $query_options, $join_conds ); // We have a new_namespace_time index! UNION over new=(0,1) and sort result set! } else { @@ -372,7 +393,7 @@ class SpecialRecentChanges extends SpecialPage { } $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title]; } - $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ) ); + $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter ); --$limit; } $s .= $list->endRecentChangesList(); @@ -453,6 +474,10 @@ class SpecialRecentChanges extends SpecialPage { $extraOpts['category'] = $this->categoryFilterForm( $opts ); } + $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] ); + if ( count($tagFilter) ) + $extraOpts['tagfilter'] = $tagFilter; + wfRunHooks( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) ); return $extraOpts; } @@ -587,14 +612,14 @@ class SpecialRecentChanges extends SpecialPage { $options = $nondefaults + $defaults; $note = ''; + if( !wfEmptyMsg( 'rclegend', wfMsg('rclegend') ) ) { + $note .= '<div class="mw-rclegend">' . wfMsgExt( 'rclegend', array('parseinline') ) . "</div>\n"; + } if( $options['from'] ) { $note .= wfMsgExt( 'rcnotefrom', array( 'parseinline' ), $wgLang->formatNum( $options['limit'] ), $wgLang->timeanddate( $options['from'], true ) ) . '<br />'; } - if( !wfEmptyMsg( 'rclegend', wfMsg('rclegend') ) ) { - $note .= wfMsgExt( 'rclegend', array('parseinline') ) . '<br />'; - } # Sort data for display and make sure it's unique after we've added user data. $wgRCLinkLimits[] = $options['limit']; @@ -609,14 +634,14 @@ class SpecialRecentChanges extends SpecialPage { $cl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ), array( 'limit' => $value ), $nondefaults, $value == $options['limit'] ) ; } - $cl = implode( ' | ', $cl ); + $cl = $wgLang->pipeList( $cl ); // day links, reset 'from' to none foreach( $wgRCLinkDays as $value ) { $dl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ), array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] ) ; } - $dl = implode( ' | ', $dl ); + $dl = $wgLang->pipeList( $dl ); // show/hide links @@ -641,7 +666,7 @@ class SpecialRecentChanges extends SpecialPage { if( $wgUser->useRCPatrol() ) $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink ); $links[] = wfMsgHtml( 'rcshowhidemine', $myselfLink ); - $hl = implode( ' | ', $links ); + $hl = $wgLang->pipeList( $links ); // show from this onward link $now = $wgLang->timeanddate( wfTimestampNow(), true ); |