MediaWiki master
MediaWiki\RecentChanges\RecentChange Class Reference

Utility class for creating and reading rows in the recentchanges table. More...

Inherits MediaWiki\ChangeTags\Taggable.

Inherited by MediaWiki\RecentChanges\RCCacheEntry.

Collaboration diagram for MediaWiki\RecentChanges\RecentChange:

Public Member Functions

 __construct (?PageReference $page=null, ?UserIdentity $performer=null)
 
 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.
 
 getAttribute ( $name)
 Get an attribute value.
 
 getAttributes ()
 
 getCharacterDifference ( $old=0, $new=0)
 Returns the change size (HTML).
 
 getEditResult ()
 
 getExtra ( $name)
 
 getExtras ()
 
 getHighlights ()
 
 getPage ()
 
 getParam ( $name)
 Get a parameter value.
 
 getPerformerIdentity ()
 Get the UserIdentity of the client that performed this change.
 
 getTags ()
 
 getTitle ()
 
 isHighlighted (string $key)
 
 isInternal ()
 Check if the change is internal (edit, new, log, categorize).
 
 loadFromRow ( $row)
 Initialises the members of this object from a mysql row object.
 
 markPatrolled (Authority $performer, $tags=null)
 Mark this RecentChange as patrolled.
 
 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)
 
 setAttribute ( $name, $value)
 
 setEditResult (?EditResult $editResult)
 Sets the EditResult associated with the edit.
 
 setExtra ( $extra)
 
 setHighlights (array $highlights)
 

Static Public Member Functions

static getChangeTypes ()
 Get an array of all change types.
 
static getQueryInfo (int $joinFlags=0)
 Return the tables, fields, and join conditions to be selected to create a new recentchanges object.
 
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 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 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 = []
 
array $mExtra = []
 
bool $notificationtimestamp
 
int $numberofWatchingusers = 0
 
string null $watchlistExpiry
 The expiry time, if this is a temporary watchlist item.
 
const PRC_AUTOPATROLLED = PatrolManager::PRC_AUTOPATROLLED
 
const PRC_PATROLLED = PatrolManager::PRC_PATROLLED
 
const PRC_UNPATROLLED = PatrolManager::PRC_UNPATROLLED
 
const SEND_FEED = RecentChangeStore::SEND_FEED
 
const SEND_NONE = RecentChangeStore::SEND_NONE
 
const SRC_CATEGORIZE = 'mw.categorize'
 
const SRC_EDIT = 'mw.edit'
 
const SRC_LOG = 'mw.log'
 
const SRC_NEW = 'mw.new'
 
const STRAIGHT_JOIN_ACTOR = 1
 Flag for RecentChange::getQueryInfo()
 

Detailed Description

Utility class for creating and reading rows in the recentchanges table.

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_source 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_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 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 90 of file RecentChange.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\RecentChanges\RecentChange::__construct ( ?PageReference $page = null,
?UserIdentity $performer = null )

Definition at line 179 of file RecentChange.php.

Member Function Documentation

◆ addTags()

MediaWiki\RecentChanges\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 823 of file RecentChange.php.

◆ diffLinkTrail()

MediaWiki\RecentChanges\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 737 of file RecentChange.php.

◆ getAttribute()

◆ getAttributes()

MediaWiki\RecentChanges\RecentChange::getAttributes ( )

◆ getChangeTypes()

static MediaWiki\RecentChanges\RecentChange::getChangeTypes ( )
static

Get an array of all change types.

Since
1.26
Returns
array

Definition at line 260 of file RecentChange.php.

◆ getCharacterDifference()

MediaWiki\RecentChanges\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 760 of file RecentChange.php.

◆ getEditResult()

MediaWiki\RecentChanges\RecentChange::getEditResult ( )
Access: internal
Returns
EditResult|null

Definition at line 836 of file RecentChange.php.

Referenced by MediaWiki\RecentChanges\RecentChangeStore\insertRecentChange().

◆ getExtra()

MediaWiki\RecentChanges\RecentChange::getExtra ( $name)
Access: internal
Parameters
string$name
Returns
mixed

