MediaWiki  1.29.2
ContribsPager.php
Go to the documentation of this file.
1 <?php
30 
32 
34  public $messages;
35  public $target;
36  public $namespace = '';
37  public $mDb;
38  public $preventClickjacking = false;
39 
41  public $mDbSecondary;
42 
46  protected $mParentLens;
47 
51  protected $templateParser;
52 
54  parent::__construct( $context );
55 
56  $msgs = [
57  'diff',
58  'hist',
59  'pipe-separator',
60  'uctop'
61  ];
62 
63  foreach ( $msgs as $msg ) {
64  $this->messages[$msg] = $this->msg( $msg )->escaped();
65  }
66 
67  $this->target = isset( $options['target'] ) ? $options['target'] : '';
68  $this->contribs = isset( $options['contribs'] ) ? $options['contribs'] : 'users';
69  $this->namespace = isset( $options['namespace'] ) ? $options['namespace'] : '';
70  $this->tagFilter = isset( $options['tagfilter'] ) ? $options['tagfilter'] : false;
71  $this->nsInvert = isset( $options['nsInvert'] ) ? $options['nsInvert'] : false;
72  $this->associated = isset( $options['associated'] ) ? $options['associated'] : false;
73 
74  $this->deletedOnly = !empty( $options['deletedOnly'] );
75  $this->topOnly = !empty( $options['topOnly'] );
76  $this->newOnly = !empty( $options['newOnly'] );
77  $this->hideMinor = !empty( $options['hideMinor'] );
78 
79  $year = isset( $options['year'] ) ? $options['year'] : false;
80  $month = isset( $options['month'] ) ? $options['month'] : false;
81  $this->getDateCond( $year, $month );
82 
83  // Most of this code will use the 'contributions' group DB, which can map to replica DBs
84  // with extra user based indexes or partioning by user. The additional metadata
85  // queries should use a regular replica DB since the lookup pattern is not all by user.
86  $this->mDbSecondary = wfGetDB( DB_REPLICA ); // any random replica DB
87  $this->mDb = wfGetDB( DB_REPLICA, 'contributions' );
88  $this->templateParser = new TemplateParser();
89  }
90 
92  $query = parent::getDefaultQuery();
93  $query['target'] = $this->target;
94 
95  return $query;
96  }
97 
107  function reallyDoQuery( $offset, $limit, $descending ) {
108  list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo(
109  $offset,
110  $limit,
111  $descending
112  );
113 
114  /*
115  * This hook will allow extensions to add in additional queries, so they can get their data
116  * in My Contributions as well. Extensions should append their results to the $data array.
117  *
118  * Extension queries have to implement the navbar requirement as well. They should
119  * - have a column aliased as $pager->getIndexField()
120  * - have LIMIT set
121  * - have a WHERE-clause that compares the $pager->getIndexField()-equivalent column to the offset
122  * - have the ORDER BY specified based upon the details provided by the navbar
123  *
124  * See includes/Pager.php buildQueryInfo() method on how to build LIMIT, WHERE & ORDER BY
125  *
126  * &$data: an array of results of all contribs queries
127  * $pager: the ContribsPager object hooked into
128  * $offset: see phpdoc above
129  * $limit: see phpdoc above
130  * $descending: see phpdoc above
131  */
132  $data = [ $this->mDb->select(
133  $tables, $fields, $conds, $fname, $options, $join_conds
134  ) ];
135  Hooks::run(
136  'ContribsPager::reallyDoQuery',
137  [ &$data, $this, $offset, $limit, $descending ]
138  );
139 
140  $result = [];
141 
142  // loop all results and collect them in an array
143  foreach ( $data as $query ) {
144  foreach ( $query as $i => $row ) {
145  // use index column as key, allowing us to easily sort in PHP
146  $result[$row->{$this->getIndexField()} . "-$i"] = $row;
147  }
148  }
149 
150  // sort results
151  if ( $descending ) {
152  ksort( $result );
153  } else {
154  krsort( $result );
155  }
156 
157  // enforce limit
158  $result = array_slice( $result, 0, $limit );
159 
160  // get rid of array keys
161  $result = array_values( $result );
162 
163  return new FakeResultWrapper( $result );
164  }
165 
166  function getQueryInfo() {
167  list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
168 
169  $user = $this->getUser();
170  $conds = array_merge( $userCond, $this->getNamespaceCond() );
171 
172  // Paranoia: avoid brute force searches (T19342)
173  if ( !$user->isAllowed( 'deletedhistory' ) ) {
174  $conds[] = $this->mDb->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0';
175  } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
176  $conds[] = $this->mDb->bitAnd( 'rev_deleted', Revision::SUPPRESSED_USER ) .
177  ' != ' . Revision::SUPPRESSED_USER;
178  }
179 
180  # Don't include orphaned revisions
181  $join_cond['page'] = Revision::pageJoinCond();
182  # Get the current user name for accounts
183  $join_cond['user'] = Revision::userJoinCond();
184 
185  $options = [];
186  if ( $index ) {
187  $options['USE INDEX'] = [ 'revision' => $index ];
188  }
189 
190  $queryInfo = [
191  'tables' => $tables,
192  'fields' => array_merge(
195  [ 'page_namespace', 'page_title', 'page_is_new',
196  'page_latest', 'page_is_redirect', 'page_len' ]
197  ),
198  'conds' => $conds,
199  'options' => $options,
200  'join_conds' => $join_cond
201  ];
202 
204  $queryInfo['tables'],
205  $queryInfo['fields'],
206  $queryInfo['conds'],
207  $queryInfo['join_conds'],
208  $queryInfo['options'],
209  $this->tagFilter
210  );
211 
212  // Avoid PHP 7.1 warning from passing $this by reference
213  $pager = $this;
214  Hooks::run( 'ContribsPager::getQueryInfo', [ &$pager, &$queryInfo ] );
215 
216  return $queryInfo;
217  }
218 
219  function getUserCond() {
220  $condition = [];
221  $join_conds = [];
222  $tables = [ 'revision', 'page', 'user' ];
223  $index = false;
224  if ( $this->contribs == 'newbie' ) {
225  $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
226  $condition[] = 'rev_user >' . (int)( $max - $max / 100 );
227  # ignore local groups with the bot right
228  # @todo FIXME: Global groups may have 'bot' rights
229  $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' );
230  if ( count( $groupsWithBotPermission ) ) {
231  $tables[] = 'user_groups';
232  $condition[] = 'ug_group IS NULL';
233  $join_conds['user_groups'] = [
234  'LEFT JOIN', [
235  'ug_user = rev_user',
236  'ug_group' => $groupsWithBotPermission,
237  'ug_expiry IS NULL OR ug_expiry >= ' .
238  $this->mDb->addQuotes( $this->mDb->timestamp() )
239  ]
240  ];
241  }
242  // (T140537) Disallow looking too far in the past for 'newbies' queries. If the user requested
243  // a timestamp offset far in the past such that there are no edits by users with user_ids in
244  // the range, we would end up scanning all revisions from that offset until start of time.
245  $condition[] = 'rev_timestamp > ' .
246  $this->mDb->addQuotes( $this->mDb->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) );
247  } else {
248  $uid = User::idFromName( $this->target );
249  if ( $uid ) {
250  $condition['rev_user'] = $uid;
251  $index = 'user_timestamp';
252  } else {
253  $condition['rev_user_text'] = $this->target;
254  $index = 'usertext_timestamp';
255  }
256  }
257 
258  if ( $this->deletedOnly ) {
259  $condition[] = 'rev_deleted != 0';
260  }
261 
262  if ( $this->topOnly ) {
263  $condition[] = 'rev_id = page_latest';
264  }
265 
266  if ( $this->newOnly ) {
267  $condition[] = 'rev_parent_id = 0';
268  }
269 
270  if ( $this->hideMinor ) {
271  $condition[] = 'rev_minor_edit = 0';
272  }
273 
274  return [ $tables, $index, $condition, $join_conds ];
275  }
276 
277  function getNamespaceCond() {
278  if ( $this->namespace !== '' ) {
279  $selectedNS = $this->mDb->addQuotes( $this->namespace );
280  $eq_op = $this->nsInvert ? '!=' : '=';
281  $bool_op = $this->nsInvert ? 'AND' : 'OR';
282 
283  if ( !$this->associated ) {
284  return [ "page_namespace $eq_op $selectedNS" ];
285  }
286 
287  $associatedNS = $this->mDb->addQuotes(
288  MWNamespace::getAssociated( $this->namespace )
289  );
290 
291  return [
292  "page_namespace $eq_op $selectedNS " .
293  $bool_op .
294  " page_namespace $eq_op $associatedNS"
295  ];
296  }
297 
298  return [];
299  }
300 
301  function getIndexField() {
302  return 'rev_timestamp';
303  }
304 
305  function doBatchLookups() {
306  # Do a link batch query
307  $this->mResult->seek( 0 );
308  $parentRevIds = [];
309  $this->mParentLens = [];
310  $batch = new LinkBatch();
311  # Give some pointers to make (last) links
312  foreach ( $this->mResult as $row ) {
313  if ( isset( $row->rev_parent_id ) && $row->rev_parent_id ) {
314  $parentRevIds[] = $row->rev_parent_id;
315  }
316  if ( isset( $row->rev_id ) ) {
317  $this->mParentLens[$row->rev_id] = $row->rev_len;
318  if ( $this->contribs === 'newbie' ) { // multiple users
319  $batch->add( NS_USER, $row->user_name );
320  $batch->add( NS_USER_TALK, $row->user_name );
321  }
322  $batch->add( $row->page_namespace, $row->page_title );
323  }
324  }
325  # Fetch rev_len for revisions not already scanned above
326  $this->mParentLens += Revision::getParentLengths(
327  $this->mDbSecondary,
328  array_diff( $parentRevIds, array_keys( $this->mParentLens ) )
329  );
330  $batch->execute();
331  $this->mResult->seek( 0 );
332  }
333 
337  function getStartBody() {
338  return "<ul class=\"mw-contributions-list\">\n";
339  }
340 
344  function getEndBody() {
345  return "</ul>\n";
346  }
347 
360  function formatRow( $row ) {
361 
362  $ret = '';
363  $classes = [];
364 
365  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
366 
367  /*
368  * There may be more than just revision rows. To make sure that we'll only be processing
369  * revisions here, let's _try_ to build a revision out of our row (without displaying
370  * notices though) and then trying to grab data from the built object. If we succeed,
371  * we're definitely dealing with revision data and we may proceed, if not, we'll leave it
372  * to extensions to subscribe to the hook to parse the row.
373  */
374  MediaWiki\suppressWarnings();
375  try {
376  $rev = new Revision( $row );
377  $validRevision = (bool)$rev->getId();
378  } catch ( Exception $e ) {
379  $validRevision = false;
380  }
381  MediaWiki\restoreWarnings();
382 
383  if ( $validRevision ) {
384  $classes = [];
385 
386  $page = Title::newFromRow( $row );
387  $link = $linkRenderer->makeLink(
388  $page,
389  $page->getPrefixedText(),
390  [ 'class' => 'mw-contributions-title' ],
391  $page->isRedirect() ? [ 'redirect' => 'no' ] : []
392  );
393  # Mark current revisions
394  $topmarktext = '';
395  $user = $this->getUser();
396  if ( $row->rev_id === $row->page_latest ) {
397  $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
398  $classes[] = 'mw-contributions-current';
399  # Add rollback link
400  if ( !$row->page_is_new && $page->quickUserCan( 'rollback', $user )
401  && $page->quickUserCan( 'edit', $user )
402  ) {
403  $this->preventClickjacking();
404  $topmarktext .= ' ' . Linker::generateRollback( $rev, $this->getContext() );
405  }
406  }
407  # Is there a visible previous revision?
408  if ( $rev->userCan( Revision::DELETED_TEXT, $user ) && $rev->getParentId() !== 0 ) {
409  $difftext = $linkRenderer->makeKnownLink(
410  $page,
411  new HtmlArmor( $this->messages['diff'] ),
412  [ 'class' => 'mw-changeslist-diff' ],
413  [
414  'diff' => 'prev',
415  'oldid' => $row->rev_id
416  ]
417  );
418  } else {
419  $difftext = $this->messages['diff'];
420  }
421  $histlink = $linkRenderer->makeKnownLink(
422  $page,
423  new HtmlArmor( $this->messages['hist'] ),
424  [ 'class' => 'mw-changeslist-history' ],
425  [ 'action' => 'history' ]
426  );
427 
428  if ( $row->rev_parent_id === null ) {
429  // For some reason rev_parent_id isn't populated for this row.
430  // Its rumoured this is true on wikipedia for some revisions (T36922).
431  // Next best thing is to have the total number of bytes.
432  $chardiff = ' <span class="mw-changeslist-separator">. .</span> ';
433  $chardiff .= Linker::formatRevisionSize( $row->rev_len );
434  $chardiff .= ' <span class="mw-changeslist-separator">. .</span> ';
435  } else {
436  $parentLen = 0;
437  if ( isset( $this->mParentLens[$row->rev_parent_id] ) ) {
438  $parentLen = $this->mParentLens[$row->rev_parent_id];
439  }
440 
441  $chardiff = ' <span class="mw-changeslist-separator">. .</span> ';
443  $parentLen,
444  $row->rev_len,
445  $this->getContext()
446  );
447  $chardiff .= ' <span class="mw-changeslist-separator">. .</span> ';
448  }
449 
450  $lang = $this->getLanguage();
451  $comment = $lang->getDirMark() . Linker::revComment( $rev, false, true );
452  $date = $lang->userTimeAndDate( $row->rev_timestamp, $user );
453  if ( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
454  $d = $linkRenderer->makeKnownLink(
455  $page,
456  $date,
457  [ 'class' => 'mw-changeslist-date' ],
458  [ 'oldid' => intval( $row->rev_id ) ]
459  );
460  } else {
461  $d = htmlspecialchars( $date );
462  }
463  if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
464  $d = '<span class="history-deleted">' . $d . '</span>';
465  }
466 
467  # Show user names for /newbies as there may be different users.
468  # Note that we already excluded rows with hidden user names.
469  if ( $this->contribs == 'newbie' ) {
470  $userlink = ' . . ' . $lang->getDirMark()
471  . Linker::userLink( $rev->getUser(), $rev->getUserText() );
472  $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
473  Linker::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
474  } else {
475  $userlink = '';
476  }
477 
478  $flags = [];
479  if ( $rev->getParentId() === 0 ) {
480  $flags[] = ChangesList::flag( 'newpage' );
481  }
482 
483  if ( $rev->isMinor() ) {
484  $flags[] = ChangesList::flag( 'minor' );
485  }
486 
488  if ( $del !== '' ) {
489  $del .= ' ';
490  }
491 
492  $diffHistLinks = $this->msg( 'parentheses' )
493  ->rawParams( $difftext . $this->messages['pipe-separator'] . $histlink )
494  ->escaped();
495 
496  # Tags, if any.
497  list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow(
498  $row->ts_tags,
499  'contributions',
500  $this->getContext()
501  );
502  $classes = array_merge( $classes, $newClasses );
503 
504  Hooks::run( 'SpecialContributions::formatRow::flags', [ $this->getContext(), $row, &$flags ] );
505 
506  $templateParams = [
507  'del' => $del,
508  'timestamp' => $d,
509  'diffHistLinks' => $diffHistLinks,
510  'charDifference' => $chardiff,
511  'flags' => $flags,
512  'articleLink' => $link,
513  'userlink' => $userlink,
514  'logText' => $comment,
515  'topmarktext' => $topmarktext,
516  'tagSummary' => $tagSummary,
517  ];
518 
519  # Denote if username is redacted for this edit
520  if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
521  $templateParams['rev-deleted-user-contribs'] =
522  $this->msg( 'rev-deleted-user-contribs' )->escaped();
523  }
524 
525  $ret = $this->templateParser->processTemplate(
526  'SpecialContributionsLine',
527  $templateParams
528  );
529  }
530 
531  // Let extensions add data
532  Hooks::run( 'ContributionsLineEnding', [ $this, &$ret, $row, &$classes ] );
533 
534  // TODO: Handle exceptions in the catch block above. Do any extensions rely on
535  // receiving empty rows?
536 
537  if ( $classes === [] && $ret === '' ) {
538  wfDebug( "Dropping Special:Contribution row that could not be formatted\n" );
539  return "<!-- Could not format Special:Contribution row. -->\n";
540  }
541 
542  // FIXME: The signature of the ContributionsLineEnding hook makes it
543  // very awkward to move this LI wrapper into the template.
544  return Html::rawElement( 'li', [ 'class' => $classes ], $ret ) . "\n";
545  }
546 
551  function getSqlComment() {
552  if ( $this->namespace || $this->deletedOnly ) {
553  // potentially slow, see CR r58153
554  return 'contributions page filtered for namespace or RevisionDeleted edits';
555  } else {
556  return 'contributions page unfiltered';
557  }
558  }
559 
560  protected function preventClickjacking() {
561  $this->preventClickjacking = true;
562  }
563 
567  public function getPreventClickjacking() {
569  }
570 }
function
when a variable name is used in a function
Definition: design.txt:93
Revision\DELETED_USER
const DELETED_USER
Definition: Revision.php:92
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:34
ReverseChronologicalPager\getDateCond
getDateCond( $year, $month, $day=-1)
Set and return the mOffset timestamp such that we can get all revisions with a timestamp up to the sp...
Definition: ReverseChronologicalPager.php:73
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:41
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:28
Linker\userTalkLink
static userTalkLink( $userId, $userText)
Definition: Linker.php:988
ContribsPager\$namespace
$namespace
Definition: ContribsPager.php:36
IndexPager\buildQueryInfo
buildQueryInfo( $offset, $limit, $descending)
Build variables to use by the database wrapper.
Definition: IndexPager.php:379
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
$tables
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:990
Revision\pageJoinCond
static pageJoinCond()
Return the value of a select() page conds array for the page table.
Definition: Revision.php:439
ContextSource\msg
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:187
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
ContribsPager\$messages
$messages
Definition: ContribsPager.php:34
Linker\userLink
static userLink( $userId, $userName, $altUserName=false)
Make user link (or user contributions for unregistered users)
Definition: Linker.php:888
ContribsPager\getUserCond
getUserCond()
Definition: ContribsPager.php:219
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
ContribsPager\reallyDoQuery
reallyDoQuery( $offset, $limit, $descending)
This method basically executes the exact same code as the parent class, though with a hook added,...
Definition: ContribsPager.php:107
captcha-old.count
count
Definition: captcha-old.py:225
ContribsPager\__construct
__construct(IContextSource $context, array $options)
Definition: ContribsPager.php:53
$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 '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. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) '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 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) '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! 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:1954
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1994
ContribsPager\getDefaultQuery
getDefaultQuery()
Get an array of query parameters that should be put into self-links.
Definition: ContribsPager.php:91
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
$fname
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition: Setup.php:36
ContribsPager\getSqlComment
getSqlComment()
Overwrite Pager function and return a helpful comment.
Definition: ContribsPager.php:551
ContribsPager\formatRow
formatRow( $row)
Generates each row in the contributions list.
Definition: ContribsPager.php:360
$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:1956
ContribsPager\$mDbSecondary
IDatabase $mDbSecondary
Definition: ContribsPager.php:41
Wikimedia\Rdbms\ResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: ResultWrapper.php:24
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
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\doBatchLookups
doBatchLookups()
Called from getBody(), before getStartBody() is called and after doQuery() was called.
Definition: ContribsPager.php:305
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
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:40
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:143
Revision
Definition: Revision.php:33
ContribsPager\getPreventClickjacking
getPreventClickjacking()
Definition: ContribsPager.php:567
$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:1572
Revision\SUPPRESSED_USER
const SUPPRESSED_USER
Definition: Revision.php:94
ContribsPager\getNamespaceCond
getNamespaceCond()
Definition: ContribsPager.php:277
ChangeTags\modifyDisplayQuery
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag=false)
Applies all tags-related changes to a query.
Definition: ChangeTags.php:632
Linker\generateRollback
static generateRollback( $rev, IContextSource $context=null, $options=[ 'verify'])
Generate a rollback link for a given revision.
Definition: Linker.php:1677
ContribsPager\getStartBody
getStartBody()
Definition: ContribsPager.php:337
Title\newFromRow
static newFromRow( $row)
Make a Title object from a DB row.
Definition: Title.php:453
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3060
$page
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 $page
Definition: hooks.txt:2536
ContribsPager\$mDefaultDirection
$mDefaultDirection
Definition: ContribsPager.php:33
$limit
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context 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 please use GetContentModels hook to make them known to core 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 $limit
Definition: hooks.txt:1049
ContribsPager\$target
$target
Definition: ContribsPager.php:35
ChangesList\flag
static flag( $flag, IContextSource $context=null)
Make an "<abbr>" element for a given change flag.
Definition: ChangesList.php:221
ContribsPager\getQueryInfo
getQueryInfo()
This function should be overridden to provide all parameters needed for the main paged query.
Definition: ContribsPager.php:166
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:999
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
ContribsPager
Definition: ContribsPager.php:31
Linker\revComment
static revComment(Revision $rev, $local=false, $isPublic=false)
Wrap and format the given revision's comment block, if the current user is allowed to view it.
Definition: Linker.php:1464
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:65
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2122
ContribsPager\$preventClickjacking
$preventClickjacking
Definition: ContribsPager.php:38
Revision\getParentLengths
static getParentLengths( $db, array $revIds)
Do a batched query to get the parent revision lengths.
Definition: Revision.php:546
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:2017
ContribsPager\$templateParser
TemplateParser $templateParser
Definition: ContribsPager.php:51
Linker\formatRevisionSize
static formatRevisionSize( $size)
Definition: Linker.php:1487
ChangesList\showCharacterDifference
static showCharacterDifference( $old, $new, IContextSource $context=null)
Show formatted char difference.
Definition: ChangesList.php:282
$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:1956
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:55
IndexPager\DIR_DESCENDING
const DIR_DESCENDING
Definition: IndexPager.php:76
User\idFromName
static idFromName( $name, $flags=self::READ_NORMAL)
Get database id given a user name.
Definition: User.php:759
$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:1741
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
Revision\userJoinCond
static userJoinCond()
Return the value of a select() JOIN conds array for the user table.
Definition: Revision.php:429
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
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:1252
NS_USER
const NS_USER
Definition: Defines.php:64
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
$batch
$batch
Definition: linkcache.txt:23
ReverseChronologicalPager
IndexPager with a formatted navigation bar.
Definition: ReverseChronologicalPager.php:29
Revision\selectUserFields
static selectUserFields()
Return the list of user fields that should be selected from user table.
Definition: Revision.php:536
ContribsPager\$mDb
$mDb
Definition: ContribsPager.php:37
ContribsPager\getEndBody
getEndBody()
Definition: ContribsPager.php:344
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
Revision\selectFields
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition: Revision.php:448
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
ContribsPager\preventClickjacking
preventClickjacking()
Definition: ContribsPager.php:560
MWNamespace\getAssociated
static getAssociated( $index)
Get the associated namespace.
Definition: MWNamespace.php:140
ContribsPager\getIndexField
getIndexField()
This function should be overridden to return the name of the index fi- eld.
Definition: ContribsPager.php:301
$options
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
ChangeTags\formatSummaryRow
static formatSummaryRow( $tags, $page, IContextSource $context=null)
Creates HTML for the given tags.
Definition: ChangeTags.php:52
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:90
$flags
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2749
ContribsPager\$mParentLens
array $mParentLens
Definition: ContribsPager.php:46
array
the array() calling protocol came about after MediaWiki 1.4rc1.
User\getGroupsWithPermission
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
Definition: User.php:4743