MediaWiki REL1_41
RecentChange Class Reference

Utility class for creating new RC entries. More...

Inherits MediaWiki\ChangeTags\Taggable.

Inherited by RCCacheEntry.

Collaboration diagram for RecentChange:

Public Member Functions

 __construct ()
 
 addTags ( $tags)
 Tags to append to the recent change, and associated revision/log.
 
 diffLinkTrail ( $forceCur)
 Gets the end part of the diff URL associated with this object Blank if no diff link should be displayed.
 
 doMarkPatrolled (Authority $performer, $auto=null, $tags=null)
 Mark this RecentChange as patrolled.
 
 getAttribute ( $name)
 Get an attribute value.
 
 getAttributes ()
 
 getCharacterDifference ( $old=0, $new=0)
 Returns the change size (HTML).
 
 getNotifyUrl ()
 Get the extra URL that is given as part of the notification to RCFeed consumers.
 
 getPage ()
 
 getParam ( $name)
 Get a parameter value.
 
 getPerformerIdentity ()
 Get the UserIdentity of the client that performed this change.
 
 getTitle ()
 
 loadFromRow ( $row)
 Initialises the members of this object from a mysql row object.
 
 notifyRCFeeds (array $feeds=null)
 Notify all the feeds about the change.
 
 parseParams ()
 Parses and returns the rc_params attribute.
 
 reallyMarkPatrolled ()
 Mark this RecentChange patrolled, without error checking.
 
 save ( $send=self::SEND_FEED)
 Writes the data in this object to the database.
 
 setAttribs ( $attribs)
 
 setEditResult (?EditResult $editResult)
 Sets the EditResult associated with the edit.
 
 setExtra ( $extra)
 

Static Public Member Functions

static getChangeTypes ()
 Get an array of all change types.
 
static getQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new recentchanges object.
 
static isEnotifEnabled (Config $conf)
 Whether e-mail notifications are generally enabled on this wiki.
 
static isInRCLifespan ( $timestamp, $tolerance=0)
 Check whether the given timestamp is new enough to have a RC row with a given tolerance as the recentchanges table might not be cleared out regularly (so older entries might exist) or rows which will be deleted soon shouldn't be included.
 
static newForCategorization ( $timestamp, PageIdentity $categoryTitle, ?UserIdentity $user, $comment, PageIdentity $pageTitle, $oldRevId, $newRevId, $lastTimestamp, $bot, $ip='', $deleted=0, $added=null)
 Constructs a RecentChange object for the given categorization This does not call save() on the object and thus does not write to the db.
 
