MediaWiki  master
RecentChange Class Reference

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

Inheritance diagram for RecentChange:
Collaboration diagram for RecentChange:

Public Member Functions

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

Static Public Member Functions

static getChangeTypes ()
 Get an array of all change types. More...
 
static getEngine ( $uri, $params=[])
 
static getQueryInfo ()
 Return the tables, fields, and join conditions to be selected to create a new recentchanges object. More...
 
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. More...
 
static newForCategorization ( $timestamp, Title $categoryTitle, ?UserIdentity $user, $comment, Title $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. More...
 
static newFromConds ( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
 Find the first recent change matching some specific conditions. More...
 
static newFromId ( $rcid)
 Obtain the recent change with a given rc_id value. More...
 
static newFromRow ( $row)
 
static newLogEntry ( $timestamp, $title, $user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='', $revId=0, $isPatrollable=false)
 
static notifyEdit ( $timestamp, $title, $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. More...
 
static notifyLog ( $timestamp, $title, $user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='')
 
static notifyNew ( $timestamp, $title, $minor, $user, $comment, $bot, $ip='', $size=0, $newId=0, $patrol=0, $tags=[])
 Makes an entry in the database corresponding to page creation Note: the title object must be loaded with the new id using resetArticleID() More...
 
static parseFromRCType ( $rcType)
 Parsing RC_* constants to human-readable test. More...
 
static parseToRCType ( $type)
 Parsing text to RC_* constants. More...
 

Public Attributes

int $counter = -1
 Line number of recent change. More...
 
array $mAttribs = []
 
 $mExtra = []
 
Title false $mTitle = false
 
 $notificationtimestamp
 
 $numberofWatchingusers = 0
 
string null $watchlistExpiry
 The expiry time, if this is a temporary watchlist item. More...
 
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'
 

Private Member Functions

 getUserIdentityFromAnyId ( $userId, $userName, $actorId=null)
 

Static Private Member Functions

static checkIPAddress ( $ip)
 

Private Attributes

EditResult null $editResult = null
 EditResult associated with the edit. More...
 
UserIdentity null $mPerformer = null
 
array $tags = []
 List of tags to apply. More...
 

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 76 of file RecentChange.php.

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 1200 of file RecentChange.php.

References $tags.

◆ checkIPAddress()

static RecentChange::checkIPAddress (   $ip)
staticprivate

Definition at line 1143 of file RecentChange.php.

References $wgRequest.

Referenced by newLogEntry().

◆ 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 1106 of file RecentChange.php.

References RC_EDIT.

◆ doMarkPatrolled()

RecentChange::doMarkPatrolled ( Authority  $performer,
  $auto = false,
  $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$autoFor automatic patrol
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 556 of file RecentChange.php.

References $tags, $wgUseFilePatrol, $wgUseNPPatrol, $wgUseRCPatrol, MediaWiki\Permissions\Authority\authorizeWrite(), getAttribute(), getTitle(), MediaWiki\Permissions\Authority\getUser(), MediaWiki\Permissions\Authority\isAllowed(), RC_LOG, RC_NEW, reallyMarkPatrolled(), PatrolLog\record(), and Hooks\runner().

◆ getAttribute()

◆ getAttributes()

RecentChange::getAttributes ( )
Returns
array

Definition at line 1096 of file RecentChange.php.

References $mAttribs.

Referenced by IRCColourfulRCFeedFormatter\getLine().

◆ getChangeTypes()

static RecentChange::getChangeTypes ( )
static

Get an array of all change types.

Since
1.26
Returns
array

Definition at line 200 of file RecentChange.php.

Referenced by ApiQueryRecentChanges\getAllowedParams(), and ApiQueryWatchlist\getAllowedParams().

◆ 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 1129 of file RecentChange.php.

References ChangesList\showCharacterDifference().

◆ getEngine()

static RecentChange::getEngine (   $uri,
  $params = [] 
)
static
Since
1.22
Deprecated:
since 1.29 Use RCFeed::factory() instead
Parameters
string$uriURI to get the engine object for
array$params
Returns
RCFeedEngine The engine object
Exceptions
MWException

Definition at line 529 of file RecentChange.php.

References $wgRCEngines.

Referenced by RCFeed\factory().

◆ getParam()

RecentChange::getParam (   $name)

Get a parameter value.

Since
1.27
Parameters
string$nameparameter name
Returns
mixed

Definition at line 1014 of file RecentChange.php.

References parseParams().

◆ getPerformer()

RecentChange::getPerformer ( )

Get the User object of the person who performed this change.

Deprecated:
since 1.36, use getPerformerIdentity() instead.
Returns
User

Definition at line 314 of file RecentChange.php.

References $mPerformer, getPerformerIdentity(), and User\newFromIdentity().

Referenced by save().

◆ getPerformerIdentity()

RecentChange::getPerformerIdentity ( )

Get the UserIdentity of the client that performed this change.

Since
1.36
Returns
UserIdentity

Definition at line 329 of file RecentChange.php.

References $mPerformer, and getUserIdentityFromAnyId().

Referenced by getAttribute(), getPerformer(), notifyRCFeeds(), and save().

◆ getQueryInfo()

static RecentChange::getQueryInfo ( )
static

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

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

Definition at line 249 of file RecentChange.php.

References CommentStore\getStore(), and ActorMigration\newMigration().

Referenced by SiteStatsUpdate\cacheUpdate(), ChangesListSpecialPage\doMainQuery(), SpecialRecentChanges\doMainQuery(), SpecialWatchlist\doMainQuery(), SpecialRecentChangesLinked\doMainQuery(), NewPagesPager\getQueryInfo(), newFromConds(), and RecentChangesUpdateJob\purgeExpiredRows().

◆ getTitle()

◆ getUserIdentityFromAnyId()

RecentChange::getUserIdentityFromAnyId (   $userId,
  $userName,
  $actorId = null 
)
private
Parameters
string | int | null$userId
string | null$userName
string | int | null$actorId
Returns
UserIdentity

Definition at line 1226 of file RecentChange.php.

References DB_REPLICA, and wfGetDB().

Referenced by getPerformerIdentity(), and loadFromRow().

◆ 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 1169 of file RecentChange.php.

References $wgRCMaxAge, and wfTimestamp().

Referenced by DifferenceEngine\getMarkPatrolledLinkInfo(), and Article\showPatrolFooter().

◆ loadFromRow()

RecentChange::loadFromRow (   $row)

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

Parameters
mixed$row

Definition at line 1024 of file RecentChange.php.

References DB_REPLICA, CommentStore\getStore(), getUserIdentityFromAnyId(), wfGetDB(), and wfTimestamp().

Referenced by newFromRow().

◆ newForCategorization()

static RecentChange::newForCategorization (   $timestamp,
Title  $categoryTitle,
?UserIdentity  $user,
  $comment,
Title  $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
Title$categoryTitleTitle of the category a page is being added to or removed from
UserIdentity | null$userUser object of the user that made the change
string$commentChange summary
Title$pageTitleTitle of the 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 935 of file RecentChange.php.

References Title\getArticleID(), Title\getDBkey(), MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\getName(), Title\getNamespace(), Title\getPrefixedDBkey(), PRC_AUTOPATROLLED, RC_CATEGORIZE, serialize(), and SRC_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 223 of file RecentChange.php.

References getQueryInfo(), newFromRow(), and wfGetDB().

Referenced by DifferenceEngine\getMarkPatrolledLinkInfo(), Revision\RevisionStore\getRecentChange(), newFromId(), and Article\showPatrolFooter().

◆ 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 210 of file RecentChange.php.

References newFromConds().

Referenced by ApiPatrol\execute(), MarkpatrolledAction\getRecentChange(), ApiTag\processIndividual(), and PatrolLog\record().

◆ newFromRow()

static RecentChange::newFromRow (   $row)
static

◆ newLogEntry()

static RecentChange::newLogEntry (   $timestamp,
  $title,
  $user,
  $actionComment,
  $ip,
  $type,
  $action,
  $target,
  $logComment,
  $params,
  $newId = 0,
  $actionCommentIRC = '',
  $revId = 0,
  $isPatrollable = false 
)
static
Parameters
string$timestamp
Title$title
UserIdentity$user
string$actionComment
string$ip
string$type
string$action
Title$target
string$logComment
string$params
int$newId
string$actionCommentIRC
int$revIdId of associated revision, if any
bool$isPatrollableWhether this log entry is patrollable
Returns
RecentChange

Definition at line 838 of file RecentChange.php.

References $title, $type, $wgRequest, checkIPAddress(), PRC_AUTOPATROLLED, PRC_UNPATROLLED, RC_LOG, and SRC_LOG.

Referenced by ManualLogEntry\getRecentChange(), notifyLog(), and LogPage\saveContent().

◆ notifyEdit()

static RecentChange::notifyEdit (   $timestamp,
  $title,
  $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
Title$title
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 661 of file RecentChange.php.

References $editResult, $tags, $title, DeferredUpdates\addCallableUpdate(), DB_MASTER, RC_EDIT, SRC_EDIT, and wfGetDB().

Referenced by MediaWiki\Storage\PageUpdater\doModify(), and ImportTextFiles\execute().

◆ notifyLog()

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

Definition at line 805 of file RecentChange.php.

References $title, $type, $wgLogRestrictions, and newLogEntry().

Referenced by LogPage\saveContent().

◆ notifyNew()

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

Makes an entry in the database corresponding to page creation Note: the title object must be loaded with the new id using resetArticleID()

Parameters
string$timestamp
Title$title
bool$minor
UserIdentity$user
string$comment
bool$bot
string$ip
int$size
int$newId
int$patrol
string[]$tags
Returns
RecentChange

Definition at line 735 of file RecentChange.php.

References $tags, $title, DeferredUpdates\addCallableUpdate(), DB_MASTER, RC_NEW, SRC_NEW, and wfGetDB().

Referenced by MediaWiki\Storage\PageUpdater\doCreate(), and ImportTextFiles\execute().

◆ 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 486 of file RecentChange.php.

References $wgRCFeeds, RCFeed\factory(), getPerformerIdentity(), and RC_EXTERNAL.

Referenced by save().

◆ parseFromRCType()

static RecentChange::parseFromRCType (   $rcType)
static

Parsing RC_* constants to human-readable test.

Since
1.24
Parameters
int$rcType
Returns
string $type

Definition at line 189 of file RecentChange.php.

Referenced by ApiQueryWatchlist\extractOutputData(), ApiQueryRecentChanges\extractRowInfo(), and MachineReadableRCFeedFormatter\getLine().

◆ parseParams()

RecentChange::parseParams ( )

Parses and returns the rc_params attribute.

Since
1.26
Returns
mixed|bool false on failed unserialization

Definition at line 1182 of file RecentChange.php.

References getAttribute(), and unserialize().

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

◆ 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 167 of file RecentChange.php.

References $t, and $type.

Referenced by ApiQueryRecentChanges\run(), and ApiQueryWatchlist\run().

◆ reallyMarkPatrolled()

RecentChange::reallyMarkPatrolled ( )

Mark this RecentChange patrolled, without error checking.

Returns
int Number of affected rows

Definition at line 610 of file RecentChange.php.

References DB_MASTER, getAttribute(), getTitle(), and wfGetDB().

Referenced by doMarkPatrolled().

◆ 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 350 of file RecentChange.php.

References $mAttribs, $title, $wgPutIPinRC, $wgShowUpdatedMarker, $wgUseEnotif, ChangeTags\addTags(), DB_MASTER, FormatJson\encode(), getPerformer(), getPerformerIdentity(), CommentStore\getStore(), getTitle(), RecentChangesUpdateJob\newCacheUpdateJob(), notifyRCFeeds(), RC_CATEGORIZE, Hooks\runner(), JobQueueGroup\singleton(), and wfGetDB().

◆ setAttribs()

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

Definition at line 286 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 1215 of file RecentChange.php.

References $editResult.

◆ setExtra()

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

Definition at line 293 of file RecentChange.php.

Member Data Documentation

◆ $counter

int RecentChange::$counter = -1

Line number of recent change.

Default -1.

Definition at line 124 of file RecentChange.php.

◆ $editResult

EditResult null RecentChange::$editResult = null
private

EditResult associated with the edit.

Definition at line 134 of file RecentChange.php.

Referenced by notifyEdit(), and setEditResult().

◆ $mAttribs

array RecentChange::$mAttribs = []

Definition at line 100 of file RecentChange.php.

Referenced by getAttributes(), and save().

◆ $mExtra

RecentChange::$mExtra = []

Definition at line 101 of file RecentChange.php.

◆ $mPerformer

UserIdentity null RecentChange::$mPerformer = null
private

Definition at line 111 of file RecentChange.php.

Referenced by getPerformer(), and getPerformerIdentity().

◆ $mTitle

Title false RecentChange::$mTitle = false

Definition at line 106 of file RecentChange.php.

Referenced by getTitle().

◆ $notificationtimestamp

RecentChange::$notificationtimestamp

Definition at line 114 of file RecentChange.php.

◆ $numberofWatchingusers

RecentChange::$numberofWatchingusers = 0

Definition at line 113 of file RecentChange.php.

◆ $tags

array RecentChange::$tags = []
private

List of tags to apply.

Definition at line 129 of file RecentChange.php.

Referenced by addTags(), doMarkPatrolled(), notifyEdit(), and notifyNew().

◆ $watchlistExpiry

string null RecentChange::$watchlistExpiry

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

Definition at line 119 of file RecentChange.php.

◆ PRC_AUTOPATROLLED

◆ PRC_PATROLLED

const RecentChange::PRC_PATROLLED = 1

◆ PRC_UNPATROLLED

◆ SRC_CATEGORIZE

const RecentChange::SRC_CATEGORIZE = 'mw.categorize'

◆ SRC_EDIT

◆ SRC_EXTERNAL

const RecentChange::SRC_EXTERNAL = 'mw.external'

Definition at line 82 of file RecentChange.php.

Referenced by PopulateRecentChangesSource\buildUpdateCondition().

◆ SRC_LOG

◆ SRC_NEW


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