MediaWiki  1.29.1
RecentChange.php
Go to the documentation of this file.
1 <?php
63 class RecentChange {
64  // Constants for the rc_source field. Extensions may also have
65  // their own source constants.
66  const SRC_EDIT = 'mw.edit';
67  const SRC_NEW = 'mw.new';
68  const SRC_LOG = 'mw.log';
69  const SRC_EXTERNAL = 'mw.external'; // obsolete
70  const SRC_CATEGORIZE = 'mw.categorize';
71 
72  public $mAttribs = [];
73  public $mExtra = [];
74 
78  public $mTitle = false;
79 
83  private $mPerformer = false;
84 
87 
91  public $counter = -1;
92 
96  private $tags = [];
97 
101  private static $changeTypes = [
102  'edit' => RC_EDIT,
103  'new' => RC_NEW,
104  'log' => RC_LOG,
105  'external' => RC_EXTERNAL,
106  'categorize' => RC_CATEGORIZE,
107  ];
108 
109  # Factory methods
110 
115  public static function newFromRow( $row ) {
116  $rc = new RecentChange;
117  $rc->loadFromRow( $row );
118 
119  return $rc;
120  }
121 
129  public static function parseToRCType( $type ) {
130  if ( is_array( $type ) ) {
131  $retval = [];
132  foreach ( $type as $t ) {
134  }
135 
136  return $retval;
137  }
138 
139  if ( !array_key_exists( $type, self::$changeTypes ) ) {
140  throw new MWException( "Unknown type '$type'" );
141  }
142  return self::$changeTypes[$type];
143  }
144 
151  public static function parseFromRCType( $rcType ) {
152  return array_search( $rcType, self::$changeTypes, true ) ?: "$rcType";
153  }
154 
162  public static function getChangeTypes() {
163  return array_keys( self::$changeTypes );
164  }
165 
172  public static function newFromId( $rcid ) {
173  return self::newFromConds( [ 'rc_id' => $rcid ], __METHOD__ );
174  }
175 
185  public static function newFromConds(
186  $conds,
187  $fname = __METHOD__,
188  $dbType = DB_REPLICA
189  ) {
190  $db = wfGetDB( $dbType );
191  $row = $db->selectRow( 'recentchanges', self::selectFields(), $conds, $fname );
192  if ( $row !== false ) {
193  return self::newFromRow( $row );
194  } else {
195  return null;
196  }
197  }
198 
204  public static function selectFields() {
205  return [
206  'rc_id',
207  'rc_timestamp',
208  'rc_user',
209  'rc_user_text',
210  'rc_namespace',
211  'rc_title',
212  'rc_comment',
213  'rc_minor',
214  'rc_bot',
215  'rc_new',
216  'rc_cur_id',
217  'rc_this_oldid',
218  'rc_last_oldid',
219  'rc_type',
220  'rc_source',
221  'rc_patrolled',
222  'rc_ip',
223  'rc_old_len',
224  'rc_new_len',
225  'rc_deleted',
226  'rc_logid',
227  'rc_log_type',
228  'rc_log_action',
229  'rc_params',
230  ];
231  }
232 
233  # Accessors
234 
238  public function setAttribs( $attribs ) {
239  $this->mAttribs = $attribs;
240  }
241 
245  public function setExtra( $extra ) {
246  $this->mExtra = $extra;
247  }
248 
252  public function &getTitle() {
253  if ( $this->mTitle === false ) {
254  $this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
255  }
256 
257  return $this->mTitle;
258  }
259 
265  public function getPerformer() {
266  if ( $this->mPerformer === false ) {
267  if ( $this->mAttribs['rc_user'] ) {
268  $this->mPerformer = User::newFromId( $this->mAttribs['rc_user'] );
269  } else {
270  $this->mPerformer = User::newFromName( $this->mAttribs['rc_user_text'], false );
271  }
272  }
273 
274  return $this->mPerformer;
275  }
276 
281  public function save( $noudp = false ) {
282  global $wgPutIPinRC, $wgUseEnotif, $wgShowUpdatedMarker, $wgContLang;
283 
284  $dbw = wfGetDB( DB_MASTER );
285  if ( !is_array( $this->mExtra ) ) {
286  $this->mExtra = [];
287  }
288 
289  if ( !$wgPutIPinRC ) {
290  $this->mAttribs['rc_ip'] = '';
291  }
292 
293  # Strict mode fixups (not-NULL fields)
294  foreach ( [ 'minor', 'bot', 'new', 'patrolled', 'deleted' ] as $field ) {
295  $this->mAttribs["rc_$field"] = (int)$this->mAttribs["rc_$field"];
296  }
297  # ...more fixups (NULL fields)
298  foreach ( [ 'old_len', 'new_len' ] as $field ) {
299  $this->mAttribs["rc_$field"] = isset( $this->mAttribs["rc_$field"] )
300  ? (int)$this->mAttribs["rc_$field"]
301  : null;
302  }
303 
304  # If our database is strict about IP addresses, use NULL instead of an empty string
305  $strictIPs = in_array( $dbw->getType(), [ 'oracle', 'postgres' ] ); // legacy
306  if ( $strictIPs && $this->mAttribs['rc_ip'] == '' ) {
307  unset( $this->mAttribs['rc_ip'] );
308  }
309 
310  # Trim spaces on user supplied text
311  $this->mAttribs['rc_comment'] = trim( $this->mAttribs['rc_comment'] );
312 
313  # Make sure summary is truncated (whole multibyte characters)
314  $this->mAttribs['rc_comment'] = $wgContLang->truncate( $this->mAttribs['rc_comment'], 255 );
315 
316  # Fixup database timestamps
317  $this->mAttribs['rc_timestamp'] = $dbw->timestamp( $this->mAttribs['rc_timestamp'] );
318  $this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'recentchanges_rc_id_seq' );
319 
320  # # If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
321  if ( $this->mAttribs['rc_cur_id'] == 0 ) {
322  unset( $this->mAttribs['rc_cur_id'] );
323  }
324 
325  # Insert new row
326  $dbw->insert( 'recentchanges', $this->mAttribs, __METHOD__ );
327 
328  # Set the ID
329  $this->mAttribs['rc_id'] = $dbw->insertId();
330 
331  # Notify extensions
332  // Avoid PHP 7.1 warning from passing $this by reference
333  $rc = $this;
334  Hooks::run( 'RecentChange_save', [ &$rc ] );
335 
336  if ( count( $this->tags ) ) {
337  ChangeTags::addTags( $this->tags, $this->mAttribs['rc_id'],
338  $this->mAttribs['rc_this_oldid'], $this->mAttribs['rc_logid'], null, $this );
339  }
340 
341  # Notify external application via UDP
342  if ( !$noudp ) {
343  $this->notifyRCFeeds();
344  }
345 
346  # E-mail notifications
347  if ( $wgUseEnotif || $wgShowUpdatedMarker ) {
348  $editor = $this->getPerformer();
349  $title = $this->getTitle();
350 
351  // Never send an RC notification email about categorization changes
352  if (
353  $this->mAttribs['rc_type'] != RC_CATEGORIZE &&
354  Hooks::run( 'AbortEmailNotification', [ $editor, $title, $this ] )
355  ) {
356  // @FIXME: This would be better as an extension hook
357  // Send emails or email jobs once this row is safely committed
358  $dbw->onTransactionIdle(
359  function () use ( $editor, $title ) {
360  $enotif = new EmailNotification();
361  $enotif->notifyOnPageChange(
362  $editor,
363  $title,
364  $this->mAttribs['rc_timestamp'],
365  $this->mAttribs['rc_comment'],
366  $this->mAttribs['rc_minor'],
367  $this->mAttribs['rc_last_oldid'],
368  $this->mExtra['pageStatus']
369  );
370  },
371  __METHOD__
372  );
373  }
374  }
375 
376  // Update the cached list of active users
377  if ( $this->mAttribs['rc_user'] > 0 ) {
379  }
380  }
381 
386  public function notifyRCFeeds( array $feeds = null ) {
387  global $wgRCFeeds;
388  if ( $feeds === null ) {
389  $feeds = $wgRCFeeds;
390  }
391 
392  $performer = $this->getPerformer();
393 
394  foreach ( $feeds as $params ) {
395  $params += [
396  'omit_bots' => false,
397  'omit_anon' => false,
398  'omit_user' => false,
399  'omit_minor' => false,
400  'omit_patrolled' => false,
401  ];
402 
403  if (
404  ( $params['omit_bots'] && $this->mAttribs['rc_bot'] ) ||
405  ( $params['omit_anon'] && $performer->isAnon() ) ||
406  ( $params['omit_user'] && !$performer->isAnon() ) ||
407  ( $params['omit_minor'] && $this->mAttribs['rc_minor'] ) ||
408  ( $params['omit_patrolled'] && $this->mAttribs['rc_patrolled'] ) ||
409  $this->mAttribs['rc_type'] == RC_EXTERNAL
410  ) {
411  continue;
412  }
413 
414  if ( isset( $this->mExtra['actionCommentIRC'] ) ) {
415  $actionComment = $this->mExtra['actionCommentIRC'];
416  } else {
417  $actionComment = null;
418  }
419 
420  $feed = RCFeed::factory( $params );
421  $feed->notify( $this, $actionComment );
422  }
423  }
424 
432  public static function getEngine( $uri, $params = [] ) {
433  // TODO: Merge into RCFeed::factory().
434  global $wgRCEngines;
435  $scheme = parse_url( $uri, PHP_URL_SCHEME );
436  if ( !$scheme ) {
437  throw new MWException( "Invalid RCFeed uri: '$uri'" );
438  }
439  if ( !isset( $wgRCEngines[$scheme] ) ) {
440  throw new MWException( "Unknown RCFeedEngine scheme: '$scheme'" );
441  }
442  if ( defined( 'MW_PHPUNIT_TEST' ) && is_object( $wgRCEngines[$scheme] ) ) {
443  return $wgRCEngines[$scheme];
444  }
445  return new $wgRCEngines[$scheme]( $params );
446  }
447 
457  public static function markPatrolled( $change, $auto = false, $tags = null ) {
458  global $wgUser;
459 
460  $change = $change instanceof RecentChange
461  ? $change
462  : RecentChange::newFromId( $change );
463 
464  if ( !$change instanceof RecentChange ) {
465  return null;
466  }
467 
468  return $change->doMarkPatrolled( $wgUser, $auto, $tags );
469  }
470 
482  public function doMarkPatrolled( User $user, $auto = false, $tags = null ) {
483  global $wgUseRCPatrol, $wgUseNPPatrol, $wgUseFilePatrol;
484 
485  $errors = [];
486  // If recentchanges patrol is disabled, only new pages or new file versions
487  // can be patrolled, provided the appropriate config variable is set
488  if ( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) &&
489  ( !$wgUseFilePatrol || !( $this->getAttribute( 'rc_type' ) == RC_LOG &&
490  $this->getAttribute( 'rc_log_type' ) == 'upload' ) ) ) {
491  $errors[] = [ 'rcpatroldisabled' ];
492  }
493  // Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
494  $right = $auto ? 'autopatrol' : 'patrol';
495  $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) );
496  if ( !Hooks::run( 'MarkPatrolled',
497  [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ] )
498  ) {
499  $errors[] = [ 'hookaborted' ];
500  }
501  // Users without the 'autopatrol' right can't patrol their
502  // own revisions
503  if ( $user->getName() === $this->getAttribute( 'rc_user_text' )
504  && !$user->isAllowed( 'autopatrol' )
505  ) {
506  $errors[] = [ 'markedaspatrollederror-noautopatrol' ];
507  }
508  if ( $errors ) {
509  return $errors;
510  }
511  // If the change was patrolled already, do nothing
512  if ( $this->getAttribute( 'rc_patrolled' ) ) {
513  return [];
514  }
515  // Actually set the 'patrolled' flag in RC
516  $this->reallyMarkPatrolled();
517  // Log this patrol event
518  PatrolLog::record( $this, $auto, $user, $tags );
519 
520  Hooks::run(
521  'MarkPatrolledComplete',
522  [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ]
523  );
524 
525  return [];
526  }
527 
532  public function reallyMarkPatrolled() {
533  $dbw = wfGetDB( DB_MASTER );
534  $dbw->update(
535  'recentchanges',
536  [
537  'rc_patrolled' => 1
538  ],
539  [
540  'rc_id' => $this->getAttribute( 'rc_id' )
541  ],
542  __METHOD__
543  );
544  // Invalidate the page cache after the page has been patrolled
545  // to make sure that the Patrol link isn't visible any longer!
546  $this->getTitle()->invalidateCache();
547 
548  return $dbw->affectedRows();
549  }
550 
570  public static function notifyEdit(
571  $timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp,
572  $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0,
573  $tags = []
574  ) {
575  $rc = new RecentChange;
576  $rc->mTitle = $title;
577  $rc->mPerformer = $user;
578  $rc->mAttribs = [
579  'rc_timestamp' => $timestamp,
580  'rc_namespace' => $title->getNamespace(),
581  'rc_title' => $title->getDBkey(),
582  'rc_type' => RC_EDIT,
583  'rc_source' => self::SRC_EDIT,
584  'rc_minor' => $minor ? 1 : 0,
585  'rc_cur_id' => $title->getArticleID(),
586  'rc_user' => $user->getId(),
587  'rc_user_text' => $user->getName(),
588  'rc_comment' => $comment,
589  'rc_this_oldid' => $newId,
590  'rc_last_oldid' => $oldId,
591  'rc_bot' => $bot ? 1 : 0,
592  'rc_ip' => self::checkIPAddress( $ip ),
593  'rc_patrolled' => intval( $patrol ),
594  'rc_new' => 0, # obsolete
595  'rc_old_len' => $oldSize,
596  'rc_new_len' => $newSize,
597  'rc_deleted' => 0,
598  'rc_logid' => 0,
599  'rc_log_type' => null,
600  'rc_log_action' => '',
601  'rc_params' => ''
602  ];
603 
604  $rc->mExtra = [
605  'prefixedDBkey' => $title->getPrefixedDBkey(),
606  'lastTimestamp' => $lastTimestamp,
607  'oldSize' => $oldSize,
608  'newSize' => $newSize,
609  'pageStatus' => 'changed'
610  ];
611 
613  function () use ( $rc, $tags ) {
614  $rc->addTags( $tags );
615  $rc->save();
616  if ( $rc->mAttribs['rc_patrolled'] ) {
617  PatrolLog::record( $rc, true, $rc->getPerformer() );
618  }
619  },
621  wfGetDB( DB_MASTER )
622  );
623 
624  return $rc;
625  }
626 
644  public static function notifyNew(
645  $timestamp, &$title, $minor, &$user, $comment, $bot,
646  $ip = '', $size = 0, $newId = 0, $patrol = 0, $tags = []
647  ) {
648  $rc = new RecentChange;
649  $rc->mTitle = $title;
650  $rc->mPerformer = $user;
651  $rc->mAttribs = [
652  'rc_timestamp' => $timestamp,
653  'rc_namespace' => $title->getNamespace(),
654  'rc_title' => $title->getDBkey(),
655  'rc_type' => RC_NEW,
656  'rc_source' => self::SRC_NEW,
657  'rc_minor' => $minor ? 1 : 0,
658  'rc_cur_id' => $title->getArticleID(),
659  'rc_user' => $user->getId(),
660  'rc_user_text' => $user->getName(),
661  'rc_comment' => $comment,
662  'rc_this_oldid' => $newId,
663  'rc_last_oldid' => 0,
664  'rc_bot' => $bot ? 1 : 0,
665  'rc_ip' => self::checkIPAddress( $ip ),
666  'rc_patrolled' => intval( $patrol ),
667  'rc_new' => 1, # obsolete
668  'rc_old_len' => 0,
669  'rc_new_len' => $size,
670  'rc_deleted' => 0,
671  'rc_logid' => 0,
672  'rc_log_type' => null,
673  'rc_log_action' => '',
674  'rc_params' => ''
675  ];
676 
677  $rc->mExtra = [
678  'prefixedDBkey' => $title->getPrefixedDBkey(),
679  'lastTimestamp' => 0,
680  'oldSize' => 0,
681  'newSize' => $size,
682  'pageStatus' => 'created'
683  ];
684 
686  function () use ( $rc, $tags ) {
687  $rc->addTags( $tags );
688  $rc->save();
689  if ( $rc->mAttribs['rc_patrolled'] ) {
690  PatrolLog::record( $rc, true, $rc->getPerformer() );
691  }
692  },
694  wfGetDB( DB_MASTER )
695  );
696 
697  return $rc;
698  }
699 
715  public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip, $type,
716  $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = ''
717  ) {
718  global $wgLogRestrictions;
719 
720  # Don't add private logs to RC!
721  if ( isset( $wgLogRestrictions[$type] ) && $wgLogRestrictions[$type] != '*' ) {
722  return false;
723  }
724  $rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action,
725  $target, $logComment, $params, $newId, $actionCommentIRC );
726  $rc->save();
727 
728  return true;
729  }
730 
748  public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip,
749  $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
750  $revId = 0, $isPatrollable = false ) {
752 
753  # # Get pageStatus for email notification
754  switch ( $type . '-' . $action ) {
755  case 'delete-delete':
756  case 'delete-delete_redir':
757  $pageStatus = 'deleted';
758  break;
759  case 'move-move':
760  case 'move-move_redir':
761  $pageStatus = 'moved';
762  break;
763  case 'delete-restore':
764  $pageStatus = 'restored';
765  break;
766  case 'upload-upload':
767  $pageStatus = 'created';
768  break;
769  case 'upload-overwrite':
770  default:
771  $pageStatus = 'changed';
772  break;
773  }
774 
775  // Allow unpatrolled status for patrollable log entries
776  $markPatrolled = $isPatrollable ? $user->isAllowed( 'autopatrol' ) : true;
777 
778  $rc = new RecentChange;
779  $rc->mTitle = $target;
780  $rc->mPerformer = $user;
781  $rc->mAttribs = [
782  'rc_timestamp' => $timestamp,
783  'rc_namespace' => $target->getNamespace(),
784  'rc_title' => $target->getDBkey(),
785  'rc_type' => RC_LOG,
786  'rc_source' => self::SRC_LOG,
787  'rc_minor' => 0,
788  'rc_cur_id' => $target->getArticleID(),
789  'rc_user' => $user->getId(),
790  'rc_user_text' => $user->getName(),
791  'rc_comment' => $logComment,
792  'rc_this_oldid' => $revId,
793  'rc_last_oldid' => 0,
794  'rc_bot' => $user->isAllowed( 'bot' ) ? (int)$wgRequest->getBool( 'bot', true ) : 0,
795  'rc_ip' => self::checkIPAddress( $ip ),
796  'rc_patrolled' => $markPatrolled ? 1 : 0,
797  'rc_new' => 0, # obsolete
798  'rc_old_len' => null,
799  'rc_new_len' => null,
800  'rc_deleted' => 0,
801  'rc_logid' => $newId,
802  'rc_log_type' => $type,
803  'rc_log_action' => $action,
804  'rc_params' => $params
805  ];
806 
807  $rc->mExtra = [
808  'prefixedDBkey' => $title->getPrefixedDBkey(),
809  'lastTimestamp' => 0,
810  'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
811  'pageStatus' => $pageStatus,
812  'actionCommentIRC' => $actionCommentIRC
813  ];
814 
815  return $rc;
816  }
817 
838  public static function newForCategorization(
839  $timestamp,
840  Title $categoryTitle,
841  User $user = null,
842  $comment,
843  Title $pageTitle,
844  $oldRevId,
845  $newRevId,
846  $lastTimestamp,
847  $bot,
848  $ip = '',
849  $deleted = 0
850  ) {
851  $rc = new RecentChange;
852  $rc->mTitle = $categoryTitle;
853  $rc->mPerformer = $user;
854  $rc->mAttribs = [
855  'rc_timestamp' => $timestamp,
856  'rc_namespace' => $categoryTitle->getNamespace(),
857  'rc_title' => $categoryTitle->getDBkey(),
858  'rc_type' => RC_CATEGORIZE,
859  'rc_source' => self::SRC_CATEGORIZE,
860  'rc_minor' => 0,
861  'rc_cur_id' => $pageTitle->getArticleID(),
862  'rc_user' => $user ? $user->getId() : 0,
863  'rc_user_text' => $user ? $user->getName() : '',
864  'rc_comment' => $comment,
865  'rc_this_oldid' => $newRevId,
866  'rc_last_oldid' => $oldRevId,
867  'rc_bot' => $bot ? 1 : 0,
868  'rc_ip' => self::checkIPAddress( $ip ),
869  'rc_patrolled' => 1, // Always patrolled, just like log entries
870  'rc_new' => 0, # obsolete
871  'rc_old_len' => null,
872  'rc_new_len' => null,
873  'rc_deleted' => $deleted,
874  'rc_logid' => 0,
875  'rc_log_type' => null,
876  'rc_log_action' => '',
877  'rc_params' => serialize( [
878  'hidden-cat' => WikiCategoryPage::factory( $categoryTitle )->isHidden()
879  ] )
880  ];
881 
882  $rc->mExtra = [
883  'prefixedDBkey' => $categoryTitle->getPrefixedDBkey(),
884  'lastTimestamp' => $lastTimestamp,
885  'oldSize' => 0,
886  'newSize' => 0,
887  'pageStatus' => 'changed'
888  ];
889 
890  return $rc;
891  }
892 
901  public function getParam( $name ) {
902  $params = $this->parseParams();
903  return isset( $params[$name] ) ? $params[$name] : null;
904  }
905 
911  public function loadFromRow( $row ) {
912  $this->mAttribs = get_object_vars( $row );
913  $this->mAttribs['rc_timestamp'] = wfTimestamp( TS_MW, $this->mAttribs['rc_timestamp'] );
914  $this->mAttribs['rc_deleted'] = $row->rc_deleted; // MUST be set
915  }
916 
923  public function getAttribute( $name ) {
924  return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : null;
925  }
926 
930  public function getAttributes() {
931  return $this->mAttribs;
932  }
933 
940  public function diffLinkTrail( $forceCur ) {
941  if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
942  $trail = "curid=" . (int)( $this->mAttribs['rc_cur_id'] ) .
943  "&oldid=" . (int)( $this->mAttribs['rc_last_oldid'] );
944  if ( $forceCur ) {
945  $trail .= '&diff=0';
946  } else {
947  $trail .= '&diff=' . (int)( $this->mAttribs['rc_this_oldid'] );
948  }
949  } else {
950  $trail = '';
951  }
952 
953  return $trail;
954  }
955 
963  public function getCharacterDifference( $old = 0, $new = 0 ) {
964  if ( $old === 0 ) {
965  $old = $this->mAttribs['rc_old_len'];
966  }
967  if ( $new === 0 ) {
968  $new = $this->mAttribs['rc_new_len'];
969  }
970  if ( $old === null || $new === null ) {
971  return '';
972  }
973 
974  return ChangesList::showCharacterDifference( $old, $new );
975  }
976 
977  private static function checkIPAddress( $ip ) {
979  if ( $ip ) {
980  if ( !IP::isIPAddress( $ip ) ) {
981  throw new MWException( "Attempt to write \"" . $ip .
982  "\" as an IP address into recent changes" );
983  }
984  } else {
985  $ip = $wgRequest->getIP();
986  if ( !$ip ) {
987  $ip = '';
988  }
989  }
990 
991  return $ip;
992  }
993 
1003  public static function isInRCLifespan( $timestamp, $tolerance = 0 ) {
1004  global $wgRCMaxAge;
1005 
1006  return wfTimestamp( TS_UNIX, $timestamp ) > time() - $tolerance - $wgRCMaxAge;
1007  }
1008 
1016  public function parseParams() {
1017  $rcParams = $this->getAttribute( 'rc_params' );
1018 
1019  MediaWiki\suppressWarnings();
1020  $unserializedParams = unserialize( $rcParams );
1021  MediaWiki\restoreWarnings();
1022 
1023  return $unserializedParams;
1024  }
1025 
1034  public function addTags( $tags ) {
1035  if ( is_string( $tags ) ) {
1036  $this->tags[] = $tags;
1037  } else {
1038  $this->tags = array_merge( $tags, $this->tags );
1039  }
1040  }
1041 }
RecentChange\getCharacterDifference
getCharacterDifference( $old=0, $new=0)
Returns the change size (HTML).
Definition: RecentChange.php:963
RecentChange\notifyNew
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...
Definition: RecentChange.php:644
$wgUser
$wgUser
Definition: Setup.php:781
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:579
RC_EXTERNAL
const RC_EXTERNAL
Definition: Defines.php:143
RecentChange\$tags
array $tags
List of tags to apply.
Definition: RecentChange.php:96
RecentChange\setExtra
setExtra( $extra)
Definition: RecentChange.php:245
$auto
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 temp or archived zone 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
Definition: hooks.txt:1459
SpecialRecentChangesLinked
This is to display changes made to all articles linked in an article.
Definition: SpecialRecentchangeslinked.php:29
RecentChange\newFromConds
static newFromConds( $conds, $fname=__METHOD__, $dbType=DB_REPLICA)
Find the first recent change matching some specific conditions.
Definition: RecentChange.php:185
captcha-old.count
count
Definition: captcha-old.py:225
Title\getPrefixedDBkey
getPrefixedDBkey()
Get the prefixed database key form.
Definition: Title.php:1439
RecentChange\getAttributes
getAttributes()
Definition: RecentChange.php:930
PatrolLog\record
static record( $rc, $auto=false, User $user=null, $tags=null)
Record a log event for a change being patrolled.
Definition: PatrolLog.php:41
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:63
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1994
RecentChange\$mAttribs
$mAttribs
Definition: RecentChange.php:72
RecentChange\newForCategorization
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...
Definition: RecentChange.php:838
RC_LOG
const RC_LOG
Definition: Defines.php:142
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
Title\getArticleID
getArticleID( $flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:3220
RecentChange\getEngine
static getEngine( $uri, $params=[])
Definition: RecentChange.php:432
$fname
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition: Setup.php:36
unserialize
unserialize( $serialized)
Definition: ApiMessage.php:185
RecentChange\loadFromRow
loadFromRow( $row)
Initialises the members of this object from a mysql row object.
Definition: RecentChange.php:911
RecentChange\getChangeTypes
static getChangeTypes()
Get an array of all change types.
Definition: RecentChange.php:162
RecentChange\reallyMarkPatrolled
reallyMarkPatrolled()
Mark this RecentChange patrolled, without error checking.
Definition: RecentChange.php:532
$params
$params
Definition: styleTest.css.php:40
RC_EDIT
const RC_EDIT
Definition: Defines.php:140
serialize
serialize()
Definition: ApiMessage.php:177
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:556
RecentChange\$counter
int $counter
Line number of recent change.
Definition: RecentChange.php:91
RecentChange\setAttribs
setAttribs( $attribs)
Definition: RecentChange.php:238
RecentChange\notifyEdit
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.
Definition: RecentChange.php:570
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
RecentChange\SRC_CATEGORIZE
const SRC_CATEGORIZE
Definition: RecentChange.php:70
$type
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
RecentChange\parseToRCType
static parseToRCType( $type)
Parsing text to RC_* constants.
Definition: RecentChange.php:129
RecentChange\SRC_LOG
const SRC_LOG
Definition: RecentChange.php:68
RecentChangesUpdateJob\newCacheUpdateJob
static newCacheUpdateJob()
Definition: RecentChangesUpdateJob.php:55
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
RecentChange\parseParams
parseParams()
Parses and returns the rc_params attribute.
Definition: RecentChange.php:1016
DeferredUpdates\addCallableUpdate
static addCallableUpdate( $callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
Definition: DeferredUpdates.php:111
Title\getDBkey
getDBkey()
Get the main part with underscores.
Definition: Title.php:901
MWException
MediaWiki exception.
Definition: MWException.php:26
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:120
Title\getNamespace
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:924
RecentChange\$notificationtimestamp
$notificationtimestamp
Definition: RecentChange.php:86
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3060
in
null for the wiki Added in
Definition: hooks.txt:1572
$attribs
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
Definition: hooks.txt:1956
RecentChange\newFromRow
static newFromRow( $row)
Definition: RecentChange.php:115
RecentChange\notifyLog
static notifyLog( $timestamp, &$title, &$user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='')
Definition: RecentChange.php:715
DeferredUpdates\POSTSEND
const POSTSEND
Definition: DeferredUpdates.php:61
message
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
Definition: hooks.txt:2114
RecentChange\SRC_EDIT
const SRC_EDIT
Definition: RecentChange.php:66
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:514
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
RecentChange\diffLinkTrail
diffLinkTrail( $forceCur)
Gets the end part of the diff URL associated with this object Blank if no diff link should be display...
Definition: RecentChange.php:940
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
DB_MASTER
const DB_MASTER
Definition: defines.php:26
RecentChange\SRC_NEW
const SRC_NEW
Definition: RecentChange.php:67
$editor
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
Definition: hooks.txt:1252
RecentChange\newFromId
static newFromId( $rcid)
Obtain the recent change with a given rc_id value.
Definition: RecentChange.php:172
RecentChange\doMarkPatrolled
doMarkPatrolled(User $user, $auto=false, $tags=null)
Mark this RecentChange as patrolled.
Definition: RecentChange.php:482
RecentChange\$mExtra
$mExtra
Definition: RecentChange.php:73
$retval
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account incomplete not yet checked for validity & $retval
Definition: hooks.txt:246
ChangesList\showCharacterDifference
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
Definition: ChangesList.php:282
RC_NEW
const RC_NEW
Definition: Defines.php:141
RecentChange\markPatrolled
static markPatrolled( $change, $auto=false, $tags=null)
Mark a given change as patrolled.
Definition: RecentChange.php:457
error
&</p >< p >< sup id="cite_ref-blank_1-1" class="reference">< a href="#cite_note-blank-1"> &</p >< div class="mw-references-wrap">< ol class="references">< li id="cite_note-blank-1">< span class="mw-cite-backlink"> ↑< sup >< a href="#cite_ref-blank_1-0"></a ></sup >< sup >< a href="#cite_ref-blank_1-1"></a ></sup ></span >< span class="reference-text">< span class="error mw-ext-cite-error" lang="en" dir="ltr"> Cite error
Definition: citeParserTests.txt:219
RecentChange\addTags
addTags( $tags)
Tags to append to the recent change, and associated revision/log.
Definition: RecentChange.php:1034
RecentChange\getAttribute
getAttribute( $name)
Get an attribute value.
Definition: RecentChange.php:923
$wgUseEnotif
$wgUseEnotif
Definition: Setup.php:345
RecentChange\checkIPAddress
static checkIPAddress( $ip)
Definition: RecentChange.php:977
Title
Represents a title within MediaWiki.
Definition: Title.php:39
RecentChange\selectFields
static selectFields()
Return the list of recentchanges fields that should be selected to create a new recentchanges object.
Definition: RecentChange.php:204
RecentChange\$mTitle
Title $mTitle
Definition: RecentChange.php:78
RecentChange\parseFromRCType
static parseFromRCType( $rcType)
Parsing RC_* constants to human-readable test.
Definition: RecentChange.php:151
RecentChange\newLogEntry
static newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='', $revId=0, $isPatrollable=false)
Definition: RecentChange.php:748
JobQueueGroup\singleton
static singleton( $wiki=false)
Definition: JobQueueGroup.php:71
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
RCFeed\factory
static factory(array $params)
Definition: RCFeed.php:46
RecentChange\isInRCLifespan
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...
Definition: RecentChange.php:1003
$revId
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context $revId
Definition: hooks.txt:1049
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:144
RecentChange\notifyRCFeeds
notifyRCFeeds(array $feeds=null)
Notify all the feeds about the change.
Definition: RecentChange.php:386
$t
$t
Definition: testCompression.php:67
RecentChange\getPerformer
getPerformer()
Get the User object of the person who performed this change.
Definition: RecentChange.php:265
EmailNotification
This module processes the email notifications when the current page is changed.
Definition: EmailNotification.php:48
$wgRequest
if(! $wgDBerrorLogTZ) $wgRequest
Definition: Setup.php:639
RecentChange\save
save( $noudp=false)
Writes the data in this object to the database.
Definition: RecentChange.php:281
RecentChange\getTitle
& getTitle()
Definition: RecentChange.php:252
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:50
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
RecentChange\$mPerformer
User $mPerformer
Definition: RecentChange.php:83
RecentChange\$changeTypes
static array $changeTypes
Array of change types.
Definition: RecentChange.php:101
RecentChange\getParam
getParam( $name)
Get a parameter value.
Definition: RecentChange.php:901
RecentChange\$numberofWatchingusers
$numberofWatchingusers
Definition: RecentChange.php:85
ChangeTags\addTags
static addTags( $tags, $rc_id=null, $rev_id=null, $log_id=null, $params=null, RecentChange $rc=null)
Add tags to a change given its rc_id, rev_id and/or log_id.
Definition: ChangeTags.php:136
IP\isIPAddress
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
Definition: IP.php:79
array
the array() calling protocol came about after MediaWiki 1.4rc1.
RecentChange\SRC_EXTERNAL
const SRC_EXTERNAL
Definition: RecentChange.php:69
User\isAllowed
isAllowed( $action='')
Internal mechanics of testing a permission.
Definition: User.php:3540
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56