85 const SEND_NONE =
true;
90 const SEND_FEED =
false;
153 $retval[] = self::parseToRCType(
$t );
162 return self::$changeTypes[
$type];
172 return array_search( $rcType, self::$changeTypes,
true ) ?:
"$rcType";
193 return self::newFromConds( [
'rc_id' => $rcid ], __METHOD__ );
211 $rcQuery = self::getQueryInfo();
212 $row = $db->selectRow(
213 $rcQuery[
'tables'], $rcQuery[
'fields'], $conds,
$fname, [], $rcQuery[
'joins']
215 if ( $row !==
false ) {
216 return self::newFromRow( $row );
237 throw new BadMethodCallException(
238 'Cannot use ' . __METHOD__
239 .
' when $wgActorTableSchemaMigrationStage has SCHEMA_COMPAT_READ_NEW'
248 'rc_actor' =>
'NULL',
268 ] + CommentStore::getStore()->getFields(
'rc_comment' );
281 $commentQuery = CommentStore::getStore()->getJoin(
'rc_comment' );
282 $actorQuery = ActorMigration::newMigration()->getJoin(
'rc_user' );
284 'tables' => [
'recentchanges' ] + $commentQuery[
'tables'] + $actorQuery[
'tables'],
307 ] + $commentQuery[
'fields'] + $actorQuery[
'fields'],
308 'joins' => $commentQuery[
'joins'] + $actorQuery[
'joins'],
325 $this->mExtra = $extra;
332 if ( $this->mTitle ===
false ) {
333 $this->mTitle = Title::makeTitle( $this->mAttribs[
'rc_namespace'], $this->mAttribs[
'rc_title'] );
336 return $this->mTitle;
345 if ( $this->mPerformer ===
false ) {
346 if ( !empty( $this->mAttribs[
'rc_actor'] ) ) {
348 }
elseif ( !empty( $this->mAttribs[
'rc_user'] ) ) {
350 }
elseif ( !empty( $this->mAttribs[
'rc_user_text'] ) ) {
353 throw new MWException(
'RecentChange object lacks rc_actor, rc_user, and rc_user_text' );
357 return $this->mPerformer;
369 public function save( $send = self::SEND_FEED ) {
385 $this->mAttribs[
'rc_ip'] =
'';
388 # Strict mode fixups (not-NULL fields)
389 foreach ( [
'minor',
'bot',
'new',
'patrolled',
'deleted' ] as $field ) {
390 $this->mAttribs[
"rc_$field"] = (
int)$this->mAttribs[
"rc_$field"];
392 # ...more fixups (NULL fields)
393 foreach ( [
'old_len',
'new_len' ] as $field ) {
394 $this->mAttribs[
"rc_$field"] =
isset( $this->mAttribs[
"rc_$field"] )
395 ? (
int)$this->mAttribs[
"rc_$field"]
399 # If our database is strict about IP addresses, use NULL instead of an empty string
400 $strictIPs =
in_array( $dbw->getType(), [
'oracle',
'postgres' ] );
401 if ( $strictIPs && $this->mAttribs[
'rc_ip'] ==
'' ) {
402 unset( $this->mAttribs[
'rc_ip'] );
405 # Trim spaces on user supplied text
406 $this->mAttribs[
'rc_comment'] =
trim( $this->mAttribs[
'rc_comment'] );
408 # Fixup database timestamps
409 $this->mAttribs[
'rc_timestamp'] = $dbw->timestamp( $this->mAttribs[
'rc_timestamp'] );
411 # # If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
412 if ( $this->mAttribs[
'rc_cur_id'] == 0 ) {
413 unset( $this->mAttribs[
'rc_cur_id'] );
416 $row = $this->mAttribs;
418 # Convert mAttribs['rc_comment'] for CommentStore
419 $comment = $row[
'rc_comment'];
420 unset( $row[
'rc_comment'], $row[
'rc_comment_text'], $row[
'rc_comment_data'] );
421 $row += CommentStore::getStore()->insert( $dbw,
'rc_comment', $comment );
423 # Convert mAttribs['rc_user'] etc for ActorMigration
425 $row[
'rc_user'] ??
null,
426 $row[
'rc_user_text'] ??
null,
427 $row[
'rc_actor'] ??
null
429 unset( $row[
'rc_user'], $row[
'rc_user_text'], $row[
'rc_actor'] );
430 $row += ActorMigration::newMigration()->getInsertValues( $dbw,
'rc_user', $user );
432 # Don't reuse an existing rc_id for the new row, if one happens to be
433 # set for some reason.
434 unset( $row[
'rc_id'] );
437 $dbw->insert(
'recentchanges', $row, __METHOD__ );
440 $this->mAttribs[
'rc_id'] = $dbw->insertId();
445 Hooks::run(
'RecentChange_save', [ &$rc ] );
447 if ( count( $this->tags ) ) {
449 $this->mAttribs[
'rc_this_oldid'], $this->mAttribs[
'rc_logid'],
null, $this );
452 if ( $send === self::SEND_FEED ) {
457 # E-mail notifications
464 Hooks::run(
'AbortEmailNotification', [
$editor, $title, $this ] ) &&
469 $dbw->onTransactionCommitOrIdle(
470 function () use (
$editor, $title ) {
472 $enotif->notifyOnPageChange(
475 $this->mAttribs[
'rc_timestamp'],
476 $this->mAttribs[
'rc_comment'],
477 $this->mAttribs[
'rc_minor'],
478 $this->mAttribs[
'rc_last_oldid'],
479 $this->mExtra[
'pageStatus']
488 if ( $this->mAttribs[
'rc_user'] > 0 ) {
489 JobQueueGroup::singleton()->lazyPush( RecentChangesUpdateJob::newCacheUpdateJob() );
499 if ( $feeds ===
null ) {
505 foreach ( $feeds as
$params ) {
507 'omit_bots' =>
false,
508 'omit_anon' =>
false,
509 'omit_user' =>
false,
510 'omit_minor' =>
false,
511 'omit_patrolled' =>
false,
515 (
$params[
'omit_bots'] && $this->mAttribs[
'rc_bot'] ) ||
516 (
$params[
'omit_anon'] && $performer->isAnon() ) ||
517 (
$params[
'omit_user'] && !$performer->isAnon() ) ||
518 (
$params[
'omit_minor'] && $this->mAttribs[
'rc_minor'] ) ||
519 (
$params[
'omit_patrolled'] && $this->mAttribs[
'rc_patrolled'] ) ||
525 $actionComment = $this->mExtra[
'actionCommentIRC'] ??
null;
528 $feed->notify( $this, $actionComment );
543 $scheme =
parse_url( $uri, PHP_URL_SCHEME );
545 throw new MWException(
"Invalid RCFeed uri: '$uri'" );
548 throw new MWException(
"Unknown RCFeedEngine scheme: '$scheme'" );
570 : self::newFromId( $change );
576 return $change->doMarkPatrolled( $wgUser,
$auto,
$tags );
594 if (
$tags ===
null ) {
605 $this->
getAttribute(
'rc_log_type' ) ==
'upload' ) ) ) {
606 $errors[] = [
'rcpatroldisabled' ];
609 $right =
$auto ?
'autopatrol' :
'patrol';
610 $errors =
array_merge( $errors, $this->
getTitle()->getUserPermissionsErrors( $right, $user ) );
611 if ( !Hooks::run(
'MarkPatrolled',
614 $errors[] = [
'hookaborted' ];
618 if ( $user->getName() === $this->getAttribute(
'rc_user_text' )
619 && !$user->isAllowed(
'autopatrol' )
621 $errors[] = [
'markedaspatrollederror-noautopatrol' ];
636 'MarkPatrolledComplete',
652 'rc_patrolled' => self::PRC_PATROLLED
661 $this->
getTitle()->invalidateCache();
663 return $dbw->affectedRows();
686 $timestamp, $title, $minor, $user, $comment, $oldId, $lastTimestamp,
687 $bot, $ip =
'', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0,
692 $rc->mPerformer =
$user;
694 'rc_timestamp' => $timestamp,
695 'rc_namespace' => $title->getNamespace(),
696 'rc_title' => $title->getDBkey(),
698 'rc_source' => self::SRC_EDIT,
699 'rc_minor' => $minor ? 1 : 0,
700 'rc_cur_id' => $title->getArticleID(),
701 'rc_user' => $user->getId(),
702 'rc_user_text' => $user->getName(),
703 'rc_actor' => $user->getActorId(),
704 'rc_comment' => &$comment,
705 'rc_comment_text' => &$comment,
706 'rc_comment_data' =>
null,
707 'rc_this_oldid' =>
$newId,
708 'rc_last_oldid' =>
$oldId,
709 'rc_bot' => $bot ? 1 : 0,
710 'rc_ip' => self::checkIPAddress( $ip ),
711 'rc_patrolled' =>
intval( $patrol ),
712 'rc_new' => 0, # obsolete
717 'rc_log_type' =>
null,
718 'rc_log_action' =>
'',
723 'prefixedDBkey' => $title->getPrefixedDBkey(),
727 'pageStatus' =>
'changed'
730 DeferredUpdates::addCallableUpdate(
731 function () use ( $rc,
$tags ) {
732 $rc->addTags(
$tags );
735 DeferredUpdates::POSTSEND,
760 $timestamp, $title, $minor, $user, $comment, $bot,
761 $ip =
'', $size = 0, $newId = 0, $patrol = 0, $tags = []
765 $rc->mPerformer =
$user;
767 'rc_timestamp' => $timestamp,
768 'rc_namespace' => $title->getNamespace(),
769 'rc_title' => $title->getDBkey(),
771 'rc_source' => self::SRC_NEW,
772 'rc_minor' => $minor ? 1 : 0,
773 'rc_cur_id' => $title->getArticleID(),
774 'rc_user' => $user->getId(),
775 'rc_user_text' => $user->getName(),
776 'rc_actor' => $user->getActorId(),
777 'rc_comment' => &$comment,
778 'rc_comment_text' => &$comment,
779 'rc_comment_data' =>
null,
780 'rc_this_oldid' =>
$newId,
781 'rc_last_oldid' => 0,
782 'rc_bot' => $bot ? 1 : 0,
783 'rc_ip' => self::checkIPAddress( $ip ),
784 'rc_patrolled' =>
intval( $patrol ),
785 'rc_new' => 1, # obsolete
787 'rc_new_len' => $size,
790 'rc_log_type' =>
null,
791 'rc_log_action' =>
'',
796 'prefixedDBkey' => $title->getPrefixedDBkey(),
797 'lastTimestamp' => 0,
800 'pageStatus' =>
'created'
803 DeferredUpdates::addCallableUpdate(
804 function () use ( $rc,
$tags ) {
805 $rc->addTags(
$tags );
808 DeferredUpdates::POSTSEND,
830 public static function notifyLog( $timestamp, $title, $user, $actionComment, $ip,
$type,
831 $action, $target, $logComment,
$params, $newId = 0, $actionCommentIRC =
''
835 # Don't add private logs to RC!
839 $rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip,
$type, $action,
840 $target, $logComment,
$params, $newId, $actionCommentIRC );
863 public static function newLogEntry( $timestamp, $title, $user, $actionComment, $ip,
864 $type, $action, $target, $logComment,
$params, $newId = 0, $actionCommentIRC =
'',
865 $revId = 0, $isPatrollable =
false ) {
868 # # Get pageStatus for email notification
869 switch (
$type .
'-' . $action ) {
870 case 'delete-delete':
871 case 'delete-delete_redir':
872 $pageStatus =
'deleted';
875 case 'move-move_redir':
876 $pageStatus =
'moved';
878 case 'delete-restore':
879 $pageStatus =
'restored';
881 case 'upload-upload':
882 $pageStatus =
'created';
884 case 'upload-overwrite':
886 $pageStatus =
'changed';
891 $markPatrolled = $isPatrollable ? $user->isAllowed(
'autopatrol' ) :
true;
894 $rc->mTitle = $target;
895 $rc->mPerformer =
$user;
897 'rc_timestamp' => $timestamp,
898 'rc_namespace' => $target->getNamespace(),
899 'rc_title' => $target->getDBkey(),
901 'rc_source' => self::SRC_LOG,
903 'rc_cur_id' => $target->getArticleID(),
904 'rc_user' => $user->getId(),
905 'rc_user_text' => $user->getName(),
906 'rc_actor' => $user->getActorId(),
909 'rc_comment_data' =>
null,
910 'rc_this_oldid' => $revId,
911 'rc_last_oldid' => 0,
912 'rc_bot' => $user->isAllowed(
'bot' ) ? (
int)
$wgRequest->getBool(
'bot',
true ) : 0,
913 'rc_ip' => self::checkIPAddress( $ip ),
914 'rc_patrolled' => $markPatrolled ? self::PRC_AUTOPATROLLED : self::PRC_UNPATROLLED,
915 'rc_new' => 0, # obsolete
916 'rc_old_len' =>
null,
917 'rc_new_len' =>
null,
920 'rc_log_type' =>
$type,
921 'rc_log_action' => $action,
926 'prefixedDBkey' => $title->getPrefixedDBkey(),
927 'lastTimestamp' => 0,
929 'pageStatus' => $pageStatus,
959 Title $categoryTitle,
975 if ( $added !==
null ) {
981 $rc->mPerformer =
$user;
983 'rc_timestamp' => $timestamp,
984 'rc_namespace' => $categoryTitle->getNamespace(),
985 'rc_title' => $categoryTitle->getDBkey(),
987 'rc_source' => self::SRC_CATEGORIZE,
990 'rc_user' => $user ? $user->getId() : 0,
991 'rc_user_text' => $user ? $user->getName() :
'',
992 'rc_actor' => $user ? $user->getActorId() :
null,
993 'rc_comment' => &$comment,
994 'rc_comment_text' => &$comment,
995 'rc_comment_data' =>
null,
998 'rc_bot' => $bot ? 1 : 0,
999 'rc_ip' => self::checkIPAddress( $ip ),
1000 'rc_patrolled' => self::PRC_AUTOPATROLLED,
1001 'rc_new' => 0, # obsolete
1002 'rc_old_len' =>
null,
1003 'rc_new_len' =>
null,
1004 'rc_deleted' => $deleted,
1006 'rc_log_type' =>
null,
1007 'rc_log_action' =>
'',
1012 'prefixedDBkey' => $categoryTitle->getPrefixedDBkey(),
1016 'pageStatus' =>
'changed'
1042 $this->mAttribs[
'rc_timestamp'] =
wfTimestamp( TS_MW, $this->mAttribs[
'rc_timestamp'] );
1044 $this->mAttribs[
'rc_deleted'] = $row->rc_deleted;
1046 if (
isset( $this->mAttribs[
'rc_ip'] ) ) {
1048 $n =
strpos( $this->mAttribs[
'rc_ip'],
'/' );
1049 if ( $n !==
false ) {
1050 $this->mAttribs[
'rc_ip'] =
substr( $this->mAttribs[
'rc_ip'], 0, $n );
1054 $comment = CommentStore::getStore()
1058 $this->mAttribs[
'rc_comment'] = &$comment;
1059 $this->mAttribs[
'rc_comment_text'] = &$comment;
1060 $this->mAttribs[
'rc_comment_data'] =
null;
1063 $this->mAttribs[
'rc_user'] ??
null,
1064 $this->mAttribs[
'rc_user_text'] ??
null,
1065 $this->mAttribs[
'rc_actor'] ??
null
1067 $this->mAttribs[
'rc_user'] = $user->getId();
1068 $this->mAttribs[
'rc_user_text'] = $user->getName();
1069 $this->mAttribs[
'rc_actor'] = $user->getActorId();
1079 if ( $name ===
'rc_comment' ) {
1080 return CommentStore::getStore()
1081 ->getComment(
'rc_comment', $this->mAttribs,
true )->text;
1084 if ( $name ===
'rc_user' || $name ===
'rc_user_text' || $name ===
'rc_actor' ) {
1086 $this->mAttribs[
'rc_user'] ??
null,
1087 $this->mAttribs[
'rc_user_text'] ??
null,
1088 $this->mAttribs[
'rc_actor'] ??
null
1090 if ( $name ===
'rc_user' ) {
1091 return $user->getId();
1093 if ( $name ===
'rc_user_text' ) {
1094 return $user->getName();
1096 if ( $name ===
'rc_actor' ) {
1097 return $user->getActorId();
1101 return $this->mAttribs[
$name] ??
null;
1108 return $this->mAttribs;
1118 if ( $this->mAttribs[
'rc_type'] ==
RC_EDIT ) {
1119 $trail =
"curid=" . (
int)( $this->mAttribs[
'rc_cur_id'] ) .
1120 "&oldid=" . (
int)( $this->mAttribs[
'rc_last_oldid'] );
1122 $trail .=
'&diff=0';
1124 $trail .=
'&diff=' . (
int)( $this->mAttribs[
'rc_this_oldid'] );
1142 $old = $this->mAttribs[
'rc_old_len'];
1145 $new = $this->mAttribs[
'rc_new_len'];
1147 if ( $old ===
null || $new ===
null ) {
1157 if ( !IP::isIPAddress( $ip ) ) {
1158 throw new MWException(
"Attempt to write \"" . $ip .
1159 "\" as an IP address into recent changes" );
1213 $this->tags[] =
$tags;
unserialize( $serialized)
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgRCFeeds
Recentchanges items are periodically purged; entries older than this many seconds will go.
$wgPutIPinRC
Log IP addresses in the recentchanges table; can be accessed only by extensions (e....
$wgUseFilePatrol
Use file patrolling to check new files on Special:Newfiles.
$wgLogRestrictions
This restricts log access to those who have a certain right Users without this will not see it in the...
$wgShowUpdatedMarker
Show "Updated (since my last visit)" marker in RC view, watchlist and history view for watched pages ...
$wgUseRCPatrol
Use RC Patrolling to check for vandalism (from recent changes and watchlists) New pages and new files...
$wgUseNPPatrol
Use new page patrolling to check new pages on Special:Newpages.
$wgRCMaxAge
Recentchanges items are periodically purged; entries older than this many seconds will go.
$wgRCEngines
Used by RecentChange::getEngine to find the correct engine for a given URI scheme.
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
if(! $wgDBerrorLogTZ) $wgRequest
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
This module processes the email notifications when the current page is changed.
static record( $rc, $auto=false, User $user=null, $tags=null)
Record a log event for a change being patrolled.
static factory(array $params)
Utility class for creating new RC entries.
static getEngine( $uri, $params=[])
static parseToRCType( $type)
Parsing text to RC_* constants.
reallyMarkPatrolled()
Mark this RecentChange patrolled, without error checking.
parseParams()
Parses and returns the rc_params attribute.
static array $changeTypes
Array of change types.
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.
static selectFields()
Return the list of recentchanges fields that should be selected to create a new recentchanges object.
getPerformer()
Get the User object of the person who performed this change.
static checkIPAddress( $ip)
static newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='', $revId=0, $isPatrollable=false)
static getChangeTypes()
Get an array of all change types.
static newForCategorization( $timestamp, Title $categoryTitle, User $user=null, $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...
static isInRCLifespan( $timestamp, $tolerance=0)
Check whether the given timestamp is new enough to have a RC row with a given tolerance as the recent...
static markPatrolled( $change, $auto=false, $tags=null)
Mark a given change as patrolled.
int $counter
Line number of recent change.
save( $send=self::SEND_FEED)
Writes the data in this object to the database.
doMarkPatrolled(User $user, $auto=false, $tags=null)
Mark this RecentChange as patrolled.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new recentchanges object.
static newFromConds( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
Find the first recent change matching some specific conditions.
getCharacterDifference( $old=0, $new=0)
Returns the change size (HTML).
static parseFromRCType( $rcType)
Parsing RC_* constants to human-readable test.
notifyRCFeeds(array $feeds=null)
Notify all the feeds about the change.
array $tags
List of tags to apply.
getParam( $name)
Get a parameter value.
addTags( $tags)
Tags to append to the recent change, and associated revision/log.
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 w...
loadFromRow( $row)
Initialises the members of this object from a mysql row object.
getAttribute( $name)
Get an attribute value.
diffLinkTrail( $forceCur)
Gets the end part of the diff URL associated with this object Blank if no diff link should be display...
static notifyLog( $timestamp, $title, $user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='')
static newFromId( $rcid)
Obtain the recent change with a given rc_id value.
This is to display changes made to all articles linked in an article.
Represents a title within MediaWiki.
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static newFromAnyId( $userId, $userName, $actorId)
Static factory method for creation from an ID, name, and/or actor ID.
static newFromId( $id)
Static factory method for creation from a given user ID.
static newFromActorId( $id)
Static factory method for creation from a given actor ID.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped true if there is text before this autocomment $auto
passed in as a query string parameter to the various URLs constructed here(i.e. $prevlink) $ldel you ll need to handle error etc yourself modifying $error and returning true will cause the contents of $error to be echoed at the top of the edit form as wikitext Return true without altering $error to allow the edit to proceed & $editor
namespace and then decline to actually register it file or subcat img or subcat $title
Allows to change the fields on the form that will be generated $name
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
return true to allow those checks to and false if checking is done & $user
const SCHEMA_COMPAT_READ_NEW
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))