MediaWiki  1.27.2
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  Hooks::run( 'RecentChange_save', [ &$this ] );
316 
317  # Notify external application via UDP
318  if ( !$noudp ) {
319  $this->notifyRCFeeds();
320  }
321 
322  # E-mail notifications
323  if ( $wgUseEnotif || $wgShowUpdatedMarker ) {
324  $editor = $this->getPerformer();
325  $title = $this->getTitle();
326 
327  // Never send an RC notification email about categorization changes
328  if ( $this->mAttribs['rc_type'] != RC_CATEGORIZE ) {
329  if ( Hooks::run( 'AbortEmailNotification', [ $editor, $title, $this ] ) ) {
330  # @todo FIXME: This would be better as an extension hook
331  $enotif = new EmailNotification();
332  $enotif->notifyOnPageChange(
333  $editor,
334  $title,
335  $this->mAttribs['rc_timestamp'],
336  $this->mAttribs['rc_comment'],
337  $this->mAttribs['rc_minor'],
338  $this->mAttribs['rc_last_oldid'],
339  $this->mExtra['pageStatus']
340  );
341  }
342  }
343  }
344 
345  // Update the cached list of active users
346  if ( $this->mAttribs['rc_user'] > 0 ) {
348  }
349  }
350 
355  public function notifyRCFeeds( array $feeds = null ) {
356  global $wgRCFeeds;
357  if ( $feeds === null ) {
358  $feeds = $wgRCFeeds;
359  }
360 
361  $performer = $this->getPerformer();
362 
363  foreach ( $feeds as $feed ) {
364  $feed += [
365  'omit_bots' => false,
366  'omit_anon' => false,
367  'omit_user' => false,
368  'omit_minor' => false,
369  'omit_patrolled' => false,
370  ];
371 
372  if (
373  ( $feed['omit_bots'] && $this->mAttribs['rc_bot'] ) ||
374  ( $feed['omit_anon'] && $performer->isAnon() ) ||
375  ( $feed['omit_user'] && !$performer->isAnon() ) ||
376  ( $feed['omit_minor'] && $this->mAttribs['rc_minor'] ) ||
377  ( $feed['omit_patrolled'] && $this->mAttribs['rc_patrolled'] ) ||
378  $this->mAttribs['rc_type'] == RC_EXTERNAL
379  ) {
380  continue;
381  }
382 
383  $engine = self::getEngine( $feed['uri'] );
384 
385  if ( isset( $this->mExtra['actionCommentIRC'] ) ) {
386  $actionComment = $this->mExtra['actionCommentIRC'];
387  } else {
388  $actionComment = null;
389  }
390 
392  $formatter = is_object( $feed['formatter'] ) ? $feed['formatter'] : new $feed['formatter']();
393  $line = $formatter->getLine( $feed, $this, $actionComment );
394  if ( !$line ) {
395  // T109544
396  // If a feed formatter returns null, this will otherwise cause an
397  // error in at least RedisPubSubFeedEngine.
398  // Not sure where/how this should best be handled.
399  continue;
400  }
401 
402  $engine->send( $feed, $line );
403  }
404  }
405 
413  public static function getEngine( $uri ) {
414  global $wgRCEngines;
415 
416  $scheme = parse_url( $uri, PHP_URL_SCHEME );
417  if ( !$scheme ) {
418  throw new MWException( __FUNCTION__ . ": Invalid stream logger URI: '$uri'" );
419  }
420 
421  if ( !isset( $wgRCEngines[$scheme] ) ) {
422  throw new MWException( __FUNCTION__ . ": Unknown stream logger URI scheme: $scheme" );
423  }
424 
425  return new $wgRCEngines[$scheme];
426  }
427 
437  public static function markPatrolled( $change, $auto = false, $tags = null ) {
438  global $wgUser;
439 
440  $change = $change instanceof RecentChange
441  ? $change
442  : RecentChange::newFromId( $change );
443 
444  if ( !$change instanceof RecentChange ) {
445  return null;
446  }
447 
448  return $change->doMarkPatrolled( $wgUser, $auto, $tags );
449  }
450 
462  public function doMarkPatrolled( User $user, $auto = false, $tags = null ) {
463  global $wgUseRCPatrol, $wgUseNPPatrol, $wgUseFilePatrol;
464 
465  $errors = [];
466  // If recentchanges patrol is disabled, only new pages or new file versions
467  // can be patrolled, provided the appropriate config variable is set
468  if ( !$wgUseRCPatrol && ( !$wgUseNPPatrol || $this->getAttribute( 'rc_type' ) != RC_NEW ) &&
469  ( !$wgUseFilePatrol || !( $this->getAttribute( 'rc_type' ) == RC_LOG &&
470  $this->getAttribute( 'rc_log_type' ) == 'upload' ) ) ) {
471  $errors[] = [ 'rcpatroldisabled' ];
472  }
473  // Automatic patrol needs "autopatrol", ordinary patrol needs "patrol"
474  $right = $auto ? 'autopatrol' : 'patrol';
475  $errors = array_merge( $errors, $this->getTitle()->getUserPermissionsErrors( $right, $user ) );
476  if ( !Hooks::run( 'MarkPatrolled',
477  [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ] )
478  ) {
479  $errors[] = [ 'hookaborted' ];
480  }
481  // Users without the 'autopatrol' right can't patrol their
482  // own revisions
483  if ( $user->getName() === $this->getAttribute( 'rc_user_text' )
484  && !$user->isAllowed( 'autopatrol' )
485  ) {
486  $errors[] = [ 'markedaspatrollederror-noautopatrol' ];
487  }
488  if ( $errors ) {
489  return $errors;
490  }
491  // If the change was patrolled already, do nothing
492  if ( $this->getAttribute( 'rc_patrolled' ) ) {
493  return [];
494  }
495  // Actually set the 'patrolled' flag in RC
496  $this->reallyMarkPatrolled();
497  // Log this patrol event
498  PatrolLog::record( $this, $auto, $user, $tags );
499 
500  Hooks::run(
501  'MarkPatrolledComplete',
502  [ $this->getAttribute( 'rc_id' ), &$user, false, $auto ]
503  );
504 
505  return [];
506  }
507 
512  public function reallyMarkPatrolled() {
513  $dbw = wfGetDB( DB_MASTER );
514  $dbw->update(
515  'recentchanges',
516  [
517  'rc_patrolled' => 1
518  ],
519  [
520  'rc_id' => $this->getAttribute( 'rc_id' )
521  ],
522  __METHOD__
523  );
524  // Invalidate the page cache after the page has been patrolled
525  // to make sure that the Patrol link isn't visible any longer!
526  $this->getTitle()->invalidateCache();
527 
528  return $dbw->affectedRows();
529  }
530 
550  public static function notifyEdit(
551  $timestamp, &$title, $minor, &$user, $comment, $oldId, $lastTimestamp,
552  $bot, $ip = '', $oldSize = 0, $newSize = 0, $newId = 0, $patrol = 0,
553  $tags = []
554  ) {
555  $rc = new RecentChange;
556  $rc->mTitle = $title;
557  $rc->mPerformer = $user;
558  $rc->mAttribs = [
559  'rc_timestamp' => $timestamp,
560  'rc_namespace' => $title->getNamespace(),
561  'rc_title' => $title->getDBkey(),
562  'rc_type' => RC_EDIT,
563  'rc_source' => self::SRC_EDIT,
564  'rc_minor' => $minor ? 1 : 0,
565  'rc_cur_id' => $title->getArticleID(),
566  'rc_user' => $user->getId(),
567  'rc_user_text' => $user->getName(),
568  'rc_comment' => $comment,
569  'rc_this_oldid' => $newId,
570  'rc_last_oldid' => $oldId,
571  'rc_bot' => $bot ? 1 : 0,
572  'rc_ip' => self::checkIPAddress( $ip ),
573  'rc_patrolled' => intval( $patrol ),
574  'rc_new' => 0, # obsolete
575  'rc_old_len' => $oldSize,
576  'rc_new_len' => $newSize,
577  'rc_deleted' => 0,
578  'rc_logid' => 0,
579  'rc_log_type' => null,
580  'rc_log_action' => '',
581  'rc_params' => ''
582  ];
583 
584  $rc->mExtra = [
585  'prefixedDBkey' => $title->getPrefixedDBkey(),
586  'lastTimestamp' => $lastTimestamp,
587  'oldSize' => $oldSize,
588  'newSize' => $newSize,
589  'pageStatus' => 'changed'
590  ];
591 
592  DeferredUpdates::addCallableUpdate( function() use ( $rc, $tags ) {
593  $rc->save();
594  if ( $rc->mAttribs['rc_patrolled'] ) {
595  PatrolLog::record( $rc, true, $rc->getPerformer() );
596  }
597  if ( count( $tags ) ) {
598  ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
599  $rc->mAttribs['rc_this_oldid'], null, null );
600  }
601  } );
602 
603  return $rc;
604  }
605 
623  public static function notifyNew(
624  $timestamp, &$title, $minor, &$user, $comment, $bot,
625  $ip = '', $size = 0, $newId = 0, $patrol = 0, $tags = []
626  ) {
627  $rc = new RecentChange;
628  $rc->mTitle = $title;
629  $rc->mPerformer = $user;
630  $rc->mAttribs = [
631  'rc_timestamp' => $timestamp,
632  'rc_namespace' => $title->getNamespace(),
633  'rc_title' => $title->getDBkey(),
634  'rc_type' => RC_NEW,
635  'rc_source' => self::SRC_NEW,
636  'rc_minor' => $minor ? 1 : 0,
637  'rc_cur_id' => $title->getArticleID(),
638  'rc_user' => $user->getId(),
639  'rc_user_text' => $user->getName(),
640  'rc_comment' => $comment,
641  'rc_this_oldid' => $newId,
642  'rc_last_oldid' => 0,
643  'rc_bot' => $bot ? 1 : 0,
644  'rc_ip' => self::checkIPAddress( $ip ),
645  'rc_patrolled' => intval( $patrol ),
646  'rc_new' => 1, # obsolete
647  'rc_old_len' => 0,
648  'rc_new_len' => $size,
649  'rc_deleted' => 0,
650  'rc_logid' => 0,
651  'rc_log_type' => null,
652  'rc_log_action' => '',
653  'rc_params' => ''
654  ];
655 
656  $rc->mExtra = [
657  'prefixedDBkey' => $title->getPrefixedDBkey(),
658  'lastTimestamp' => 0,
659  'oldSize' => 0,
660  'newSize' => $size,
661  'pageStatus' => 'created'
662  ];
663 
664  DeferredUpdates::addCallableUpdate( function() use ( $rc, $tags ) {
665  $rc->save();
666  if ( $rc->mAttribs['rc_patrolled'] ) {
667  PatrolLog::record( $rc, true, $rc->getPerformer() );
668  }
669  if ( count( $tags ) ) {
670  ChangeTags::addTags( $tags, $rc->mAttribs['rc_id'],
671  $rc->mAttribs['rc_this_oldid'], null, null );
672  }
673  } );
674 
675  return $rc;
676  }
677 
693  public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip, $type,
694  $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = ''
695  ) {
696  global $wgLogRestrictions;
697 
698  # Don't add private logs to RC!
699  if ( isset( $wgLogRestrictions[$type] ) && $wgLogRestrictions[$type] != '*' ) {
700  return false;
701  }
702  $rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action,
703  $target, $logComment, $params, $newId, $actionCommentIRC );
704  $rc->save();
705 
706  return true;
707  }
708 
726  public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip,
727  $type, $action, $target, $logComment, $params, $newId = 0, $actionCommentIRC = '',
728  $revId = 0, $isPatrollable = false ) {
730 
731  # # Get pageStatus for email notification
732  switch ( $type . '-' . $action ) {
733  case 'delete-delete':
734  $pageStatus = 'deleted';
735  break;
736  case 'move-move':
737  case 'move-move_redir':
738  $pageStatus = 'moved';
739  break;
740  case 'delete-restore':
741  $pageStatus = 'restored';
742  break;
743  case 'upload-upload':
744  $pageStatus = 'created';
745  break;
746  case 'upload-overwrite':
747  default:
748  $pageStatus = 'changed';
749  break;
750  }
751 
752  // Allow unpatrolled status for patrollable log entries
753  $markPatrolled = $isPatrollable ? $user->isAllowed( 'autopatrol' ) : true;
754 
755  $rc = new RecentChange;
756  $rc->mTitle = $target;
757  $rc->mPerformer = $user;
758  $rc->mAttribs = [
759  'rc_timestamp' => $timestamp,
760  'rc_namespace' => $target->getNamespace(),
761  'rc_title' => $target->getDBkey(),
762  'rc_type' => RC_LOG,
763  'rc_source' => self::SRC_LOG,
764  'rc_minor' => 0,
765  'rc_cur_id' => $target->getArticleID(),
766  'rc_user' => $user->getId(),
767  'rc_user_text' => $user->getName(),
768  'rc_comment' => $logComment,
769  'rc_this_oldid' => $revId,
770  'rc_last_oldid' => 0,
771  'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0,
772  'rc_ip' => self::checkIPAddress( $ip ),
773  'rc_patrolled' => $markPatrolled ? 1 : 0,
774  'rc_new' => 0, # obsolete
775  'rc_old_len' => null,
776  'rc_new_len' => null,
777  'rc_deleted' => 0,
778  'rc_logid' => $newId,
779  'rc_log_type' => $type,
780  'rc_log_action' => $action,
781  'rc_params' => $params
782  ];
783 
784  $rc->mExtra = [
785  'prefixedDBkey' => $title->getPrefixedDBkey(),
786  'lastTimestamp' => 0,
787  'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
788  'pageStatus' => $pageStatus,
789  'actionCommentIRC' => $actionCommentIRC
790  ];
791 
792  return $rc;
793  }
794 
815  public static function newForCategorization(
816  $timestamp,
817  Title $categoryTitle,
818  User $user = null,
819  $comment,
820  Title $pageTitle,
821  $oldRevId,
822  $newRevId,
823  $lastTimestamp,
824  $bot,
825  $ip = '',
826  $deleted = 0
827  ) {
828  $rc = new RecentChange;
829  $rc->mTitle = $categoryTitle;
830  $rc->mPerformer = $user;
831  $rc->mAttribs = [
832  'rc_timestamp' => $timestamp,
833  'rc_namespace' => $categoryTitle->getNamespace(),
834  'rc_title' => $categoryTitle->getDBkey(),
835  'rc_type' => RC_CATEGORIZE,
836  'rc_source' => self::SRC_CATEGORIZE,
837  'rc_minor' => 0,
838  'rc_cur_id' => $pageTitle->getArticleID(),
839  'rc_user' => $user ? $user->getId() : 0,
840  'rc_user_text' => $user ? $user->getName() : '',
841  'rc_comment' => $comment,
842  'rc_this_oldid' => $newRevId,
843  'rc_last_oldid' => $oldRevId,
844  'rc_bot' => $bot ? 1 : 0,
845  'rc_ip' => self::checkIPAddress( $ip ),
846  'rc_patrolled' => 1, // Always patrolled, just like log entries
847  'rc_new' => 0, # obsolete
848  'rc_old_len' => null,
849  'rc_new_len' => null,
850  'rc_deleted' => $deleted,
851  'rc_logid' => 0,
852  'rc_log_type' => null,
853  'rc_log_action' => '',
854  'rc_params' => serialize( [
855  'hidden-cat' => WikiCategoryPage::factory( $categoryTitle )->isHidden()
856  ] )
857  ];
858 
859  $rc->mExtra = [
860  'prefixedDBkey' => $categoryTitle->getPrefixedDBkey(),
861  'lastTimestamp' => $lastTimestamp,
862  'oldSize' => 0,
863  'newSize' => 0,
864  'pageStatus' => 'changed'
865  ];
866 
867  return $rc;
868  }
869 
878  public function getParam( $name ) {
879  $params = $this->parseParams();
880  return isset( $params[$name] ) ? $params[$name] : null;
881  }
882 
888  public function loadFromRow( $row ) {
889  $this->mAttribs = get_object_vars( $row );
890  $this->mAttribs['rc_timestamp'] = wfTimestamp( TS_MW, $this->mAttribs['rc_timestamp'] );
891  $this->mAttribs['rc_deleted'] = $row->rc_deleted; // MUST be set
892  }
893 
900  public function getAttribute( $name ) {
901  return isset( $this->mAttribs[$name] ) ? $this->mAttribs[$name] : null;
902  }
903 
907  public function getAttributes() {
908  return $this->mAttribs;
909  }
910 
917  public function diffLinkTrail( $forceCur ) {
918  if ( $this->mAttribs['rc_type'] == RC_EDIT ) {
919  $trail = "curid=" . (int)( $this->mAttribs['rc_cur_id'] ) .
920  "&oldid=" . (int)( $this->mAttribs['rc_last_oldid'] );
921  if ( $forceCur ) {
922  $trail .= '&diff=0';
923  } else {
924  $trail .= '&diff=' . (int)( $this->mAttribs['rc_this_oldid'] );
925  }
926  } else {
927  $trail = '';
928  }
929 
930  return $trail;
931  }
932 
940  public function getCharacterDifference( $old = 0, $new = 0 ) {
941  if ( $old === 0 ) {
942  $old = $this->mAttribs['rc_old_len'];
943  }
944  if ( $new === 0 ) {
945  $new = $this->mAttribs['rc_new_len'];
946  }
947  if ( $old === null || $new === null ) {
948  return '';
949  }
950 
951  return ChangesList::showCharacterDifference( $old, $new );
952  }
953 
954  private static function checkIPAddress( $ip ) {
956  if ( $ip ) {
957  if ( !IP::isIPAddress( $ip ) ) {
958  throw new MWException( "Attempt to write \"" . $ip .
959  "\" as an IP address into recent changes" );
960  }
961  } else {
962  $ip = $wgRequest->getIP();
963  if ( !$ip ) {
964  $ip = '';
965  }
966  }
967 
968  return $ip;
969  }
970 
980  public static function isInRCLifespan( $timestamp, $tolerance = 0 ) {
981  global $wgRCMaxAge;
982 
983  return wfTimestamp( TS_UNIX, $timestamp ) > time() - $tolerance - $wgRCMaxAge;
984  }
985 
993  public function parseParams() {
994  $rcParams = $this->getAttribute( 'rc_params' );
995 
996  MediaWiki\suppressWarnings();
997  $unserializedParams = unserialize( $rcParams );
998  MediaWiki\restoreWarnings();
999 
1000  return $unserializedParams;
1001  }
1002 }
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:1924
$comment
null for the local wiki Added in
Definition: hooks.txt:1418
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:1004
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:912
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:1306
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:242
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:242
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:2338
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:1099
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:1798
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:310