MediaWiki  1.33.0
ContribsPager.php
Go to the documentation of this file.
1 <?php
30 
32 
36  private $messages;
37 
41  private $target;
42 
47  private $contribs;
48 
52  private $namespace = '';
53 
57  private $tagFilter;
58 
62  private $nsInvert;
63 
68  private $associated;
69 
73  private $deletedOnly;
74 
78  private $topOnly;
79 
83  private $newOnly;
84 
88  private $hideMinor;
89 
90  private $preventClickjacking = false;
91 
93  private $mDbSecondary;
94 
98  private $mParentLens;
99 
104 
106  parent::__construct( $context );
107 
108  $msgs = [
109  'diff',
110  'hist',
111  'pipe-separator',
112  'uctop'
113  ];
114 
115  foreach ( $msgs as $msg ) {
116  $this->messages[$msg] = $this->msg( $msg )->escaped();
117  }
118 
119  $this->target = $options['target'] ?? '';
120  $this->contribs = $options['contribs'] ?? 'users';
121  $this->namespace = $options['namespace'] ?? '';
122  $this->tagFilter = $options['tagfilter'] ?? false;
123  $this->nsInvert = $options['nsInvert'] ?? false;
124  $this->associated = $options['associated'] ?? false;
125 
126  $this->deletedOnly = !empty( $options['deletedOnly'] );
127  $this->topOnly = !empty( $options['topOnly'] );
128  $this->newOnly = !empty( $options['newOnly'] );
129  $this->hideMinor = !empty( $options['hideMinor'] );
130 
131  // Date filtering: use timestamp if available
132  $startTimestamp = '';
133  $endTimestamp = '';
134  if ( $options['start'] ) {
135  $startTimestamp = $options['start'] . ' 00:00:00';
136  }
137  if ( $options['end'] ) {
138  $endTimestamp = $options['end'] . ' 23:59:59';
139  }
140  $this->getDateRangeCond( $startTimestamp, $endTimestamp );
141 
142  // Most of this code will use the 'contributions' group DB, which can map to replica DBs
143  // with extra user based indexes or partioning by user. The additional metadata
144  // queries should use a regular replica DB since the lookup pattern is not all by user.
145  $this->mDbSecondary = wfGetDB( DB_REPLICA ); // any random replica DB
146  $this->mDb = wfGetDB( DB_REPLICA, 'contributions' );
147  $this->templateParser = new TemplateParser();
148  }
149 
150  function getDefaultQuery() {
151  $query = parent::getDefaultQuery();
152  $query['target'] = $this->target;
153 
154  return $query;
155  }
156 
164  function getNavigationBar() {
165  return Html::rawElement( 'p', [ 'class' => 'mw-pager-navigation-bar' ],
166  parent::getNavigationBar()
167  );
168  }
169 
179  function reallyDoQuery( $offset, $limit, $order ) {
180  list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo(
181  $offset,
182  $limit,
183  $order
184  );
185 
186  /*
187  * This hook will allow extensions to add in additional queries, so they can get their data
188  * in My Contributions as well. Extensions should append their results to the $data array.
189  *
190  * Extension queries have to implement the navbar requirement as well. They should
191  * - have a column aliased as $pager->getIndexField()
192  * - have LIMIT set
193  * - have a WHERE-clause that compares the $pager->getIndexField()-equivalent column to the offset
194  * - have the ORDER BY specified based upon the details provided by the navbar
195  *
196  * See includes/Pager.php buildQueryInfo() method on how to build LIMIT, WHERE & ORDER BY
197  *
198  * &$data: an array of results of all contribs queries
199  * $pager: the ContribsPager object hooked into
200  * $offset: see phpdoc above
201  * $limit: see phpdoc above
202  * $descending: see phpdoc above
203  */
204  $data = [ $this->mDb->select(
205  $tables, $fields, $conds, $fname, $options, $join_conds
206  ) ];
207  Hooks::run(
208  'ContribsPager::reallyDoQuery',
209  [ &$data, $this, $offset, $limit, $order ]
210  );
211 
212  $result = [];
213 
214  // loop all results and collect them in an array
215  foreach ( $data as $query ) {
216  foreach ( $query as $i => $row ) {
217  // use index column as key, allowing us to easily sort in PHP
218  $result[$row->{$this->getIndexField()} . "-$i"] = $row;
219  }
220  }
221 
222  // sort results
223  if ( $order === self::QUERY_ASCENDING ) {
224  ksort( $result );
225  } else {
226  krsort( $result );
227  }
228 
229  // enforce limit
230  $result = array_slice( $result, 0, $limit );
231 
232  // get rid of array keys
233  $result = array_values( $result );
234 
235  return new FakeResultWrapper( $result );
236  }
237 
238  function getQueryInfo() {
239  $revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
240  $queryInfo = [
241  'tables' => $revQuery['tables'],
242  'fields' => array_merge( $revQuery['fields'], [ 'page_is_new' ] ),
243  'conds' => [],
244  'options' => [],
245  'join_conds' => $revQuery['joins'],
246  ];
247 
248  if ( $this->contribs == 'newbie' ) {
249  $max = $this->mDb->selectField( 'user', 'max(user_id)', '', __METHOD__ );
250  $queryInfo['conds'][] = $revQuery['fields']['rev_user'] . ' >' . (int)( $max - $max / 100 );
251  # ignore local groups with the bot right
252  # @todo FIXME: Global groups may have 'bot' rights
253  $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
254  if ( count( $groupsWithBotPermission ) ) {
255  $queryInfo['tables'][] = 'user_groups';
256  $queryInfo['conds'][] = 'ug_group IS NULL';
257  $queryInfo['join_conds']['user_groups'] = [
258  'LEFT JOIN', [
259  'ug_user = ' . $revQuery['fields']['rev_user'],
260  'ug_group' => $groupsWithBotPermission,
261  'ug_expiry IS NULL OR ug_expiry >= ' .
262  $this->mDb->addQuotes( $this->mDb->timestamp() )
263  ]
264  ];
265  }
266  // (T140537) Disallow looking too far in the past for 'newbies' queries. If the user requested
267  // a timestamp offset far in the past such that there are no edits by users with user_ids in
268  // the range, we would end up scanning all revisions from that offset until start of time.
269  $queryInfo['conds'][] = 'rev_timestamp > ' .
270  $this->mDb->addQuotes( $this->mDb->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) );
271  } else {
272  $user = User::newFromName( $this->target, false );
273  $ipRangeConds = $user->isAnon() ? $this->getIpRangeConds( $this->mDb, $this->target ) : null;
274  if ( $ipRangeConds ) {
275  $queryInfo['tables'][] = 'ip_changes';
282  $queryInfo['fields'] = array_merge(
283  [
284  'rev_timestamp' => 'ipc_rev_timestamp',
285  'rev_id' => 'ipc_rev_id',
286  ],
287  array_diff( $queryInfo['fields'], [
288  'rev_timestamp',
289  'rev_id',
290  ] )
291  );
292  $queryInfo['join_conds']['ip_changes'] = [
293  'LEFT JOIN', [ 'ipc_rev_id = rev_id' ]
294  ];
295  $queryInfo['conds'][] = $ipRangeConds;
296  } else {
297  // tables and joins are already handled by Revision::getQueryInfo()
298  $conds = ActorMigration::newMigration()->getWhere( $this->mDb, 'rev_user', $user );
299  $queryInfo['conds'][] = $conds['conds'];
300  // Force the appropriate index to avoid bad query plans (T189026)
301  if ( isset( $conds['orconds']['actor'] ) ) {
302  // @todo: This will need changing when revision_comment_temp goes away
303  $queryInfo['options']['USE INDEX']['temp_rev_user'] = 'actor_timestamp';
304  // Alias 'rev_timestamp' => 'revactor_timestamp' so "ORDER BY rev_timestamp" is interpreted to
305  // use revactor_timestamp instead.
306  $queryInfo['fields'] = array_merge(
307  array_diff( $queryInfo['fields'], [ 'rev_timestamp' ] ),
308  [ 'rev_timestamp' => 'revactor_timestamp' ]
309  );
310  } else {
311  $queryInfo['options']['USE INDEX']['revision'] =
312  isset( $conds['orconds']['userid'] ) ? 'user_timestamp' : 'usertext_timestamp';
313  }
314  }
315  }
316 
317  if ( $this->deletedOnly ) {
318  $queryInfo['conds'][] = 'rev_deleted != 0';
319  }
320 
321  if ( $this->topOnly ) {
322  $queryInfo['conds'][] = 'rev_id = page_latest';
323  }
324 
325  if ( $this->newOnly ) {
326  $queryInfo['conds'][] = 'rev_parent_id = 0';
327  }
328 
329  if ( $this->hideMinor ) {
330  $queryInfo['conds'][] = 'rev_minor_edit = 0';
331  }
332 
333  $user = $this->getUser();
334  $queryInfo['conds'] = array_merge( $queryInfo['conds'], $this->getNamespaceCond() );
335 
336  // Paranoia: avoid brute force searches (T19342)
337  if ( !$user->isAllowed( 'deletedhistory' ) ) {
338  $queryInfo['conds'][] = $this->mDb->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0';
339  } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
340  $queryInfo['conds'][] = $this->mDb->bitAnd( 'rev_deleted', Revision::SUPPRESSED_USER ) .
341  ' != ' . Revision::SUPPRESSED_USER;
342  }
343 
344  // For IPv6, we use ipc_rev_timestamp on ip_changes as the index field,
345  // which will be referenced when parsing the results of a query.
346  if ( self::isQueryableRange( $this->target ) ) {
347  $queryInfo['fields'][] = 'ipc_rev_timestamp';
348  }
349 
351  $queryInfo['tables'],
352  $queryInfo['fields'],
353  $queryInfo['conds'],
354  $queryInfo['join_conds'],
355  $queryInfo['options'],
356  $this->tagFilter
357  );
358 
359  // Avoid PHP 7.1 warning from passing $this by reference
360  $pager = $this;
361  Hooks::run( 'ContribsPager::getQueryInfo', [ &$pager, &$queryInfo ] );
362 
363  return $queryInfo;
364  }
365 
366  function getNamespaceCond() {
367  if ( $this->namespace !== '' ) {
368  $selectedNS = $this->mDb->addQuotes( $this->namespace );
369  $eq_op = $this->nsInvert ? '!=' : '=';
370  $bool_op = $this->nsInvert ? 'AND' : 'OR';
371 
372  if ( !$this->associated ) {
373  return [ "page_namespace $eq_op $selectedNS" ];
374  }
375 
376  $associatedNS = $this->mDb->addQuotes(
377  MWNamespace::getAssociated( $this->namespace )
378  );
379 
380  return [
381  "page_namespace $eq_op $selectedNS " .
382  $bool_op .
383  " page_namespace $eq_op $associatedNS"
384  ];
385  }
386 
387  return [];
388  }
389 
396  private function getIpRangeConds( $db, $ip ) {
397  // First make sure it is a valid range and they are not outside the CIDR limit
398  if ( !$this->isQueryableRange( $ip ) ) {
399  return false;
400  }
401 
402  list( $start, $end ) = IP::parseRange( $ip );
403 
404  return 'ipc_hex BETWEEN ' . $db->addQuotes( $start ) . ' AND ' . $db->addQuotes( $end );
405  }
406 
414  public function isQueryableRange( $ipRange ) {
415  $limits = $this->getConfig()->get( 'RangeContributionsCIDRLimit' );
416 
417  $bits = IP::parseCIDR( $ipRange )[1];
418  if (
419  ( $bits === false ) ||
420  ( IP::isIPv4( $ipRange ) && $bits < $limits['IPv4'] ) ||
421  ( IP::isIPv6( $ipRange ) && $bits < $limits['IPv6'] )
422  ) {
423  return false;
424  }
425 
426  return true;
427  }
428 
432  public function getIndexField() {
433  // Note this is run via parent::__construct() *before* $this->target is set!
434  return 'rev_timestamp';
435  }
436 
440  public function getTagFilter() {
441  return $this->tagFilter;
442  }
443 
447  public function getContribs() {
448  return $this->contribs;
449  }
450 
454  public function getTarget() {
455  return $this->target;
456  }
457 
461  public function isNewOnly() {
462  return $this->newOnly;
463  }
464 
468  public function getNamespace() {
469  return $this->namespace;
470  }
471 
475  protected function getExtraSortFields() {
476  // Note this is run via parent::__construct() *before* $this->target is set!
477  return [ 'rev_id' ];
478  }
479 
480  protected function doBatchLookups() {
481  # Do a link batch query
482  $this->mResult->seek( 0 );
483  $parentRevIds = [];
484  $this->mParentLens = [];
485  $batch = new LinkBatch();
486  $isIpRange = $this->isQueryableRange( $this->target );
487  # Give some pointers to make (last) links
488  foreach ( $this->mResult as $row ) {
489  if ( isset( $row->rev_parent_id ) && $row->rev_parent_id ) {
490  $parentRevIds[] = $row->rev_parent_id;
491  }
492  if ( isset( $row->rev_id ) ) {
493  $this->mParentLens[$row->rev_id] = $row->rev_len;
494  if ( $this->contribs === 'newbie' ) { // multiple users
495  $batch->add( NS_USER, $row->user_name );
496  $batch->add( NS_USER_TALK, $row->user_name );
497  } elseif ( $isIpRange ) {
498  // If this is an IP range, batch the IP's talk page
499  $batch->add( NS_USER_TALK, $row->rev_user_text );
500  }
501  $batch->add( $row->page_namespace, $row->page_title );
502  }
503  }
504  # Fetch rev_len for revisions not already scanned above
505  $this->mParentLens += Revision::getParentLengths(
506  $this->mDbSecondary,
507  array_diff( $parentRevIds, array_keys( $this->mParentLens ) )
508  );
509  $batch->execute();
510  $this->mResult->seek( 0 );
511  }
512 
516  protected function getStartBody() {
517  return "<ul class=\"mw-contributions-list\">\n";
518  }
519 
523  protected function getEndBody() {
524  return "</ul>\n";
525  }
526 
535  public function tryToCreateValidRevision( $row, $title = null ) {
536  /*
537  * There may be more than just revision rows. To make sure that we'll only be processing
538  * revisions here, let's _try_ to build a revision out of our row (without displaying
539  * notices though) and then trying to grab data from the built object. If we succeed,
540  * we're definitely dealing with revision data and we may proceed, if not, we'll leave it
541  * to extensions to subscribe to the hook to parse the row.
542  */
543  Wikimedia\suppressWarnings();
544  try {
545  $rev = new Revision( $row, 0, $title );
546  $validRevision = (bool)$rev->getId();
547  } catch ( Exception $e ) {
548  $validRevision = false;
549  }
550  Wikimedia\restoreWarnings();
551  return $validRevision ? $rev : null;
552  }
553 
566  function formatRow( $row ) {
567  $ret = '';
568  $classes = [];
569  $attribs = [];
570 
571  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
572 
573  $page = null;
574  // Create a title for the revision if possible
575  // Rows from the hook may not include title information
576  if ( isset( $row->page_namespace ) && isset( $row->page_title ) ) {
577  $page = Title::newFromRow( $row );
578  }
579  $rev = $this->tryToCreateValidRevision( $row, $page );
580  if ( $rev ) {
581  $attribs['data-mw-revid'] = $rev->getId();
582 
583  $link = $linkRenderer->makeLink(
584  $page,
585  $page->getPrefixedText(),
586  [ 'class' => 'mw-contributions-title' ],
587  $page->isRedirect() ? [ 'redirect' => 'no' ] : []
588  );
589  # Mark current revisions
590  $topmarktext = '';
591  $user = $this->getUser();
592 
593  if ( $row->rev_id === $row->page_latest ) {
594  $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
595  $classes[] = 'mw-contributions-current';
596  # Add rollback link
597  if ( !$row->page_is_new && $page->quickUserCan( 'rollback', $user )
598  && $page->quickUserCan( 'edit', $user )
599  ) {
600  $this->preventClickjacking();
601  $topmarktext .= ' ' . Linker::generateRollback( $rev, $this->getContext() );
602  }
603  }
604  # Is there a visible previous revision?
605  if ( $rev->userCan( Revision::DELETED_TEXT, $user ) && $rev->getParentId() !== 0 ) {
606  $difftext = $linkRenderer->makeKnownLink(
607  $page,
608  new HtmlArmor( $this->messages['diff'] ),
609  [ 'class' => 'mw-changeslist-diff' ],
610  [
611  'diff' => 'prev',
612  'oldid' => $row->rev_id
613  ]
614  );
615  } else {
616  $difftext = $this->messages['diff'];
617  }
618  $histlink = $linkRenderer->makeKnownLink(
619  $page,
620  new HtmlArmor( $this->messages['hist'] ),
621  [ 'class' => 'mw-changeslist-history' ],
622  [ 'action' => 'history' ]
623  );
624 
625  if ( $row->rev_parent_id === null ) {
626  // For some reason rev_parent_id isn't populated for this row.
627  // Its rumoured this is true on wikipedia for some revisions (T36922).
628  // Next best thing is to have the total number of bytes.
629  $chardiff = ' <span class="mw-changeslist-separator"></span> ';
630  $chardiff .= Linker::formatRevisionSize( $row->rev_len );
631  $chardiff .= ' <span class="mw-changeslist-separator"></span> ';
632  } else {
633  $parentLen = 0;
634  if ( isset( $this->mParentLens[$row->rev_parent_id] ) ) {
635  $parentLen = $this->mParentLens[$row->rev_parent_id];
636  }
637 
638  $chardiff = ' <span class="mw-changeslist-separator"></span> ';
640  $parentLen,
641  $row->rev_len,
642  $this->getContext()
643  );
644  $chardiff .= ' <span class="mw-changeslist-separator"></span> ';
645  }
646 
647  $lang = $this->getLanguage();
648  $comment = $lang->getDirMark() . Linker::revComment( $rev, false, true, false );
649  $d = ChangesList::revDateLink( $rev, $user, $lang, $page );
650 
651  # Show user names for /newbies as there may be different users.
652  # Note that only unprivileged users have rows with hidden user names excluded.
653  # When querying for an IP range, we want to always show user and user talk links.
654  $userlink = '';
655  if ( ( $this->contribs == 'newbie' && !$rev->isDeleted( Revision::DELETED_USER ) )
656  || $this->isQueryableRange( $this->target ) ) {
657  $userlink = ' <span class="mw-changeslist-separator"></span> '
658  . $lang->getDirMark()
659  . Linker::userLink( $rev->getUser(), $rev->getUserText() );
660  $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
661  Linker::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
662  }
663 
664  $flags = [];
665  if ( $rev->getParentId() === 0 ) {
666  $flags[] = ChangesList::flag( 'newpage' );
667  }
668 
669  if ( $rev->isMinor() ) {
670  $flags[] = ChangesList::flag( 'minor' );
671  }
672 
673  $del = Linker::getRevDeleteLink( $user, $rev, $page );
674  if ( $del !== '' ) {
675  $del .= ' ';
676  }
677 
678  // While it might be tempting to use a list here
679  // this would result in clutter and slows down navigating the content
680  // in assistive technology.
681  // See https://phabricator.wikimedia.org/T205581#4734812
682  $diffHistLinks = Html::rawElement( 'span',
683  [ 'class' => 'mw-changeslist-links' ],
684  // The spans are needed to ensure the dividing '|' elements are not
685  // themselves styled as links.
686  Html::rawElement( 'span', [], $difftext ) .
687  ' ' . // Space needed for separating two words.
688  Html::rawElement( 'span', [], $histlink )
689  );
690 
691  # Tags, if any.
692  list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
693  $row->ts_tags,
694  'contributions',
695  $this->getContext()
696  );
697  $classes = array_merge( $classes, $newClasses );
698 
699  Hooks::run( 'SpecialContributions::formatRow::flags', [ $this->getContext(), $row, &$flags ] );
700 
701  $templateParams = [
702  'del' => $del,
703  'timestamp' => $d,
704  'diffHistLinks' => $diffHistLinks,
705  'charDifference' => $chardiff,
706  'flags' => $flags,
707  'articleLink' => $link,
708  'userlink' => $userlink,
709  'logText' => $comment,
710  'topmarktext' => $topmarktext,
711  'tagSummary' => $tagSummary,
712  ];
713 
714  # Denote if username is redacted for this edit
715  if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
716  $templateParams['rev-deleted-user-contribs'] =
717  $this->msg( 'rev-deleted-user-contribs' )->escaped();
718  }
719 
720  $ret = $this->templateParser->processTemplate(
721  'SpecialContributionsLine',
722  $templateParams
723  );
724  }
725 
726  // Let extensions add data
727  Hooks::run( 'ContributionsLineEnding', [ $this, &$ret, $row, &$classes, &$attribs ] );
728  $attribs = array_filter( $attribs,
729  [ Sanitizer::class, 'isReservedDataAttribute' ],
730  ARRAY_FILTER_USE_KEY
731  );
732 
733  // TODO: Handle exceptions in the catch block above. Do any extensions rely on
734  // receiving empty rows?
735 
736  if ( $classes === [] && $attribs === [] && $ret === '' ) {
737  wfDebug( "Dropping Special:Contribution row that could not be formatted\n" );
738  return "<!-- Could not format Special:Contribution row. -->\n";
739  }
740  $attribs['class'] = $classes;
741 
742  // FIXME: The signature of the ContributionsLineEnding hook makes it
743  // very awkward to move this LI wrapper into the template.
744  return Html::rawElement( 'li', $attribs, $ret ) . "\n";
745  }
746 
751  function getSqlComment() {
752  if ( $this->namespace || $this->deletedOnly ) {
753  // potentially slow, see CR r58153
754  return 'contributions page filtered for namespace or RevisionDeleted edits';
755  } else {
756  return 'contributions page unfiltered';
757  }
758  }
759 
760  protected function preventClickjacking() {
761  $this->preventClickjacking = true;
762  }
763 
767  public function getPreventClickjacking() {
768  return $this->preventClickjacking;
769  }
770 
777  public static function processDateFilter( array $opts ) {
778  $start = $opts['start'] ?? '';
779  $end = $opts['end'] ?? '';
780  $year = $opts['year'] ?? '';
781  $month = $opts['month'] ?? '';
782 
783  if ( $start !== '' && $end !== '' && $start > $end ) {
784  $temp = $start;
785  $start = $end;
786  $end = $temp;
787  }
788 
789  // If year/month legacy filtering options are set, convert them to display the new stamp
790  if ( $year !== '' || $month !== '' ) {
791  // Reuse getDateCond logic, but subtract a day because
792  // the endpoints of our date range appear inclusive
793  // but the internal end offsets are always exclusive
794  $legacyTimestamp = ReverseChronologicalPager::getOffsetDate( $year, $month );
795  $legacyDateTime = new DateTime( $legacyTimestamp->getTimestamp( TS_ISO_8601 ) );
796  $legacyDateTime = $legacyDateTime->modify( '-1 day' );
797 
798  // Clear the new timestamp range options if used and
799  // replace with the converted legacy timestamp
800  $start = '';
801  $end = $legacyDateTime->format( 'Y-m-d' );
802  }
803 
804  $opts['start'] = $start;
805  $opts['end'] = $end;
806 
807  return $opts;
808  }
809 }
ReverseChronologicalPager\getOffsetDate
static getOffsetDate( $year, $month, $day=-1)
Core logic of determining the mOffset timestamp such that we can get all items with a timestamp up to...
Definition: ReverseChronologicalPager.php:122
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:48
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:33
ContribsPager\getNamespace
getNamespace()
Definition: ContribsPager.php:468
$user
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1476
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:28
Linker\userTalkLink
static userTalkLink( $userId, $userText)
Definition: Linker.php:1016
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:892
ContribsPager\$topOnly
bool $topOnly
Set to true to show only latest (a.k.a.
Definition: ContribsPager.php:78
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
captcha-old.count
count
Definition: captcha-old.py:249
ContextSource\msg
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:168
ContribsPager\__construct
__construct(IContextSource $context, array $options)
Definition: ContribsPager.php:105
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1983
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1912
ContribsPager\getDefaultQuery
getDefaultQuery()
Get an array of query parameters that should be put into self-links.
Definition: ContribsPager.php:150
$tables
this hook is for auditing only 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 & $tables
Definition: hooks.txt:979
ContribsPager\getSqlComment
getSqlComment()
Overwrite Pager function and return a helpful comment.
Definition: ContribsPager.php:751
Linker\revComment
static revComment(Revision $rev, $local=false, $isPublic=false, $useParentheses=true)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
Definition: Linker.php:1510
ContribsPager\formatRow
formatRow( $row)
Generates each row in the contributions list.
Definition: ContribsPager.php:566
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:585
IP\isIPv6
static isIPv6( $ip)
Given a string, determine if it as valid IP in IPv6 only.
Definition: IP.php:88
$linkRenderer
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 before processing starts Return false to skip default processing and return $ret $linkRenderer
Definition: hooks.txt:1985
ContribsPager\reallyDoQuery
reallyDoQuery( $offset, $limit, $order)
This method basically executes the exact same code as the parent class, though with a hook added,...
Definition: ContribsPager.php:179
ContribsPager\$mDbSecondary
IDatabase $mDbSecondary
Definition: ContribsPager.php:93
ContribsPager\tryToCreateValidRevision
tryToCreateValidRevision( $row, $title=null)
Check whether the revision associated is valid for formatting.
Definition: ContribsPager.php:535
Wikimedia\Rdbms\FakeResultWrapper
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Definition: FakeResultWrapper.php:11
ContribsPager\$target
string $target
User name, or a string describing an IP address range.
Definition: ContribsPager.php:41
getContext
getContext()
ContribsPager\doBatchLookups
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
Definition: ContribsPager.php:480
$revQuery
$revQuery
Definition: testCompression.php:51
ActorMigration\newMigration
static newMigration()
Static constructor.
Definition: ActorMigration.php:111
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
ContribsPager\processDateFilter
static processDateFilter(array $opts)
Set up date filter options, given request data.
Definition: ContribsPager.php:777
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
Revision
Definition: Revision.php:40
ContribsPager\getPreventClickjacking
getPreventClickjacking()
Definition: ContribsPager.php:767
ChangeTags\modifyDisplayQuery
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
Definition: ChangeTags.php:728
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1588
$data
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Definition: generatePhpCharToUpperMappings.php:13
Revision\SUPPRESSED_USER
const SUPPRESSED_USER
Definition: Revision.php:50
ContribsPager\getNamespaceCond
getNamespaceCond()
Definition: ContribsPager.php:366
Revision\getQueryInfo
static getQueryInfo( $options=[])
Return the tables, fields, and join conditions to be selected to create a new revision object.
Definition: Revision.php:511
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
Linker\generateRollback
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition: Linker.php:1750
ContribsPager\getTarget
getTarget()
Definition: ContribsPager.php:454
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
ContribsPager\getStartBody
getStartBody()
Definition: ContribsPager.php:516
Title\newFromRow
static newFromRow( $row)
Make a Title object from a DB row.
Definition: Title.php:506
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2636
RangeChronologicalPager\getDateRangeCond
getDateRangeCond( $startStamp, $endStamp)
Set and return a date range condition using timestamps provided by the user.
Definition: RangeChronologicalPager.php:43
ContribsPager\$deletedOnly
bool $deletedOnly
Set to true to show only deleted revisions.
Definition: ContribsPager.php:73
$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:1985
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
ChangesList\flag
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
Definition: ChangesList.php:253
ContribsPager\isNewOnly
isNewOnly()
Definition: ContribsPager.php:461
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:949
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
RangeChronologicalPager
Pager for filtering by a range of dates.
Definition: RangeChronologicalPager.php:27
$fname
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition: Setup.php:123
ContribsPager
Definition: ContribsPager.php:31
ContribsPager\$contribs
string $contribs
Set to "newbie" to list contributions from the most recent 1% registered users.
Definition: ContribsPager.php:47
ContribsPager\isQueryableRange
isQueryableRange( $ipRange)
Is the given IP a range and within the CIDR limit?
Definition: ContribsPager.php:414
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:67
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2162
ContribsPager\getNavigationBar
getNavigationBar()
Wrap the navigation bar in a p element with identifying class.
Definition: ContribsPager.php:164
ContribsPager\$preventClickjacking
$preventClickjacking
Definition: ContribsPager.php:90
Revision\getParentLengths
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition: Revision.php:538
IP\parseRange
static parseRange( $range)
Given a string range in a number of formats, return the start and end of the range in hexadecimal.
Definition: IP.php:513
Linker\getRevDeleteLink
static getRevDeleteLink(User $user, Revision $rev, Title $title)
Get a revision-deletion link, or disabled link, or nothing, depending on user permissions & the setti...
Definition: Linker.php:2049
ContribsPager\getExtraSortFields
getExtraSortFields()
Definition: ContribsPager.php:475
ContribsPager\$templateParser
TemplateParser $templateParser
Definition: ContribsPager.php:103
ChangesList\revDateLink
static revDateLink(Revision $rev, User $user, Language $lang, $title=null)
Render the date and time of a revision in the current user language based on whether the user is able...
Definition: ChangesList.php:409
Linker\formatRevisionSize
static formatRevisionSize( $size)
Definition: Linker.php:1535
ChangesList\showCharacterDifference
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
Definition: ChangesList.php:317
ContribsPager\$tagFilter
string false $tagFilter
Name of tag to filter, or false to ignore tags.
Definition: ContribsPager.php:57
$ret
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 & $ret
Definition: hooks.txt:1985
RangeChronologicalPager\buildQueryInfo
buildQueryInfo( $offset, $limit, $order)
Build variables to use by the database wrapper.
Definition: RangeChronologicalPager.php:100
IP\isIPv4
static isIPv4( $ip)
Given a string, determine if it as valid IP in IPv4 only.
Definition: IP.php:99
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
IP\parseCIDR
static parseCIDR( $range)
Convert a network specification in CIDR notation to an integer network and a number of bits.
Definition: IP.php:470
ContribsPager\getContribs
getContribs()
Definition: ContribsPager.php:447
ContribsPager\$newOnly
bool $newOnly
Set to true to show only new pages.
Definition: ContribsPager.php:83
ContribsPager\$hideMinor
bool $hideMinor
Set to true to hide edits marked as minor by the user.
Definition: ContribsPager.php:88
ContribsPager\$associated
bool $associated
Set to true to show both the subject and talk namespace, no matter which got selected.
Definition: ContribsPager.php:68
$options
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 & $options
Definition: hooks.txt:1985
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1769
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
messages
passed in as a query string parameter to the various URLs constructed here(i.e. $prevlink) $ldel you ll need to handle error messages
Definition: hooks.txt:1290
NS_USER
const NS_USER
Definition: Defines.php:66
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3053
$batch
$batch
Definition: linkcache.txt:23
ContribsPager\getIpRangeConds
getIpRangeConds( $db, $ip)
Get SQL conditions for an IP range, if applicable.
Definition: ContribsPager.php:396
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
ContribsPager\getEndBody
getEndBody()
Definition: ContribsPager.php:523
ContribsPager\getQueryInfo
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
Definition: ContribsPager.php:238
ContribsPager\$messages
string[] $messages
Local cache for escaped messages.
Definition: ContribsPager.php:36
MediaWikiServices
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 MediaWikiServices
Definition: injection.txt:23
ContribsPager\$nsInvert
bool $nsInvert
Set to true to invert the namespace selection.
Definition: ContribsPager.php:62
ContribsPager\$namespace
string int $namespace
A single namespace number, or an empty string for all namespaces.
Definition: ContribsPager.php:52
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
ContribsPager\preventClickjacking
preventClickjacking()
Definition: ContribsPager.php:760
MWNamespace\getAssociated
static getAssociated( $index)
Get the associated namespace.
Definition: MWNamespace.php:163
ContribsPager\getIndexField
getIndexField()
Definition: ContribsPager.php:432
ChangeTags\formatSummaryRow
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
Definition: ChangeTags.php:93
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:46
ContribsPager\$mParentLens
array $mParentLens
Definition: ContribsPager.php:98
User\getGroupsWithPermission
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
Definition: User.php:5042
ContribsPager\getTagFilter
getTagFilter()
Definition: ContribsPager.php:440