MediaWiki  1.27.3
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 
85  public $numberofWatchingusers = 0; # Dummy to prevent error message in SpecialRecentChangesLinked
87 
91  public $counter = -1;
92 
96  private static $changeTypes = [
97  'edit' => RC_EDIT,
98  'new' => RC_NEW,
99  'log' => RC_LOG,
100  'external' => RC_EXTERNAL,
101  'categorize' => RC_CATEGORIZE,
102  ];
103 
104  # Factory methods
105 
110  public static function newFromRow( $row ) {
111  $rc = new RecentChange;
112  $rc->loadFromRow( $row );
113 
114  return $rc;
115  }
116 
124  public static function parseToRCType( $type ) {
125  if ( is_array( $type ) ) {
126  $retval = [];
127  foreach ( $type as $t ) {
129  }
130 
131  return $retval;
132  }
133 
134  if ( !array_key_exists( $type, self::$changeTypes ) ) {
135  throw new MWException( "Unknown type '$type'" );
136  }
137  return self::$changeTypes[$type];
138  }
139 
146  public static function parseFromRCType( $rcType ) {
147  return array_search( $rcType, self::$changeTypes, true ) ?: "$rcType";
148  }
149 
157  public static function getChangeTypes() {
158  return array_keys( self::$changeTypes );
159  }
160 
167  public static function newFromId( $rcid ) {
168  return self::newFromConds( [ 'rc_id' => $rcid ], __METHOD__ );
169  }
170 
180  public static function newFromConds(
181  $conds,
182  $fname = __METHOD__,
183  $dbType = DB_SLAVE
184  ) {
185  $db = wfGetDB( $dbType );
186  $row = $db->selectRow( 'recentchanges', self::selectFields(), $conds, $fname );
187  if ( $row !== false ) {
188  return self::newFromRow( $row );
189  } else {
190  return null;
191  }
192  }
193 
199  public static function selectFields() {
200  return [
201  'rc_id',
202  'rc_timestamp',
203  'rc_user',
204  'rc_user_text',
205  'rc_namespace',
206  'rc_title',
207  'rc_comment',
208  'rc_minor',
209  'rc_bot',
210  'rc_new',
211  'rc_cur_id',
212  'rc_this_oldid',
213  'rc_last_oldid',
214  'rc_type',
215  'rc_source',
216  'rc_patrolled',
217  'rc_ip',
218  'rc_old_len',
219  'rc_new_len',
220  'rc_deleted',
221  'rc_logid',
222  'rc_log_type',
223  'rc_log_action',
224  'rc_params',
225  ];
226  }
227 
228  # Accessors
229 
233  public function setAttribs( $attribs ) {
234  $this->mAttribs = $attribs;
235  }
236 
240  public function setExtra( $extra ) {
241  $this->mExtra = $extra;
242  }
243 
247  public function &getTitle() {
248  if ( $this->mTitle === false ) {
249  $this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
250  }
251 
252  return $this->mTitle;
253  }
254 
260  public function getPerformer() {
261  if ( $this->mPerformer === false ) {
262  if ( $this->mAttribs['rc_user'] ) {
263  $this->mPerformer = User::newFromId( $this->mAttribs['rc_user'] );
264  } else {
265  $this->mPerformer = User::newFromName( $this->mAttribs['rc_user_text'], false );
266  }
267  }
268 
269  return $this->mPerformer;
270  }
271 
276  public function save( $noudp = false ) {
277  global $wgPutIPinRC, $wgUseEnotif, $wgShowUpdatedMarker, $wgContLang;
278 
279  $dbw = wfGetDB( DB_MASTER );
280  if ( !is_array( $this->mExtra ) ) {
281  $this->mExtra = [];
282  }
283 
284  if ( !$wgPutIPinRC ) {
285  $this->mAttribs['rc_ip'] = '';
286  }
287 
288  # If our database is strict about IP addresses, use NULL instead of an empty string
289  if ( $dbw->strictIPs() && $this->mAttribs['rc_ip'] == '' ) {
290  unset( $this->mAttribs['rc_ip'] );
291  }
292 
293  # Trim spaces on user supplied text
294  $this->mAttribs['rc_comment'] = trim( $this->mAttribs['rc_comment'] );
295 
296  # Make sure summary is truncated (whole multibyte characters)
297  $this->mAttribs['rc_comment'] = $wgContLang->truncate( $this->mAttribs['rc_comment'], 255 );
298 
299  # Fixup database timestamps
300  $this->mAttribs['rc_timestamp'] = $dbw->timestamp( $this->mAttribs['rc_timestamp'] );
301  $this->mAttribs['rc_id'] = $dbw->nextSequenceValue( 'recentchanges_rc_id_seq' );
302 
303  # # If we are using foreign keys, an entry of 0 for the page_id will fail, so use NULL
304  if ( $dbw->cascadingDeletes() && $this->mAttribs['rc_cur_id'] == 0 ) {
305  unset( $this->mAttribs['rc_cur_id'] );
306  }
307 
308  # Insert new row
309  $dbw->insert( 'recentchanges', $this->mAttribs, __METHOD__ );
310 
311  # Set the ID
312  $this->mAttribs['rc_id'] = $dbw->insertId();
313 
314  # Notify extensions
315  // Avoid PHP 7.1 warning from passing $this by reference
316  $rc = $this;
317  Hooks::run( 'RecentChange_save', [ &$rc ] );
318 
319  # Notify external application via UDP
320  if ( !$noudp ) {
321  $this->notifyRCFeeds();
322  }
323 
324  # E-mail notifications
325  if ( $wgUseEnotif || $wgShowUpdatedMarker ) {
326  $editor = $this->getPerformer();
327  $title = $this->getTitle();
328 
329  // Never send an RC notification email about categorization changes
330  if ( $this->mAttribs['rc_type'] != RC_CATEGORIZE ) {
331  if ( Hooks::run( 'AbortEmailNotification', [ $editor, $title, $this ] ) ) {
332  # @todo FIXME: This would be better as an extension hook
333  $enotif = new EmailNotification();
334  $enotif->notifyOnPageChange(
335  $editor,
336  $title,
337  $this->mAttribs['rc_timestamp'],
338  $this->mAttribs['rc_comment'],
339  $this->mAttribs['rc_minor'],
340  $this->mAttribs['rc_last_oldid'],
341  $this->mExtra['pageStatus']
342  );
343  }
344  }
345  }
346 
347  // Update the cached list of active users
348  if ( $this->mAttribs['rc_user'] > 0 ) {
350  }
351  }
352 
357  public function notifyRCFeeds( array $feeds = null ) {
358  global $wgRCFeeds;
359  if ( $feeds === null ) {
360  $feeds = $wgRCFeeds;
361  }
362 
363  $performer = $this->getPerformer();
364 
365  foreach ( $feeds as $feed ) {
366  $feed += [
367  'omit_bots' => false,
368  'omit_anon' => false,
369  'omit_user' => false,
370  'omit_minor' => false,
371  'omit_patrolled' => false,
372  ];
373 
374  if (
375  ( $feed['omit_bots'] && $this->mAttribs['rc_bot'] ) ||
376  ( $feed['omit_anon'] && $performer->isAnon() ) ||
377  ( $feed['omit_user'] && !$performer->isAnon() ) ||
378  ( $feed['omit_minor'] && $this->mAttribs['rc_minor'] ) ||
379  ( $feed['omit_patrolled'] && $this->mAttribs['rc_patrolled'] ) ||
380  $this->mAttribs['rc_type'] == RC_EXTERNAL
381  ) {
382  continue;
383  }
384 
385  $engine = self::getEngine( $feed['uri'] );
386 
387  if ( isset( $this->mExtra['actionCommentIRC'] ) ) {
388  $actionComment = $this->mExtra['actionCommentIRC'];
389  } else {
390  $actionComment = null;
391  }
392 
394  $formatter = is_object( $feed['formatter'] ) ? $feed['formatter'] : new $feed['formatter']();
395  $line = $formatter->getLine( $feed, $this, $actionComment );
396  if ( !$line ) {
397  // T109544
398  // If a feed formatter returns null, this will otherwise cause an
399  // error in at least RedisPubSubFeedEngine.
400  // Not sure where/how this should best be handled.
401  continue;
402  }
403 
404  $engine->send( $feed, $line );
405  }
406  }
407 
415  public static function getEngine( $uri ) {
416  global $wgRCEngines;
417 
418  $scheme = parse_url( $uri, PHP_URL_SCHEME );
419  if ( !$scheme ) {
420  throw new MWException( __FUNCTION__ . ": Invalid stream logger URI: '$uri'" );
421  }
422 
423  if ( !isset( $wgRCEngines[$scheme] ) ) {
424  throw new MWException( __FUNCTION__ . ": Unknown stream logger URI scheme: $scheme" );
425  }
426 
427  return new $wgRCEngines[$scheme];
428  }
429 
439  public static function markPatrolled( $change, $auto = false, $tags = null ) {
440  global $wgUser;
441 
442  $change = $change instanceof RecentChange
443  ? $change
444  : RecentChange::newFromId( $change );
445 
446  if ( !$change instanceof RecentChange ) {
447  return null;
448  }
449 
450  return $change->doMarkPatrolled( $wgUser, $auto, $tags );
451  }
452 
464  public function doMarkPatrolled( User $user, $auto = false, $tags = null ) {
465  global $wgUseRCPatrol, $wgUseNPPatrol, $wgUseFilePatrol;
466 
467  $errors = [];
468  // If recentchanges patrol is disabled, only new pages or new file versions
469  // can be patrolled, provided the appropriate config variable is set
470  if ( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) &&
471  ( !$wgUseFilePatrol || !( $this->getAttribute( 'rc_type' ) == RC_LOG &&
472  $this->getAttribute( 'rc_log_type' ) == 'upload' ) ) ) {
473  $errors[] = [ 'rcpatroldisabled' ];
474  }
475  // Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
476  $right = $auto ? 'autopatrol' : 'patrol';
477  $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) );
478  if ( !Hooks::run( 'MarkPatrolled',
479  [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ] )
480  ) {
481  $errors[] = [ 'hookaborted' ];
482  }
483  // Users without the 'autopatrol' right can't patrol their
484  // own revisions
485  if ( $user->getName() === $this->getAttribute( 'rc_user_text' )
486  && !$user->isAllowed( 'autopatrol' )
487  ) {
488  $errors[] = [ 'markedaspatrollederror-noautopatrol' ];
489  }
490  if ( $errors ) {
491  return $errors;
492  }
493  // If the change was patrolled already, do nothing
494  if ( $this->getAttribute( 'rc_patrolled' ) ) {
495  return [];
496  }
497  // Actually set the 'patrolled' flag in RC
498  $this->reallyMarkPatrolled();
499  // Log this patrol event
500  PatrolLog::record( $this, $auto, $user, $tags );
501 
502  Hooks::run(
503  'MarkPatrolledComplete',
504  [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ]
505  );
506 
507  return [];
508  }
509 
514  public function reallyMarkPatrolled() {
515  $dbw = wfGetDB( DB_MASTER );
516  $dbw->update(
517  'recentchanges',
518  [
519  'rc_patrolled' => 1
520  ],
521  [
522  'rc_id' => $this->getAttribute( 'rc_id' )
523  ],
524  __METHOD__
525  );
526  // Invalidate the page cache after the page has been patrolled
527  // to make sure that the Patrol link isn't visible any longer!
528  $this->getTitle()->invalidateCache();
529 
530  return $dbw->affectedRows();
531  }
532 
552  public static function notifyEdit(
553  $timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp,
554  $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0,
555  $tags = []
556  ) {
557  $rc = new RecentChange;
558  $rc->mTitle = $title;
559  $rc->mPerformer = $user;
560  $rc->mAttribs = [
561  'rc_timestamp' => $timestamp,
562  'rc_namespace' => $title->getNamespace(),
563  'rc_title' => $title->getDBkey(),
564  'rc_type' => RC_EDIT,
565  'rc_source' => self::SRC_EDIT,
566  'rc_minor' => $minor ? 1 : 0,
567  'rc_cur_id' => $title->getArticleID(),
568  'rc_user' => $user->getId(),
569  'rc_user_text' => $user->getName(),
570  'rc_comment' => $comment,
571  'rc_this_oldid' => $newId,
572  'rc_last_oldid' => $oldId,
573  'rc_bot' => $bot ? 1 : 0,
574  'rc_ip' => self::checkIPAddress( $ip ),
575  'rc_patrolled' => intval( $patrol ),
576  'rc_new' => 0, # obsolete
577  'rc_old_len' => $oldSize,
578  'rc_new_len' => $newSize,
579  'rc_deleted' => 0,
580  'rc_logid' => 0,
581  'rc_log_type' => null,
582  'rc_log_action' => '',
583  'rc_params' => ''
584  ];
585 
586  $rc->mExtra = [
587  'prefixedDBkey' => $title->getPrefixedDBkey(),
588  'lastTimestamp' => $lastTimestamp,
589  'oldSize' => $oldSize,
590  'newSize' => $newSize,
591  'pageStatus' => 'changed'
592  ];
593 
594  DeferredUpdates::addCallableUpdate( function() use ( $rc, $tags ) {
595  $rc->save();
596  if ( $rc->mAttribs['rc_patrolled'] ) {
597  PatrolLog::record( $rc, true, $rc->getPerformer() );
598  }
599  if ( count( $tags ) ) {
600  ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
601  $rc->mAttribs['rc_this_oldid'], null, null );
602  }
603  } );
604 
605  return $rc;
606  }
607 
625  public static function notifyNew(
626  $timestamp, &$title, $minor, &$user, $comment, $bot,
627  $ip = '', $size = 0, $newId = 0, $patrol = 0, $tags = []
628  ) {
629  $rc = new RecentChange;
630  $rc->mTitle = $title;
631  $rc->mPerformer = $user;
632  $rc->mAttribs = [
633  'rc_timestamp' => $timestamp,
634  'rc_namespace' => $title->getNamespace(),
635  'rc_title' => $title->getDBkey(),
636  'rc_type' => RC_NEW,
637  'rc_source' => self::SRC_NEW,
638  'rc_minor' => $minor ? 1 : 0,
639  'rc_cur_id' => $title->getArticleID(),
640  'rc_user' => $user->getId(),
641  'rc_user_text' => $user->getName(),
642  'rc_comment' => $comment,
643  'rc_this_oldid' => $newId,
644  'rc_last_oldid' => 0,
645  'rc_bot' => $bot ? 1 : 0,
646  'rc_ip' => self::checkIPAddress( $ip ),
647  'rc_patrolled' => intval( $patrol ),
648  'rc_new' => 1, # obsolete
649  'rc_old_len' => 0,
650  'rc_new_len' => $size,
651  'rc_deleted' => 0,
652  'rc_logid' => 0,
653  'rc_log_type' => null,
654  'rc_log_action' => '',
655  'rc_params' => ''
656  ];
657 
658  $rc->mExtra = [
659  'prefixedDBkey' => $title->getPrefixedDBkey(),
660  'lastTimestamp' => 0,
661  'oldSize' => 0,
662  'newSize' => $size,
663  'pageStatus' => 'created'
664  ];
665 
666  DeferredUpdates::addCallableUpdate( function() use ( $rc, $tags ) {
667  $rc->save();
668  if ( $rc->mAttribs['rc_patrolled'] ) {
669  PatrolLog::record( $rc, true, $rc->getPerformer() );
670  }
671  if ( count( $tags ) ) {
672  ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
673  $rc->mAttribs['rc_this_oldid'], null, null );
674  }
675  } );
676 
677  return $rc;
678  }
679 
695  public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip, $type,
696  $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = ''
697  ) {
698  global $wgLogRestrictions;
699 
700  # Don't add private logs to RC!
701  if ( isset( $wgLogRestrictions[$type] ) && $wgLogRestrictions[$type] != '*' ) {
702  return false;
703  }
704  $rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action,
705  $target, $logComment, $params, $newId, $actionCommentIRC );
706  $rc->save();
707 
708  return true;
709  }
710 
728  public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip,
729  $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
730  $revId = 0, $isPatrollable = false ) {
732 
733  # # Get pageStatus for email notification
734  switch ( $type . '-' . $action ) {
735  case 'delete-delete':
736  $pageStatus = 'deleted';
737  break;
738  case 'move-move':
739  case 'move-move_redir':
740  $pageStatus = 'moved';
741  break;
742  case 'delete-restore':
743  $pageStatus = 'restored';
744  break;
745  case 'upload-upload':
746  $pageStatus = 'created';
747  break;
748  case 'upload-overwrite':
749  default:
750  $pageStatus = 'changed';
751  break;
752  }
753 
754  // Allow unpatrolled status for patrollable log entries
755  $markPatrolled = $isPatrollable ? $user->isAllowed( 'autopatrol' ) : true;
756 
757  $rc = new RecentChange;
758  $rc->mTitle = $target;
759  $rc->mPerformer = $user;
760  $rc->mAttribs = [
761  'rc_timestamp' => $timestamp,
762  'rc_namespace' => $target->getNamespace(),
763  'rc_title' => $target->getDBkey(),
764  'rc_type' => RC_LOG,
765  'rc_source' => self::SRC_LOG,
766  'rc_minor' => 0,
767  'rc_cur_id' => $target->getArticleID(),
768  'rc_user' => $user->getId(),
769  'rc_user_text' => $user->getName(),
770  'rc_comment' => $logComment,
771  'rc_this_oldid' => $revId,
772  'rc_last_oldid' => 0,
773  'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
774  'rc_ip' => self::checkIPAddress( $ip ),
775  'rc_patrolled' => $markPatrolled ? 1 : 0,
776  'rc_new' => 0, # obsolete
777  'rc_old_len' => null,
778  'rc_new_len' => null,
779  'rc_deleted' => 0,
780  'rc_logid' => $newId,
781  'rc_log_type' => $type,
782  'rc_log_action' => $action,
783  'rc_params' => $params
784  ];
785 
786  $rc->mExtra = [
787  'prefixedDBkey' => $title->getPrefixedDBkey(),
788  'lastTimestamp' => 0,
789  'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
790  'pageStatus' => $pageStatus,
791  'actionCommentIRC' => $actionCommentIRC
792  ];
793 
794  return $rc;
795  }
796 
817  public static function newForCategorization(
818  $timestamp,
819  Title $categoryTitle,
820  User $user = null,
821  $comment,
822  Title $pageTitle,
823  $oldRevId,
824  $newRevId,
825  $lastTimestamp,
826  $bot,
827  $ip = '',
828  $deleted = 0
829  ) {
830  $rc = new RecentChange;
831  $rc->mTitle = $categoryTitle;
832  $rc->mPerformer = $user;
833  $rc->mAttribs = [
834  'rc_timestamp' => $timestamp,
835  'rc_namespace' => $categoryTitle->getNamespace(),
836  'rc_title' => $categoryTitle->getDBkey(),
837  'rc_type' => RC_CATEGORIZE,
838  'rc_source' => self::SRC_CATEGORIZE,
839  'rc_minor' => 0,
840  'rc_cur_id' => $pageTitle->getArticleID(),
841  'rc_user' => $user ? $user->getId() : 0,
842  'rc_user_text' => $user ? $user->getName() : '',
843  'rc_comment' => $comment,
844  'rc_this_oldid' => $newRevId,
845  'rc_last_oldid' => $oldRevId,
846  'rc_bot' => $bot ? 1 : 0,
847  'rc_ip' => self::checkIPAddress( $ip ),
848  'rc_patrolled' => 1, // Always patrolled, just like log entries
849  'rc_new' => 0, # obsolete
850  'rc_old_len' => null,
851  'rc_new_len' => null,
852  'rc_deleted' => $deleted,
853  'rc_logid' => 0,
854  'rc_log_type' => null,
855  'rc_log_action' => '',
856  'rc_params' => serialize( [
857  'hidden-cat' => WikiCategoryPage::factory( $categoryTitle )->isHidden()
858  ] )
859  ];
860 
861  $rc->mExtra = [
862  'prefixedDBkey' => $categoryTitle->getPrefixedDBkey(),
863  'lastTimestamp' => $lastTimestamp,
864  'oldSize' => 0,
865  'newSize' => 0,
866  'pageStatus' => 'changed'
867  ];
868 
869  return $rc;
870  }
871 
880  public function getParam( $name ) {
881  $params = $this->parseParams();
882  return isset( $params[$name] ) ? $params[$name] : null;
883  }
884 
890  public function loadFromRow( $row ) {
891  $this->mAttribs = get_object_vars( $row );
892  $this->mAttribs['rc_timestamp'] = wfTimestamp( TS_MW, $this->mAttribs['rc_timestamp'] );
893  $this->mAttribs['rc_deleted'] = $row->rc_deleted; // MUST be set
894  }
895 
902  public function getAttribute( $name ) {
903  return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : null;
904  }
905 
909  public function getAttributes() {
910  return $this->mAttribs;
911  }
912 
919  public function diffLinkTrail( $forceCur ) {
920  if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
921  $trail = "curid=" . (int)( $this->mAttribs['rc_cur_id'] ) .
922  "&oldid=" . (int)( $this->mAttribs['rc_last_oldid'] );
923  if ( $forceCur ) {
924  $trail .= '&diff=0';
925  } else {
926  $trail .= '&diff=' . (int)( $this->mAttribs['rc_this_oldid'] );
927  }
928  } else {
929  $trail = '';
930  }
931 
932  return $trail;
933  }
934 
942  public function getCharacterDifference( $old = 0, $new = 0 ) {
943  if ( $old === 0 ) {
944  $old = $this->mAttribs['rc_old_len'];
945  }
946  if ( $new === 0 ) {
947  $new = $this->mAttribs['rc_new_len'];
948  }
949  if ( $old === null || $new === null ) {
950  return '';
951  }
952 
953  return ChangesList::showCharacterDifference( $old, $new );
954  }
955 
956  private static function checkIPAddress( $ip ) {
958  if ( $ip ) {
959  if ( !IP::isIPAddress( $ip ) ) {
960  throw new MWException( "Attempt to write \"" . $ip .
961  "\" as an IP address into recent changes" );
962  }
963  } else {
964  $ip = $wgRequest->getIP();
965  if ( !$ip ) {
966  $ip = '';
967  }
968  }
969 
970  return $ip;
971  }
972 
982  public static function isInRCLifespan( $timestamp, $tolerance = 0 ) {
983  global $wgRCMaxAge;
984 
985  return wfTimestamp( TS_UNIX, $timestamp ) > time() - $tolerance - $wgRCMaxAge;
986  }
987 
995  public function parseParams() {
996  $rcParams = $this->getAttribute( 'rc_params' );
997 
998  MediaWiki\suppressWarnings();
999  $unserializedParams = unserialize( $rcParams );
1000  MediaWiki\restoreWarnings();
1001 
1002  return $unserializedParams;
1003  }
1004 }
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
Definition: User.php:568
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:99
This module processes the email notifications when the current page is changed.
const RC_CATEGORIZE
Definition: Defines.php:173
Utility class for creating new RC entries.
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...
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
the array() calling protocol came about after MediaWiki 1.4rc1.
const SRC_CATEGORIZE
static getChangeTypes()
Get an array of all change types.
getArticleID($flags=0)
Get the article ID for this Title from the link cache, adding it if necessary.
Definition: Title.php:3187
doMarkPatrolled(User $user, $auto=false, $tags=null)
Mark this RecentChange as patrolled.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
getCharacterDifference($old=0, $new=0)
Returns the change size (HTML).
parseParams()
Parses and returns the rc_params attribute.
static newFromId($rcid)
Obtain the recent change with a given rc_id value.
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 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:1928
$comment
null for the local wiki Added in
Definition: hooks.txt:1422
getParam($name)
Get a parameter value.
static newFromId($id)
Static factory method for creation from a given user ID.
Definition: User.php:591
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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:1008
save($noudp=false)
Writes the data in this object to the database.
Represents a title within MediaWiki.
Definition: Title.php:34
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
static isIPAddress($ip)
Determine if a string is as valid IP address or network (CIDR prefix).
Definition: IP.php:79
getName()
Get the user name, or the IP of an anonymous user.
Definition: User.php:2086
static record($rc, $auto=false, User $user=null, $tags=null)
Record a log event for a change being patrolled.
Definition: PatrolLog.php:41
getPerformer()
Get the User object of the person who performed this change.
getAttribute($name)
Get an attribute value.
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 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...
static addCallableUpdate($callable, $type=self::POSTSEND)
Add a callable update.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
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= '')
unserialize($serialized)
Definition: ApiMessage.php:102
isAllowed($action= '')
Internal mechanics of testing a permission.
Definition: User.php:3408
getDBkey()
Get the main part with underscores.
Definition: Title.php:911
if($limit) $timestamp
static checkIPAddress($ip)
static showCharacterDifference($old, $new, IContextSource $context=null)
Show formatted char difference.
static array $changeTypes
Array of change types.
$params
const DB_SLAVE
Definition: Defines.php:46
const SRC_EXTERNAL
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:916
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:934
setExtra($extra)
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
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:1310
static selectFields()
Return the list of recentchanges fields that should be selected to create a new recentchanges object...
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 local account $user
Definition: hooks.txt:246
static array static newFromRow($row)
static singleton($wiki=false)
static parseFromRCType($rcType)
Parsing RC_* constants to human-readable test.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
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
$wgUseEnotif
Definition: Setup.php:361
reallyMarkPatrolled()
Mark this RecentChange patrolled, without error checking.
static getEngine($uri)
Gets the stream engine object for a given URI from $wgRCEngines.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
Definition: Setup.php:35
static markPatrolled($change, $auto=false, $tags=null)
Mark a given change as patrolled.
notifyRCFeeds(array $feeds=null)
Notify all the feeds about the change.
setAttribs($attribs)
int $counter
Line number of recent change.
$line
Definition: cdb.php:59
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 local content language as $wgContLang
Definition: design.txt:56
static addTags($tags, $rc_id=null, $rev_id=null, $log_id=null, $params=null)
Add tags to a change given its rc_id, rev_id and/or log_id.
Definition: ChangeTags.php:126
const RC_EXTERNAL
Definition: Defines.php:172
const DB_MASTER
Definition: Defines.php:47
const RC_NEW
Definition: Defines.php:170
This is to display changes made to all articles linked in an article.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
serialize()
Definition: ApiMessage.php:94
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.
static newLogEntry($timestamp, &$title, &$user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC= '', $revId=0, $isPatrollable=false)
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 local account incomplete not yet checked for validity & $retval
Definition: hooks.txt:246
static parseToRCType($type)
Parsing text to RC_* constants.
if(is_null($wgLocalTZoffset)) if(!$wgDBerrorLogTZ) $wgRequest
Definition: Setup.php:657
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 one of or reset 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:2342
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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 as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive false for true for descending in case the handler function wants to provide a converted Content object Note that $result getContentModel() must return $toModel. 'CustomEditor'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:1103
static newFromConds($conds, $fname=__METHOD__, $dbType=DB_SLAVE)
Find the first recent change matching some specific conditions.
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:524
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:1802
const RC_EDIT
Definition: Defines.php:169
const RC_LOG
Definition: Defines.php:171
getPrefixedDBkey()
Get the prefixed database key form.
Definition: Title.php:1437
$wgUser
Definition: Setup.php:794
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:314