MediaWiki  1.28.0
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 (User $user, $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...
 
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 ($noudp=false)
 Writes the data in this object to the database. More...
 
 setAttribs ($attribs)
 
 setExtra ($extra)
 

Static Public Member Functions

static getChangeTypes ()
 Get an array of all change types. More...
 
static getEngine ($uri)
 Gets the stream engine object for a given URI from $wgRCEngines. 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 markPatrolled ($change, $auto=false, $tags=null)
 Mark a given change as patrolled. More...
 
static newForCategorization ($timestamp, Title $categoryTitle, User $user=null, $comment, Title $pageTitle, $oldRevId, $newRevId, $lastTimestamp, $bot, $ip= '', $deleted=0)
 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 array 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=[])
 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...
 
static selectFields ()
 Return the list of recentchanges fields that should be selected to create a new recentchanges object. More...
 

Public Attributes

int $counter = -1
 Line number of recent change. More...
 
 $mAttribs = []
 
 $mExtra = []
 
Title $mTitle = false
 
 $notificationtimestamp
 
 $numberofWatchingusers = 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'
 

Static Private Member Functions

static checkIPAddress ($ip)
 

Private Attributes

User $mPerformer = false
 
array $tags = []
 List of tags to apply. More...
 

Static Private Attributes

static array $changeTypes
 Array of change types. 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

Definition at line 63 of file RecentChange.php.

Member Function Documentation

RecentChange::addTags (   $tags)

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

Since
1.28
Parameters
string | array$tags

Definition at line 1043 of file RecentChange.php.

References $tags.

static RecentChange::checkIPAddress (   $ip)
staticprivate

Definition at line 986 of file RecentChange.php.

References $wgRequest, global, and IP\isIPAddress().

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

References RC_EDIT.

RecentChange::doMarkPatrolled ( User  $user,
  $auto = false,
  $tags = null 
)

Mark this RecentChange as patrolled.

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

Parameters
User$userUser object doing the action
bool$autoFor automatic patrol
string|string[]$tags Change 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 Title::getUserPermissionsErrors()

Definition at line 491 of file RecentChange.php.

References $auto, getAttribute(), User\getName(), getTitle(), global, User\isAllowed(), RC_LOG, RC_NEW, reallyMarkPatrolled(), PatrolLog\record(), and Hooks\run().

RecentChange::getAttribute (   $name)

Get an attribute value.

Parameters
string$nameAttribute name
Returns
mixed

Definition at line 932 of file RecentChange.php.

References $name.

Referenced by RCCacheEntryFactory\buildDiffLink(), doMarkPatrolled(), EnhancedChangesList\getDiffHistLinks(), MachineReadableRCFeedFormatter\getLine(), parseParams(), and reallyMarkPatrolled().

RecentChange::getAttributes ( )
Returns
array

Definition at line 939 of file RecentChange.php.

References $mAttribs.

Referenced by IRCColourfulRCFeedFormatter\getLine().

static RecentChange::getChangeTypes ( )
static

Get an array of all change types.

Since
1.26
Returns
array

Definition at line 162 of file RecentChange.php.

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

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

References ChangesList\showCharacterDifference().

static RecentChange::getEngine (   $uri)
static

Gets the stream engine object for a given URI from $wgRCEngines.

Parameters
string$uriURI to get the engine object for
Exceptions
MWException
Returns
RCFeedEngine The engine object

Definition at line 442 of file RecentChange.php.

References global.

RecentChange::getParam (   $name)

Get a parameter value.

Since
1.27
Parameters
string$nameparameter name
Returns
mixed

Definition at line 910 of file RecentChange.php.

References $name, $params, and parseParams().

RecentChange::getPerformer ( )

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

Returns
User

Definition at line 265 of file RecentChange.php.

References $mPerformer, User\newFromId(), and User\newFromName().

Referenced by notifyRCFeeds(), and save().

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

References $timestamp, global, TS_UNIX, and wfTimestamp().

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

RecentChange::loadFromRow (   $row)

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

Parameters
mixed$row

Definition at line 920 of file RecentChange.php.

References TS_MW, and wfTimestamp().

Referenced by newFromRow().

static RecentChange::markPatrolled (   $change,
  $auto = false,
  $tags = null 
)
static

Mark a given change as patrolled.

Parameters
RecentChange | int$changeRecentChange or corresponding rc_id
bool$autoFor automatic patrol
string|string[]$tags Change tags to add to the patrol log entry ($user should be able to add the specified tags before this is called)
Returns
array See doMarkPatrolled(), or null if $change is not an existing rc_id

Definition at line 466 of file RecentChange.php.

References $auto, $wgUser, global, and newFromId().

static RecentChange::newForCategorization (   $timestamp,
Title  $categoryTitle,
User  $user = null,
  $comment,
Title  $pageTitle,
  $oldRevId,
  $newRevId,
  $lastTimestamp,
  $bot,
  $ip = '',
  $deleted = 0 
)
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
User$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
Returns
RecentChange

Definition at line 847 of file RecentChange.php.

References $comment, $timestamp, $user, WikiPage\factory(), Title\getArticleID(), Title\getDBkey(), Title\getNamespace(), Title\getPrefixedDBkey(), RC_CATEGORIZE, and serialize().

Referenced by ApiQueryWatchlistIntegrationTest\testCategorizeTypeParameter(), and RecentChangeTest\testHiddenCategoryChange().

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

References $fname, and wfGetDB().

Referenced by CategoryMembershipChangeJobTest\getCategorizeRecentChangeForRevId(), DifferenceEngine\getMarkPatrolledLinkInfo(), Revision\getRecentChange(), and Article\showPatrolFooter().

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

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

static array static RecentChange::newFromRow (   $row)
static
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
User$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 757 of file RecentChange.php.

References $params, $revId, $timestamp, $title, $type, $user, $wgRequest, global, and RC_LOG.

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

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

Makes an entry in the database corresponding to an edit.

Parameters
string$timestamp
Title$title
bool$minor
User$user
string$comment
int$oldId
string$lastTimestamp
bool$bot
string$ip
int$oldSize
int$newSize
int$newId
int$patrol
array$tags
Returns
RecentChange

Definition at line 579 of file RecentChange.php.

References $comment, $timestamp, $title, $user, DeferredUpdates\addCallableUpdate(), DB_MASTER, DeferredUpdates\POSTSEND, RC_EDIT, PatrolLog\record(), use, and wfGetDB().

Referenced by WikiPage\doModify(), and ImportTextFiles\execute().

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

Definition at line 724 of file RecentChange.php.

References $params, $timestamp, $title, $type, $user, and global.

Referenced by LogPage\saveContent().

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
User$user
string$comment
bool$bot
string$ip
int$size
int$newId
int$patrol
array$tags
Returns
RecentChange

Definition at line 653 of file RecentChange.php.

References $comment, $timestamp, $title, $user, DeferredUpdates\addCallableUpdate(), DB_MASTER, DeferredUpdates\POSTSEND, RC_NEW, PatrolLog\record(), use, and wfGetDB().

Referenced by WikiPage\doCreate(), and ImportTextFiles\execute().

RecentChange::notifyRCFeeds ( array  $feeds = null)

Notify all the feeds about the change.

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

Definition at line 384 of file RecentChange.php.

References $engine, $line, as, getPerformer(), global, and RC_EXTERNAL.

Referenced by save().

static RecentChange::parseFromRCType (   $rcType)
static

Parsing RC_* constants to human-readable test.

Since
1.24
Parameters
int$rcType
Returns
string $type

Definition at line 151 of file RecentChange.php.

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

RecentChange::parseParams ( )

Parses and returns the rc_params attribute.

Since
1.26
Returns
mixed|bool false on failed unserialization

Definition at line 1025 of file RecentChange.php.

References getAttribute(), and unserialize().

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

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

References $retval, $t, $type, and as.

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

RecentChange::reallyMarkPatrolled ( )

Mark this RecentChange patrolled, without error checking.

Returns
int Number of affected rows

Definition at line 541 of file RecentChange.php.

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

Referenced by doMarkPatrolled().

RecentChange::save (   $noudp = false)
static RecentChange::selectFields ( )
static

Return the list of recentchanges fields that should be selected to create a new recentchanges object.

Returns
array

Definition at line 204 of file RecentChange.php.

Referenced by SpecialRecentChangesLinked\doMainQuery(), SpecialWatchlist\doMainQuery(), SpecialRecentChanges\doMainQuery(), and ChangesListSpecialPage\doMainQuery().

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

Definition at line 238 of file RecentChange.php.

References $attribs.

Referenced by RecentChangeTest\assertParseParams().

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

Definition at line 245 of file RecentChange.php.

Member Data Documentation

array RecentChange::$changeTypes
staticprivate
Initial value:
= [
'edit' => RC_EDIT

Array of change types.

Definition at line 101 of file RecentChange.php.

int RecentChange::$counter = -1

Line number of recent change.

Default -1.

Definition at line 91 of file RecentChange.php.

RecentChange::$mAttribs = []

Definition at line 72 of file RecentChange.php.

Referenced by getAttributes().

RecentChange::$mExtra = []

Definition at line 73 of file RecentChange.php.

User RecentChange::$mPerformer = false
private

Definition at line 83 of file RecentChange.php.

Referenced by getPerformer().

Title RecentChange::$mTitle = false

Definition at line 78 of file RecentChange.php.

Referenced by getTitle().

RecentChange::$notificationtimestamp

Definition at line 86 of file RecentChange.php.

RecentChange::$numberofWatchingusers = 0

Definition at line 85 of file RecentChange.php.

array RecentChange::$tags = []
private

List of tags to apply.

Definition at line 96 of file RecentChange.php.

Referenced by addTags().

const RecentChange::SRC_CATEGORIZE = 'mw.categorize'

Definition at line 70 of file RecentChange.php.

Referenced by CategoryMembershipChangeJob\run().

const RecentChange::SRC_EXTERNAL = 'mw.external'

Definition at line 69 of file RecentChange.php.

Referenced by PopulateRecentChangesSource\buildUpdateCondition().


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