Definition at line 718 of file RecentChange.php.

Referenced by MediaWiki\RecentChanges\RecentChangeStore\insertRecentChange(), and MediaWiki\RecentChanges\RecentChangeRCFeedNotifier\notifyRCFeeds().

◆ getExtras()

MediaWiki\RecentChanges\RecentChange::getExtras ( )
Access: internal
Returns
array

Definition at line 727 of file RecentChange.php.

Referenced by MediaWiki\RecentChanges\RecentChangeStore\insertRecentChange().

◆ getHighlights()

MediaWiki\RecentChanges\RecentChange::getHighlights ( )
Returns
array<string,bool>

Definition at line 915 of file RecentChange.php.

◆ getPage()

MediaWiki\RecentChanges\RecentChange::getPage ( )

◆ getParam()

MediaWiki\RecentChanges\RecentChange::getParam ( $name)

Get a parameter value.

Since
1.27
Parameters
string$nameparameter name
Returns
mixed

Definition at line 622 of file RecentChange.php.

◆ getPerformerIdentity()

MediaWiki\RecentChanges\RecentChange::getPerformerIdentity ( )

Get the UserIdentity of the client that performed this change.

Since
1.36
Returns
UserIdentity

Definition at line 436 of file RecentChange.php.

Referenced by MediaWiki\RecentChanges\RecentChangeStore\insertRecentChange(), and MediaWiki\RecentChanges\RecentChangeRCFeedNotifier\notifyRCFeeds().

◆ getQueryInfo()

static MediaWiki\RecentChanges\RecentChange::getQueryInfo ( int $joinFlags = 0)
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
Parameters
int$joinFlagsMay be STRAIGHT_JOIN_ACTOR to use a straight join on the actor table, preventing the database from placing the actor table first in the join. This is appropriate when there are no restrictive conditions on the actor table, and the conditions are potentially complex and unindexed, and the query is limited and ordered by timestamp. Since 1.45.
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 323 of file RecentChange.php.

References MediaWiki\RecentChanges\RecentChange\STRAIGHT_JOIN_ACTOR.

Referenced by MediaWiki\RecentChanges\RecentChangesUpdateJob\purgeExpiredRows().

◆ getTags()

MediaWiki\RecentChanges\RecentChange::getTags ( )
Access: internal
Returns
string[]

Definition at line 811 of file RecentChange.php.

Referenced by MediaWiki\RecentChanges\RecentChangeStore\insertRecentChange().

◆ getTitle()

◆ isHighlighted()

MediaWiki\RecentChanges\RecentChange::isHighlighted ( string $key)

◆ isInRCLifespan()

static MediaWiki\RecentChanges\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 783 of file RecentChange.php.

References wfTimestamp().

◆ isInternal()

MediaWiki\RecentChanges\RecentChange::isInternal ( )

Check if the change is internal (edit, new, log, categorize).

External changes are those that are defined by external sources, such as extensions.

Since
1.45
Returns
bool

Definition at line 668 of file RecentChange.php.

◆ loadFromRow()

MediaWiki\RecentChanges\RecentChange::loadFromRow ( $row)

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

Parameters
mixed$row

Definition at line 632 of file RecentChange.php.

References wfTimestamp().

◆ markPatrolled()

MediaWiki\RecentChanges\RecentChange::markPatrolled ( Authority $performer,
$tags = null )

Mark this RecentChange as patrolled.

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

Deprecated
since 1.45, use PatrolManager::markPatrolled() instead.
Parameters
Authority$performerUser performing the action
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
PermissionStatus

Definition at line 483 of file RecentChange.php.

◆ newFromConds()

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

Find the first recent change matching some specific conditions.

Deprecated
since 1.45, use MediaWikiServices::getInstance() ->getRecentChangeLookup()->getRecentChangeByConds() instead.
Parameters
array$condsArray of conditions
mixed$fnameOverride the method name in profiling/logs
int$dbTypeDB_* constant
Returns
RecentChange|null

Definition at line 291 of file RecentChange.php.

References DB_PRIMARY, and MediaWiki\MediaWikiServices\getInstance().

◆ newFromId()