static newFromConds ( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
 Find the first recent change matching some specific conditions.
 
static newFromId ( $rcid)
 Obtain the recent change with a given rc_id value.
 
static newFromRow ( $row)
 
static newLogEntry ( $timestamp, $logPage, $user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='', $revId=0, $isPatrollable=false, $forceBotFlag=null)
 
static notifyEdit ( $timestamp, $page, $minor, $user, $comment, $oldId, $lastTimestamp, $bot, $ip='', $oldSize=0, $newSize=0, $newId=0, $patrol=0, $tags=[], EditResult $editResult=null)
 Makes an entry in the database corresponding to an edit.
 
static notifyLog ( $timestamp, $logPage, $user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='')
 
static notifyNew ( $timestamp, $page, $minor, $user, $comment, $bot, $ip='', $size=0, $newId=0, $patrol=0, $tags=[])
 Makes an entry in the database corresponding to page creation.
 
static parseFromRCType ( $rcType)
 Parsing RC_* constants to human-readable test.
 
static parseToRCType ( $type)
 Parsing text to RC_* constants.
 

Public Attributes

int $counter = -1
 Line number of recent change.
 
array $mAttribs = []
 
 $mExtra = []
 
 $notificationtimestamp
 
 $numberofWatchingusers = 0
 
string null $watchlistExpiry
 The expiry time, if this is a temporary watchlist item.
 
const PRC_AUTOPATROLLED = 2
 
const PRC_PATROLLED = 1
 
const PRC_UNPATROLLED = 0
 
const SRC_CATEGORIZE = 'mw.categorize'
 
const SRC_EDIT = 'mw.edit'
 
const SRC_EXTERNAL = 'mw.external'
 
const SRC_LOG = 'mw.log'
 
const SRC_NEW = 'mw.new'
 

Detailed Description

Utility class for creating new RC entries.

mAttribs: rc_id id of the row in the recentchanges table rc_timestamp time the entry was made rc_namespace namespace # rc_title non-prefixed db key rc_type is new entry, used to determine whether updating is necessary rc_source string representation of change source rc_minor is minor rc_cur_id page_id of associated page entry rc_user user id who made the entry rc_user_text user name who made the entry rc_comment edit summary rc_this_oldid rev_id associated with this entry (or zero) rc_last_oldid rev_id associated with the entry before this one (or zero) rc_bot is bot, hidden rc_ip IP address of the user in dotted quad notation rc_new obsolete, use rc_type==RC_NEW rc_patrolled boolean whether or not someone has marked this edit as patrolled rc_old_len integer byte length of the text before the edit rc_new_len the same after the edit rc_deleted partial deletion rc_logid the log_id value for this log entry (or zero) rc_log_type the log type (or null) rc_log_action the log action (or null) rc_params log params

mExtra: prefixedDBkey prefixed db key, used by external app via msg queue lastTimestamp timestamp of previous entry, used in WHERE clause during update oldSize text size before the change newSize text size after the change pageStatus status of the page: created, deleted, moved, restored, changed

temporary: not stored in the database notificationtimestamp numberofWatchingusers watchlistExpiry for temporary watchlist items

Todo
Deprecate access to mAttribs (direct or via getAttributes). Right now we're having to include both rc_comment and rc_comment_text/rc_comment_data so random crap works right.

Definition at line 87 of file RecentChange.php.

Constructor & Destructor Documentation

◆ __construct()

RecentChange::__construct ( )

Definition at line 306 of file RecentChange.php.

References deprecatePublicPropertyFallback().

Member Function Documentation

◆ addTags()

RecentChange::addTags ( $tags)

Tags to append to the recent change, and associated revision/log.

Since
1.28
Parameters
string | string[]$tags

Implements MediaWiki\ChangeTags\Taggable.

Definition at line 1346 of file RecentChange.php.

◆ diffLinkTrail()

RecentChange::diffLinkTrail ( $forceCur)

Gets the end part of the diff URL associated with this object Blank if no diff link should be displayed.

Parameters
bool$forceCur
Returns
string

Definition at line 1180 of file RecentChange.php.

References RC_EDIT.

◆ doMarkPatrolled()

RecentChange::doMarkPatrolled ( Authority $performer,
$auto = null,
$tags = null )

Mark this RecentChange as patrolled.

NOTE: Can also return 'rcpatroldisabled', 'hookaborted' and 'markedaspatrollederror-noautopatrol' as errors

Parameters
Authority$performerUser performing the action
bool | null$autoUnused. Passing true logs a warning.
string | string[] | null$tagsChange tags to add to the patrol log entry ($user should be able to add the specified tags before this is called)
Returns
array[] Array of permissions errors, see PermissionManager::getPermissionErrors()

Definition at line 587 of file RecentChange.php.

References MediaWiki\Permissions\Authority\authorizeWrite(), getTitle(), MediaWiki\Permissions\Authority\getUser(), MediaWiki\Permissions\Authority\isAllowed(), RC_LOG, RC_NEW, PatrolLog\record(), and wfWarn().

◆ getAttribute()

RecentChange::getAttribute ( $name)

Get an attribute value.

Parameters
string$nameAttribute name
Returns
mixed

Definition at line 1140 of file RecentChange.php.

References wfDeprecatedMsg().

Referenced by ChangesList\getDataAttributes(), EnhancedChangesList\getDiffHistLinks(), MachineReadableRCFeedFormatter\getLine(), and MediaWiki\Specials\SpecialWatchlist\isChangeEffectivelySeen().

◆ getAttributes()

RecentChange::getAttributes ( )
Returns
array

Definition at line 1170 of file RecentChange.php.

Referenced by IRCColourfulRCFeedFormatter\getLine().

◆ getChangeTypes()

static RecentChange::getChangeTypes ( )
static

Get an array of all change types.

Since
1.26
Returns
array

Definition at line 210 of file RecentChange.php.

◆ getCharacterDifference()

RecentChange::getCharacterDifference ( $old = 0,
$new = 0 )

Returns the change size (HTML).

The lengths can be given optionally.

Parameters
int$old
int$new
Returns
string

Definition at line 1203 of file RecentChange.php.

◆ getNotifyUrl()

RecentChange::getNotifyUrl ( )

Get the extra URL that is given as part of the notification to RCFeed consumers.

This is mainly to facilitate patrolling or other content review.

Since
1.40
Returns
string|null URL

Definition at line 1291 of file RecentChange.php.

References RC_LOG, and RC_NEW.

Referenced by IRCColourfulRCFeedFormatter\getLine(), and MachineReadableRCFeedFormatter\getLine().

◆ getPage()

RecentChange::getPage ( )
Since
1.37
Returns
?PageReference

Definition at line 348 of file RecentChange.php.

Referenced by getTitle().

◆ getParam()

RecentChange::getParam ( $name)

Get a parameter value.

Since
1.27
Parameters
string$nameparameter name
Returns
mixed

Definition at line 1096 of file RecentChange.php.

◆ getPerformerIdentity()

RecentChange::getPerformerIdentity ( )

Get the UserIdentity of the client that performed this change.

Since
1.36
Returns
UserIdentity

Definition at line 379 of file RecentChange.php.

◆ getQueryInfo()

static RecentChange::getQueryInfo ( )
static

Return the tables, fields, and join conditions to be selected to create a new recentchanges object.

Since 1.34, rc_user and rc_user_text have not been present in the database, but they continue to be available in query results as aliases.

Since
1.31
Returns
array[] With three keys:
  • tables: (string[]) to include in the $table to IDatabase->select() or SelectQueryBuilder::tables
  • fields: (string[]) to include in the $vars to IDatabase->select() or SelectQueryBuilder::fields
  • joins: (array) to include in the $join_conds to IDatabase->select() or SelectQueryBuilder::joinConds

Definition at line 265 of file RecentChange.php.

◆ getTitle()

◆ isEnotifEnabled()

static RecentChange::isEnotifEnabled ( Config $conf)
static

Whether e-mail notifications are generally enabled on this wiki.

This is used for:

  • performance optimization in RecentChange::save(). After an edit, whether or not we need to use the EmailNotification service to determine which EnotifNotifyJob to dispatch.
  • performance optmization in WatchlistManager. After using reset ("Mark all pages as seen") on Special:Watchlist, whether to only look for user talk data to reset, or whether to look at all possible pages for timestamps to reset.

TODO: Determine whether these optimizations still make sense.

FIXME: The $wgShowUpdatedMarker variable was added to this condtion in 2008 (2cf12c973d, SVN r35001) because at the time the per-user "last seen" marker for watchlist and page history, was managed by the EmailNotification/UserMailed classes. As of August 2022, this appears to no longer be the case.

Since
1.40
Parameters
Config$conf
Returns
bool

Definition at line 1277 of file RecentChange.php.

◆ isInRCLifespan()

static RecentChange::isInRCLifespan ( $timestamp,
$tolerance = 0 )
static

Check whether the given timestamp is new enough to have a RC row with a given tolerance as the recentchanges table might not be cleared out regularly (so older entries might exist) or rows which will be deleted soon shouldn't be included.

Parameters
mixed$timestampMWTimestamp compatible timestamp
int$toleranceTolerance in seconds
Returns
bool

Definition at line 1244 of file RecentChange.php.

References wfTimestamp().

◆ loadFromRow()

RecentChange::loadFromRow ( $row)

Initialises the members of this object from a mysql row object.

Parameters
mixed$row

Definition at line 1106 of file RecentChange.php.

References DB_REPLICA, wfGetDB(), and wfTimestamp().

Referenced by newFromRow().

◆ newForCategorization()

static RecentChange::newForCategorization ( $timestamp,
PageIdentity $categoryTitle,
?UserIdentity $user,
$comment,
PageIdentity $pageTitle,
$oldRevId,
$newRevId,
$lastTimestamp,
$bot,
$ip = '',
$deleted = 0,
$added = null )
static

Constructs a RecentChange object for the given categorization This does not call save() on the object and thus does not write to the db.

Since
1.27
Parameters
string$timestampTimestamp of the recent change to occur
PageIdentity$categoryTitlethe category a page is being added to or removed from
UserIdentity | null$userUser object of the user that made the change
string$commentChange summary
PageIdentity$pageTitlethe page that is being added or removed
int$oldRevIdParent revision ID of this change
int$newRevIdRevision ID of this change
string$lastTimestampParent revision timestamp of this change
bool$bottrue, if the change was made by a bot
string$ipIP address of the user, if the change was made anonymously
int$deletedIndicates whether the change has been deleted
bool | null$addedtrue, if the category was added, false for removed
Returns
RecentChange

Definition at line 1009 of file RecentChange.php.

References MediaWiki\Page\PageReference\getDBkey(), MediaWiki\Page\PageIdentity\getId(), MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\getName(), MediaWiki\Page\PageReference\getNamespace(), and RC_CATEGORIZE.

◆ newFromConds()

static RecentChange::newFromConds ( $conds,
$fname = __METHOD__,
$dbType = DB_REPLICA )
static

Find the first recent change matching some specific conditions.

Parameters
array$condsArray of conditions
mixed$fnameOverride the method name in profiling/logs
int$dbTypeDB_* constant
Returns
RecentChange|null

Definition at line 233 of file RecentChange.php.

References wfGetDB().

◆ newFromId()

static RecentChange::newFromId ( $rcid)
static

Obtain the recent change with a given rc_id value.

Parameters
int$rcidThe rc_id value to retrieve
Returns
RecentChange|null

Definition at line 220 of file RecentChange.php.

◆ newFromRow()

static RecentChange::newFromRow ( $row)
static
Parameters
mixed$row
Returns
RecentChange

Definition at line 163 of file RecentChange.php.

References loadFromRow().

◆ newLogEntry()

static RecentChange::newLogEntry ( $timestamp,
$logPage,
$user,
$actionComment,
$ip,
$type,
$action,
$target,
$logComment,
$params,
$newId = 0,
$actionCommentIRC = '',
$revId = 0,
$isPatrollable = false,
$forceBotFlag = null )
static
Parameters
string$timestamp
PageReference$logPage
UserIdentity$user
string$actionComment
string$ip
string$type
string$action
PageReference$target
string$logComment
string$params
int$newId
string$actionCommentIRC
int$revIdId of associated revision, if any
bool$isPatrollableWhether this log entry is patrollable
bool | null$forceBotFlagOverride the default behavior and set bot flag to the value of the argument. When omitted or null, it falls back to the global state.
Returns
RecentChange

Definition at line 891 of file RecentChange.php.

References $wgRequest, MediaWiki\Page\PageIdentity\canExist(), and RC_LOG.

◆ notifyEdit()

static RecentChange::notifyEdit ( $timestamp,
$page,
$minor,
$user,
$comment,
$oldId,
$lastTimestamp,
$bot,
$ip = '',
$oldSize = 0,
$newSize = 0,
$newId = 0,
$patrol = 0,
$tags = [],
EditResult $editResult = null )
static

Makes an entry in the database corresponding to an edit.

Since
1.36 Added $editResult parameter
Parameters
string$timestamp
PageIdentity$page
bool$minor
UserIdentity$user
string$comment
int$oldId
string$lastTimestamp
bool$bot
string$ip
int$oldSize
int$newSize
int$newId
int$patrol
string[]$tags
EditResult | null$editResultEditResult associated with this edit. Can be safely skipped if the edit is not a revert. Used only for marking revert tags.
Returns
RecentChange

Definition at line 694 of file RecentChange.php.

References RC_EDIT.

◆ notifyLog()

static RecentChange::notifyLog ( $timestamp,
$logPage,
$user,
$actionComment,
$ip,
$type,
$action,
$target,
$logComment,
$params,
$newId = 0,
$actionCommentIRC = '' )
static
Parameters
string$timestamp
PageReference$logPage
UserIdentity$user
string$actionComment
string$ip
string$type
string$action
PageReference$target
string$logComment
string$params
int$newId
string$actionCommentIRC
Returns
bool

Definition at line 852 of file RecentChange.php.

◆ notifyNew()

static RecentChange::notifyNew ( $timestamp,
$page,
$minor,
$user,
$comment,
$bot,
$ip = '',
$size = 0,
$newId = 0,
$patrol = 0,
$tags = [] )
static

Makes an entry in the database corresponding to page creation.

Note
$page must reflect the state of the database after the page creation. In particular, $page->getId() must return the newly assigned page ID.
Parameters
string$timestamp
PageIdentity$page
bool$minor
UserIdentity$user
string$comment
bool$bot
string$ip
int$size
int$newId
int$patrol
string[]$tags
Returns
RecentChange

Definition at line 775 of file RecentChange.php.

References RC_NEW.

◆ notifyRCFeeds()

RecentChange::notifyRCFeeds ( array $feeds = null)

Notify all the feeds about the change.

Parameters
array | null$feedsOptional feeds to send to, defaults to $wgRCFeeds

Definition at line 543 of file RecentChange.php.

References RCFeed\factory(), and RC_EXTERNAL.

◆ parseFromRCType()

static RecentChange::parseFromRCType ( $rcType)
static

Parsing RC_* constants to human-readable test.

Since
1.24
Parameters
int$rcType
Returns
string

Definition at line 199 of file RecentChange.php.

◆ parseParams()

RecentChange::parseParams ( )

Parses and returns the rc_params attribute.

Since
1.26
Returns
mixed|bool false on failed unserialization

Definition at line 1328 of file RecentChange.php.

Referenced by MachineReadableRCFeedFormatter\getLine().

◆ parseToRCType()

static RecentChange::parseToRCType ( $type)
static

Parsing text to RC_* constants.

Since
1.24
Parameters
string | array$type
Exceptions
MWException
Returns
int|array RC_TYPE

Definition at line 177 of file RecentChange.php.

◆ reallyMarkPatrolled()

RecentChange::reallyMarkPatrolled ( )

Mark this RecentChange patrolled, without error checking.

Returns
int Number of affected rows

Definition at line 648 of file RecentChange.php.

References DB_PRIMARY, getTitle(), and wfGetDB().

◆ save()

RecentChange::save ( $send = self::SEND_FEED)

Writes the data in this object to the database.

For compatibility reasons, the SEND_ constants internally reference a value that may seem negated from their purpose (none=true, feed=false). This is because the parameter used to be called "$noudp", defaulting to false.

Parameters
bool$sendself::SEND_FEED or self::SEND_NONE

Definition at line 400 of file RecentChange.php.

References ChangeTags\addTags(), DB_PRIMARY, RC_CATEGORIZE, and wfGetDB().

◆ setAttribs()

RecentChange::setAttribs ( $attribs)
Parameters
array$attribs

Definition at line 324 of file RecentChange.php.

◆ setEditResult()

RecentChange::setEditResult ( ?EditResult $editResult)

Sets the EditResult associated with the edit.

Since
1.36
Parameters
EditResult | null$editResult

Definition at line 1361 of file RecentChange.php.

◆ setExtra()

RecentChange::setExtra ( $extra)
Parameters
array$extra

Definition at line 331 of file RecentChange.php.

Member Data Documentation

◆ $counter

int RecentChange::$counter = -1

Line number of recent change.

Default -1.

Definition at line 137 of file RecentChange.php.

◆ $mAttribs

array RecentChange::$mAttribs = []

Definition at line 113 of file RecentChange.php.

◆ $mExtra

RecentChange::$mExtra = []

Definition at line 114 of file RecentChange.php.

◆ $notificationtimestamp

RecentChange::$notificationtimestamp

Definition at line 127 of file RecentChange.php.

◆ $numberofWatchingusers

RecentChange::$numberofWatchingusers = 0

Definition at line 126 of file RecentChange.php.

◆ $watchlistExpiry

string null RecentChange::$watchlistExpiry

The expiry time, if this is a temporary watchlist item.

Definition at line 132 of file RecentChange.php.

◆ PRC_AUTOPATROLLED

const RecentChange::PRC_AUTOPATROLLED = 2

Definition at line 100 of file RecentChange.php.

◆ PRC_PATROLLED

const RecentChange::PRC_PATROLLED = 1

Definition at line 99 of file RecentChange.php.

◆ PRC_UNPATROLLED

const RecentChange::PRC_UNPATROLLED = 0

Definition at line 98 of file RecentChange.php.

◆ SRC_CATEGORIZE

const RecentChange::SRC_CATEGORIZE = 'mw.categorize'

Definition at line 96 of file RecentChange.php.

◆ SRC_EDIT

const RecentChange::SRC_EDIT = 'mw.edit'

Definition at line 92 of file RecentChange.php.

◆ SRC_EXTERNAL

const RecentChange::SRC_EXTERNAL = 'mw.external'

Definition at line 95 of file RecentChange.php.

◆ SRC_LOG

const RecentChange::SRC_LOG = 'mw.log'

Definition at line 94 of file RecentChange.php.

◆ SRC_NEW

const RecentChange::SRC_NEW = 'mw.new'

Definition at line 93 of file RecentChange.php.


The documentation for this class was generated from the following file: