summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialRecentchanges.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialRecentchanges.php')
-rw-r--r--includes/specials/SpecialRecentchanges.php100
1 files changed, 63 insertions, 37 deletions
diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php
index 2bd8b0a9..008678f7 100644
--- a/includes/specials/SpecialRecentchanges.php
+++ b/includes/specials/SpecialRecentchanges.php
@@ -42,16 +42,16 @@ class SpecialRecentChanges extends IncludableSpecialPage {
public function getDefaultOptions() {
$opts = new FormOptions();
- $opts->add( 'days', (int)$this->getUser()->getOption( 'rcdays' ) );
- $opts->add( 'limit', (int)$this->getUser()->getOption( 'rclimit' ) );
+ $opts->add( 'days', $this->getUser()->getIntOption( 'rcdays' ) );
+ $opts->add( 'limit', $this->getUser()->getIntOption( 'rclimit' ) );
$opts->add( 'from', '' );
- $opts->add( 'hideminor', $this->getUser()->getBoolOption( 'hideminor' ) );
- $opts->add( 'hidebots', true );
- $opts->add( 'hideanons', false );
- $opts->add( 'hideliu', false );
+ $opts->add( 'hideminor', $this->getUser()->getBoolOption( 'hideminor' ) );
+ $opts->add( 'hidebots', true );
+ $opts->add( 'hideanons', false );
+ $opts->add( 'hideliu', false );
$opts->add( 'hidepatrolled', $this->getUser()->getBoolOption( 'hidepatrolled' ) );
- $opts->add( 'hidemyself', false );
+ $opts->add( 'hidemyself', false );
$opts->add( 'namespace', '', FormOptions::INTNULL );
$opts->add( 'invert', false );
@@ -109,8 +109,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
public function feedSetup() {
global $wgFeedLimit;
$opts = $this->getDefaultOptions();
- # Feed is cached on limit,hideminor,namespace; other params would randomly not work
- $opts->fetchValuesFromRequest( $this->getRequest(), array( 'limit', 'hideminor', 'namespace' ) );
+ $opts->fetchValuesFromRequest( $this->getRequest() );
$opts->validateIntBounds( 'limit', 0, $wgFeedLimit );
return $opts;
}
@@ -130,7 +129,6 @@ class SpecialRecentChanges extends IncludableSpecialPage {
return $this->rcOptions;
}
-
/**
* Main execution point
*
@@ -156,7 +154,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
// Fetch results, prepare a batch link existence check query
$conds = $this->buildMainQueryConds( $opts );
$rows = $this->doMainQuery( $conds, $opts );
- if( $rows === false ){
+ if( $rows === false ) {
if( !$this->including() ) {
$this->doHeader( $opts );
}
@@ -187,7 +185,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
*
* @return Array
*/
- public function getFeedObject( $feedFormat ){
+ public function getFeedObject( $feedFormat ) {
$changesFeed = new ChangesFeed( $feedFormat, 'rcfeed' );
$formatter = $changesFeed->getFeedObject(
$this->msg( 'recentchanges' )->inContentLanguage()->text(),
@@ -233,7 +231,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
}
if( is_numeric( $bit ) ) {
- $opts['limit'] = $bit;
+ $opts['limit'] = $bit;
}
$m = array();
@@ -282,9 +280,9 @@ class SpecialRecentChanges extends IncludableSpecialPage {
# It makes no sense to hide both anons and logged-in users
# Where this occurs, force anons to be shown
$forcebot = false;
- if( $opts['hideanons'] && $opts['hideliu'] ){
+ if( $opts['hideanons'] && $opts['hideliu'] ) {
# Check if the user wants to show bots only
- if( $opts['hidebots'] ){
+ if( $opts['hidebots'] ) {
$opts['hideanons'] = false;
} else {
$forcebot = true;
@@ -297,9 +295,9 @@ class SpecialRecentChanges extends IncludableSpecialPage {
$cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400);
$cutoff = $dbr->timestamp( $cutoff_unixtime );
- $fromValid = preg_match('/^[0-9]{14}$/', $opts['from']);
- if( $fromValid && $opts['from'] > wfTimestamp(TS_MW,$cutoff) ) {
- $cutoff = $dbr->timestamp($opts['from']);
+ $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
+ if( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
+ $cutoff = $dbr->timestamp( $opts['from'] );
} else {
$opts->reset( 'from' );
}
@@ -341,7 +339,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
if( $opts['namespace'] !== '' ) {
$selectedNS = $dbr->addQuotes( $opts['namespace'] );
$operator = $opts['invert'] ? '!=' : '=';
- $boolean = $opts['invert'] ? 'AND' : 'OR';
+ $boolean = $opts['invert'] ? 'AND' : 'OR';
# namespace association (bug 2429)
if( !$opts['associated'] ) {
@@ -352,8 +350,8 @@ class SpecialRecentChanges extends IncludableSpecialPage {
MWNamespace::getAssociated( $opts['namespace'] )
);
$condition = "(rc_namespace $operator $selectedNS "
- . $boolean
- . " rc_namespace $operator $associatedNS)";
+ . $boolean
+ . " rc_namespace $operator $associatedNS)";
}
$conds[] = $condition;
@@ -382,19 +380,22 @@ class SpecialRecentChanges extends IncludableSpecialPage {
$invert = $opts['invert'];
$associated = $opts['associated'];
- $fields = array( $dbr->tableName( 'recentchanges' ) . '.*' ); // all rc columns
+ $fields = RecentChange::selectFields();
// JOIN on watchlist for users
if ( $uid ) {
$tables[] = 'watchlist';
$fields[] = 'wl_user';
$fields[] = 'wl_notificationtimestamp';
- $join_conds['watchlist'] = array('LEFT JOIN',
- "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace");
+ $join_conds['watchlist'] = array( 'LEFT JOIN', array(
+ 'wl_user' => $uid,
+ 'wl_title=rc_title',
+ 'wl_namespace=rc_namespace'
+ ));
}
if ( $this->getUser()->isAllowed( 'rollback' ) ) {
$tables[] = 'page';
$fields[] = 'page_latest';
- $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
+ $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
}
// Tag stuff.
ChangeTags::modifyDisplayQuery(
@@ -467,7 +468,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
/**
* Send output to the OutputPage object, only called if not used feeds
*
- * @param $rows Array of database rows
+ * @param array $rows of database rows
* @param $opts FormOptions
*/
public function webOutput( $rows, $opts ) {
@@ -481,7 +482,12 @@ class SpecialRecentChanges extends IncludableSpecialPage {
}
// And now for the content
- $this->getOutput()->setFeedAppendQuery( $this->getFeedQuery() );
+ $feedQuery = $this->getFeedQuery();
+ if ( $feedQuery !== '' ) {
+ $this->getOutput()->setFeedAppendQuery( $feedQuery );
+ } else {
+ $this->getOutput()->setFeedAppendQuery( false );
+ }
if( $wgAllowCategorizedRecentChanges ) {
$this->filterByCategories( $rows, $opts );
@@ -525,8 +531,12 @@ class SpecialRecentChanges extends IncludableSpecialPage {
}
$rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
}
- $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
- --$limit;
+
+ $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
+ if ( $changeLine !== false ) {
+ $s .= $changeLine;
+ --$limit;
+ }
}
$s .= $list->endRecentChangesList();
$this->getOutput()->addHTML( $s );
@@ -534,11 +544,24 @@ class SpecialRecentChanges extends IncludableSpecialPage {
/**
* Get the query string to append to feed link URLs.
- * This is overridden by RCL to add the target parameter
- * @return bool
+ *
+ * @return string
*/
public function getFeedQuery() {
- return false;
+ global $wgFeedLimit;
+
+ $this->getOptions()->validateIntBounds( 'limit', 0, $wgFeedLimit );
+ $options = $this->getOptions()->getChangedValues();
+
+ // wfArrayToCgi() omits options set to null or false
+ foreach ( $options as &$value ) {
+ if ( $value === false ) {
+ $value = '0';
+ }
+ }
+ unset( $value );
+
+ return wfArrayToCgi( $options );
}
/**
@@ -701,11 +724,11 @@ class SpecialRecentChanges extends IncludableSpecialPage {
/**
* Filter $rows by categories set in $opts
*
- * @param $rows Array of database rows
+ * @param array $rows of database rows
* @param $opts FormOptions
*/
function filterByCategories( &$rows, FormOptions $opts ) {
- $categories = array_map( 'trim', explode( '|' , $opts['categories'] ) );
+ $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
if( !count( $categories ) ) {
return;
@@ -766,8 +789,8 @@ class SpecialRecentChanges extends IncludableSpecialPage {
* Makes change an option link which carries all the other options
*
* @param $title Title
- * @param $override Array: options to override
- * @param $options Array: current options
+ * @param array $override options to override
+ * @param array $options current options
* @param $active Boolean: whether to show the link in bold
* @return string
*/
@@ -839,7 +862,6 @@ class SpecialRecentChanges extends IncludableSpecialPage {
}
$dl = $lang->pipeList( $dl );
-
// show/hide links
$showhide = array( $this->msg( 'show' )->text(), $this->msg( 'hide' )->text() );
$filters = array(
@@ -885,4 +907,8 @@ class SpecialRecentChanges extends IncludableSpecialPage {
'mediawiki.special.recentchanges',
) );
}
+
+ protected function getGroupName() {
+ return 'changes';
+ }
}