static MediaWiki\RecentChanges\RecentChange::newFromId ( $rcid)
static

Obtain the recent change with a given rc_id value.

Deprecated
since 1.45, use MediaWikiServices::getInstance() ->getRecentChangeLookup()->getRecentChangeById() instead.
Parameters
int$rcidThe rc_id value to retrieve
Returns
RecentChange|null

Definition at line 273 of file RecentChange.php.

References MediaWiki\MediaWikiServices\getInstance().

◆ newFromRow()

static MediaWiki\RecentChanges\RecentChange::newFromRow ( $row)
static
Deprecated
since 1.45, use MediaWikiServices::getInstance() ->getRecentChangeFactory()->newRecentChangeFromRow() instead.
Parameters
mixed$row
Returns
RecentChange

Definition at line 207 of file RecentChange.php.

References MediaWiki\MediaWikiServices\getInstance().

◆ newLogEntry()

static MediaWiki\RecentChanges\RecentChange::newLogEntry ( $timestamp,
$logPage,
$user,
$actionComment,
$ip,
$type,
$action,
$target,
$logComment,
$params,
$newId = 0,
$actionCommentIRC = '',
$revId = 0,
$isPatrollable = false,
$forceBotFlag = null )
static
Deprecated
since 1.45, use RecentChangeFactory::createLogRecentChange() instead
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 601 of file RecentChange.php.

◆ notifyEdit()

static MediaWiki\RecentChanges\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
Deprecated
since 1.45, use RecentChangeFactory::createEditRecentChange() instead to create the log entry, then use RecentChangeFactory::insertRecentChange() to insert it into the database.
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 529 of file RecentChange.php.

◆ notifyNew()

static MediaWiki\RecentChanges\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.
Deprecated
since 1.45, use RecentChangeFactory::createNewPageRecentChange() instead to create the log entry, then use RecentChangeFactory::insertRecentChange() to insert it into the database.
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 565 of file RecentChange.php.

◆ notifyRCFeeds()

MediaWiki\RecentChanges\RecentChange::notifyRCFeeds ( ?array $feeds = null)

Notify all the feeds about the change.

Deprecated
since 1.45, use RecentChangeRCFeedNotifier::notifyRCFeeds() instead.
Parameters
array | null$feedsOptional feeds to send to, defaults to $wgRCFeeds

Definition at line 466 of file RecentChange.php.

◆ parseFromRCType()

static MediaWiki\RecentChanges\RecentChange::parseFromRCType ( $rcType)
static

Parsing RC_* constants to human-readable test.

Deprecated
since 1.46
Since
1.24
Parameters
int$rcType
Returns
string

Definition at line 247 of file RecentChange.php.

References wfDeprecated().

◆ parseParams()

MediaWiki\RecentChanges\RecentChange::parseParams ( )

Parses and returns the rc_params attribute.

Since
1.26
Returns
mixed|bool false on failed unserialization

Definition at line 796 of file RecentChange.php.

Referenced by MediaWiki\RCFeed\MachineReadableRCFeedFormatter\getLine().

◆ parseToRCType()

static MediaWiki\RecentChanges\RecentChange::parseToRCType ( $type)
static

Parsing text to RC_* constants.

Deprecated
since 1.46
Since
1.24
Parameters
string | array$typeCallers must make sure that the given types are valid RC types.
Returns
int|array RC_TYPE

Definition at line 221 of file RecentChange.php.

References MediaWiki\RecentChanges\RecentChange\parseToRCType(), and wfDeprecated().

Referenced by MediaWiki\RecentChanges\RecentChange\parseToRCType().

◆ reallyMarkPatrolled()

MediaWiki\RecentChanges\RecentChange::reallyMarkPatrolled ( )

Mark this RecentChange patrolled, without error checking.

Deprecated
since 1.45, use PatrolManager::reallyMarkPatrolled() instead.
Returns
int Number of database rows changed, usually 1, but 0 if another request already patrolled it in the mean time.

Definition at line 497 of file RecentChange.php.

◆ save()

MediaWiki\RecentChanges\RecentChange::save ( $send = self::SEND_FEED)

Writes the data in this object to the database.

