* @todo document functions and variables
*/
class RecentChange {
-
// Constants for the rc_source field. Extensions may also have
// their own source constants.
const SRC_EDIT = 'mw.edit';
const SRC_LOG = 'mw.log';
const SRC_EXTERNAL = 'mw.external'; // obsolete
- var $mAttribs = array(), $mExtra = array();
+ public $mAttribs = array();
+ public $mExtra = array();
/**
* @var Title
*/
- var $mTitle = false;
+ public $mTitle = false;
/**
* @var User
*/
private $mPerformer = false;
+ public $numberofWatchingusers = 0; # Dummy to prevent error message in SpecialRecentChangesLinked
+ public $notificationtimestamp;
+
/**
- * @var Title
+ * @var int Line number of recent change. Default -1.
*/
- var $mMovedToTitle = false;
- var $numberofWatchingusers = 0; # Dummy to prevent error message in SpecialRecentchangeslinked
- var $notificationtimestamp;
+ public $counter = -1;
# Factory methods
public static function newFromRow( $row ) {
$rc = new RecentChange;
$rc->loadFromRow( $row );
+
return $rc;
}
/**
+ * No uses left in Gerrit on 2013-11-19.
* @deprecated in 1.22
* @param $row
* @return RecentChange
$rc->loadFromCurRow( $row );
$rc->notificationtimestamp = false;
$rc->numberofWatchingusers = false;
+
return $rc;
}
if ( $this->mTitle === false ) {
$this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
}
+
return $this->mTitle;
}
$this->mPerformer = User::newFromName( $this->mAttribs['rc_user_text'], false );
}
}
+
return $this->mPerformer;
}
'add_interwiki_prefix' => $wgRC2UDPInterwikiPrefix,
);
- return $engine->send( $feed, $line );
+ $engine->send( $feed, $line );
}
/**
continue;
}
+ /** @var $formatter RCFeedFormatter */
$formatter = new $feed['formatter']();
$line = $formatter->getLine( $feed, $this, $actionComment );
/**
* Gets the stream engine object for a given URI from $wgRCEngines
*
- * @param $uri string URI to get the engine object for
+ * @param string $uri URI to get the engine object for
+ * @throws MWException
* @return object The engine object
*/
private static function getEngine( $uri ) {
*/
public static function cleanupForIRC( $text ) {
wfDeprecated( __METHOD__, '1.22' );
+
return IRCColourfulRCFeedFormatter::cleanupForIRC( $text );
}
if ( !$change instanceof RecentChange ) {
return null;
}
+
return $change->doMarkPatrolled( $wgUser, $auto );
}
/**
* Mark this RecentChange as patrolled
*
- * NOTE: Can also return 'rcpatroldisabled', 'hookaborted' and 'markedaspatrollederror-noautopatrol' as errors
+ * NOTE: Can also return 'rcpatroldisabled', 'hookaborted' and
+ * 'markedaspatrollederror-noautopatrol' as errors
* @param $user User object doing the action
* @param $auto Boolean: for automatic patrol
* @return array of permissions errors, see Title::getUserPermissionsErrors()
}
// Users without the 'autopatrol' right can't patrol their
// own revisions
- if ( $user->getName() == $this->getAttribute( 'rc_user_text' ) && !$user->isAllowed( 'autopatrol' ) ) {
+ if ( $user->getName() == $this->getAttribute( 'rc_user_text' )
+ && !$user->isAllowed( 'autopatrol' )
+ ) {
$errors[] = array( 'markedaspatrollederror-noautopatrol' );
}
if ( $errors ) {
// Log this patrol event
PatrolLog::record( $this, $auto, $user );
wfRunHooks( 'MarkPatrolledComplete', array( $this->getAttribute( 'rc_id' ), &$user, false ) );
+
return array();
}
// Invalidate the page cache after the page has been patrolled
// to make sure that the Patrol link isn't visible any longer!
$this->getTitle()->invalidateCache();
+
return $dbw->affectedRows();
}
$rc->mTitle = $title;
$rc->mPerformer = $user;
$rc->mAttribs = array(
- 'rc_timestamp' => $timestamp,
- 'rc_namespace' => $title->getNamespace(),
- 'rc_title' => $title->getDBkey(),
- 'rc_type' => RC_EDIT,
- 'rc_source' => self::SRC_EDIT,
- 'rc_minor' => $minor ? 1 : 0,
- 'rc_cur_id' => $title->getArticleID(),
- 'rc_user' => $user->getId(),
- 'rc_user_text' => $user->getName(),
- 'rc_comment' => $comment,
+ 'rc_timestamp' => $timestamp,
+ 'rc_namespace' => $title->getNamespace(),
+ 'rc_title' => $title->getDBkey(),
+ 'rc_type' => RC_EDIT,
+ 'rc_source' => self::SRC_EDIT,
+ 'rc_minor' => $minor ? 1 : 0,
+ 'rc_cur_id' => $title->getArticleID(),
+ 'rc_user' => $user->getId(),
+ 'rc_user_text' => $user->getName(),
+ 'rc_comment' => $comment,
'rc_this_oldid' => $newId,
'rc_last_oldid' => $oldId,
- 'rc_bot' => $bot ? 1 : 0,
- 'rc_ip' => self::checkIPAddress( $ip ),
- 'rc_patrolled' => intval( $patrol ),
- 'rc_new' => 0, # obsolete
- 'rc_old_len' => $oldSize,
- 'rc_new_len' => $newSize,
- 'rc_deleted' => 0,
- 'rc_logid' => 0,
- 'rc_log_type' => null,
+ 'rc_bot' => $bot ? 1 : 0,
+ 'rc_ip' => self::checkIPAddress( $ip ),
+ 'rc_patrolled' => intval( $patrol ),
+ 'rc_new' => 0, # obsolete
+ 'rc_old_len' => $oldSize,
+ 'rc_new_len' => $newSize,
+ 'rc_deleted' => 0,
+ 'rc_logid' => 0,
+ 'rc_log_type' => null,
'rc_log_action' => '',
- 'rc_params' => ''
+ 'rc_params' => ''
);
$rc->mExtra = array(
'prefixedDBkey' => $title->getPrefixedDBkey(),
'lastTimestamp' => $lastTimestamp,
- 'oldSize' => $oldSize,
- 'newSize' => $newSize,
- 'pageStatus' => 'changed'
+ 'oldSize' => $oldSize,
+ 'newSize' => $newSize,
+ 'pageStatus' => 'changed'
);
$rc->save();
+
return $rc;
}
$rc->mTitle = $title;
$rc->mPerformer = $user;
$rc->mAttribs = array(
- 'rc_timestamp' => $timestamp,
- 'rc_namespace' => $title->getNamespace(),
- 'rc_title' => $title->getDBkey(),
- 'rc_type' => RC_NEW,
- 'rc_source' => self::SRC_NEW,
- 'rc_minor' => $minor ? 1 : 0,
- 'rc_cur_id' => $title->getArticleID(),
- 'rc_user' => $user->getId(),
- 'rc_user_text' => $user->getName(),
- 'rc_comment' => $comment,
- 'rc_this_oldid' => $newId,
- 'rc_last_oldid' => 0,
- 'rc_bot' => $bot ? 1 : 0,
- 'rc_ip' => self::checkIPAddress( $ip ),
- 'rc_patrolled' => intval( $patrol ),
- 'rc_new' => 1, # obsolete
- 'rc_old_len' => 0,
- 'rc_new_len' => $size,
- 'rc_deleted' => 0,
- 'rc_logid' => 0,
- 'rc_log_type' => null,
- 'rc_log_action' => '',
- 'rc_params' => ''
+ 'rc_timestamp' => $timestamp,
+ 'rc_namespace' => $title->getNamespace(),
+ 'rc_title' => $title->getDBkey(),
+ 'rc_type' => RC_NEW,
+ 'rc_source' => self::SRC_NEW,
+ 'rc_minor' => $minor ? 1 : 0,
+ 'rc_cur_id' => $title->getArticleID(),
+ 'rc_user' => $user->getId(),
+ 'rc_user_text' => $user->getName(),
+ 'rc_comment' => $comment,
+ 'rc_this_oldid' => $newId,
+ 'rc_last_oldid' => 0,
+ 'rc_bot' => $bot ? 1 : 0,
+ 'rc_ip' => self::checkIPAddress( $ip ),
+ 'rc_patrolled' => intval( $patrol ),
+ 'rc_new' => 1, # obsolete
+ 'rc_old_len' => 0,
+ 'rc_new_len' => $size,
+ 'rc_deleted' => 0,
+ 'rc_logid' => 0,
+ 'rc_log_type' => null,
+ 'rc_log_action' => '',
+ 'rc_params' => ''
);
$rc->mExtra = array(
'pageStatus' => 'created'
);
$rc->save();
+
return $rc;
}
* @return bool
*/
public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip, $type,
- $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '' )
- {
+ $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = ''
+ ) {
global $wgLogRestrictions;
+
# Don't add private logs to RC!
if ( isset( $wgLogRestrictions[$type] ) && $wgLogRestrictions[$type] != '*' ) {
return false;
$rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action,
$target, $logComment, $params, $newId, $actionCommentIRC );
$rc->save();
+
return true;
}
$rc->mTitle = $target;
$rc->mPerformer = $user;
$rc->mAttribs = array(
- 'rc_timestamp' => $timestamp,
- 'rc_namespace' => $target->getNamespace(),
- 'rc_title' => $target->getDBkey(),
- 'rc_type' => RC_LOG,
- 'rc_source' => self::SRC_LOG,
- 'rc_minor' => 0,
- 'rc_cur_id' => $target->getArticleID(),
- 'rc_user' => $user->getId(),
- 'rc_user_text' => $user->getName(),
- 'rc_comment' => $logComment,
+ 'rc_timestamp' => $timestamp,
+ 'rc_namespace' => $target->getNamespace(),
+ 'rc_title' => $target->getDBkey(),
+ 'rc_type' => RC_LOG,
+ 'rc_source' => self::SRC_LOG,
+ 'rc_minor' => 0,
+ 'rc_cur_id' => $target->getArticleID(),
+ 'rc_user' => $user->getId(),
+ 'rc_user_text' => $user->getName(),
+ 'rc_comment' => $logComment,
'rc_this_oldid' => 0,
'rc_last_oldid' => 0,
- 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
- 'rc_ip' => self::checkIPAddress( $ip ),
- 'rc_patrolled' => 1,
- 'rc_new' => 0, # obsolete
- 'rc_old_len' => null,
- 'rc_new_len' => null,
- 'rc_deleted' => 0,
- 'rc_logid' => $newId,
- 'rc_log_type' => $type,
+ 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
+ 'rc_ip' => self::checkIPAddress( $ip ),
+ 'rc_patrolled' => 1,
+ 'rc_new' => 0, # obsolete
+ 'rc_old_len' => null,
+ 'rc_new_len' => null,
+ 'rc_deleted' => 0,
+ 'rc_logid' => $newId,
+ 'rc_log_type' => $type,
'rc_log_action' => $action,
- 'rc_params' => $params
+ 'rc_params' => $params
);
$rc->mExtra = array(
'prefixedDBkey' => $title->getPrefixedDBkey(),
'lastTimestamp' => 0,
'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
- 'pageStatus' => $pageStatus,
+ 'pageStatus' => $pageStatus,
'actionCommentIRC' => $actionCommentIRC
);
+
return $rc;
}
} else {
$trail = '';
}
+
return $trail;
}
if ( $old === null || $new === null ) {
return '';
}
+
return ChangesList::showCharacterDifference( $old, $new );
}
$method = __METHOD__;
$dbw = wfGetDB( DB_MASTER );
- $dbw->onTransactionIdle( function() use ( $dbw, $method ) {
+ $dbw->onTransactionIdle( function () use ( $dbw, $method ) {
global $wgRCMaxAge;
$cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
global $wgRequest;
if ( $ip ) {
if ( !IP::isIPAddress( $ip ) ) {
- throw new MWException( "Attempt to write \"" . $ip . "\" as an IP address into recent changes" );
+ throw new MWException( "Attempt to write \"" . $ip .
+ "\" as an IP address into recent changes" );
}
} else {
$ip = $wgRequest->getIP();
$ip = '';
}
}
+
return $ip;
}
*/
public static function isInRCLifespan( $timestamp, $tolerance = 0 ) {
global $wgRCMaxAge;
+
return wfTimestamp( TS_UNIX, $timestamp ) > time() - $tolerance - $wgRCMaxAge;
}
}