Deprecated
since 1.45, use RecentChangeFactory::insertRecentChange() instead.
Parameters
bool$sendself::SEND_FEED or self::SEND_NONE

Definition at line 455 of file RecentChange.php.

◆ setAttribs()

MediaWiki\RecentChanges\RecentChange::setAttribs ( $attribs)
Parameters
array$attribs

Definition at line 373 of file RecentChange.php.

◆ setAttribute()

MediaWiki\RecentChanges\RecentChange::setAttribute ( $name,
$value )
Since
1.45
Parameters
string$name
mixed$value

Definition at line 382 of file RecentChange.php.

Referenced by MediaWiki\RecentChanges\RecentChangeStore\insertRecentChange().

◆ setEditResult()

MediaWiki\RecentChanges\RecentChange::setEditResult ( ?EditResult $editResult)

Sets the EditResult associated with the edit.

Since
1.36
Parameters
EditResult | null$editResult

Definition at line 847 of file RecentChange.php.

◆ setExtra()

MediaWiki\RecentChanges\RecentChange::setExtra ( $extra)
Parameters
array$extra

Definition at line 389 of file RecentChange.php.

Referenced by MediaWiki\RecentChanges\RecentChangeStore\insertRecentChange().

◆ setHighlights()

MediaWiki\RecentChanges\RecentChange::setHighlights ( array $highlights)
Parameters
array<string,bool>$highlights

Definition at line 908 of file RecentChange.php.

Referenced by MediaWiki\RecentChanges\RCCacheEntry\newFromParent().

Member Data Documentation

◆ $counter

int MediaWiki\RecentChanges\RecentChange::$counter = -1

Line number of recent change.

Default -1.

Definition at line 161 of file RecentChange.php.

◆ $mAttribs

array MediaWiki\RecentChanges\RecentChange::$mAttribs = []

Definition at line 134 of file RecentChange.php.

◆ $mExtra

array MediaWiki\RecentChanges\RecentChange::$mExtra = []

Definition at line 136 of file RecentChange.php.

◆ $notificationtimestamp

bool MediaWiki\RecentChanges\RecentChange::$notificationtimestamp

Definition at line 151 of file RecentChange.php.

◆ $numberofWatchingusers

int MediaWiki\RecentChanges\RecentChange::$numberofWatchingusers = 0

Definition at line 149 of file RecentChange.php.

◆ $watchlistExpiry

string null MediaWiki\RecentChanges\RecentChange::$watchlistExpiry

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

Definition at line 156 of file RecentChange.php.

◆ PRC_AUTOPATROLLED

const MediaWiki\RecentChanges\RecentChange::PRC_AUTOPATROLLED = PatrolManager::PRC_AUTOPATROLLED

◆ PRC_PATROLLED

const MediaWiki\RecentChanges\RecentChange::PRC_PATROLLED = PatrolManager::PRC_PATROLLED

◆ PRC_UNPATROLLED

const MediaWiki\RecentChanges\RecentChange::PRC_UNPATROLLED = PatrolManager::PRC_UNPATROLLED

◆ SEND_FEED

const MediaWiki\RecentChanges\RecentChange::SEND_FEED = RecentChangeStore::SEND_FEED

Definition at line 128 of file RecentChange.php.

◆ SEND_NONE

const MediaWiki\RecentChanges\RecentChange::SEND_NONE = RecentChangeStore::SEND_NONE

Definition at line 127 of file RecentChange.php.

◆ SRC_CATEGORIZE

◆ SRC_EDIT

const MediaWiki\RecentChanges\RecentChange::SRC_EDIT = 'mw.edit'

◆ SRC_LOG

◆ SRC_NEW

◆ STRAIGHT_JOIN_ACTOR

const MediaWiki\RecentChanges\RecentChange::STRAIGHT_JOIN_ACTOR = 1

Flag for RecentChange::getQueryInfo()

Definition at line 131 of file RecentChange.php.

Referenced by MediaWiki\RecentChanges\RecentChange\getQueryInfo(), and MediaWiki\RecentChanges\RecentChangesUpdateJob\purgeExpiredRows().


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