MediaWiki  1.28.1
SpecialRecentchanges.php
Go to the documentation of this file.
1 <?php
25 
32  // @codingStandardsIgnoreStart Needed "useless" override to change parameters.
33  public function __construct( $name = 'Recentchanges', $restriction = '' ) {
34  parent::__construct( $name, $restriction );
35  }
36  // @codingStandardsIgnoreEnd
37 
43  public function execute( $subpage ) {
44  // Backwards-compatibility: redirect to new feed URLs
45  $feedFormat = $this->getRequest()->getVal( 'feed' );
46  if ( !$this->including() && $feedFormat ) {
47  $query = $this->getFeedQuery();
48  $query['feedformat'] = $feedFormat === 'atom' ? 'atom' : 'rss';
49  $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
50 
51  return;
52  }
53 
54  // 10 seconds server-side caching max
55  $this->getOutput()->setCdnMaxage( 10 );
56  // Check if the client has a cached version
57  $lastmod = $this->checkLastModified();
58  if ( $lastmod === false ) {
59  return;
60  }
61 
62  $this->addHelpLink(
63  '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
64  true
65  );
66  parent::execute( $subpage );
67  }
68 
74  public function getDefaultOptions() {
75  $opts = parent::getDefaultOptions();
76  $user = $this->getUser();
77 
78  $opts->add( 'days', $user->getIntOption( 'rcdays' ) );
79  $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
80  $opts->add( 'from', '' );
81 
82  $opts->add( 'hideminor', $user->getBoolOption( 'hideminor' ) );
83  $opts->add( 'hidebots', true );
84  $opts->add( 'hideanons', false );
85  $opts->add( 'hideliu', false );
86  $opts->add( 'hidepatrolled', $user->getBoolOption( 'hidepatrolled' ) );
87  $opts->add( 'hidemyself', false );
88  $opts->add( 'hidecategorization', $user->getBoolOption( 'hidecategorization' ) );
89 
90  $opts->add( 'categories', '' );
91  $opts->add( 'categories_any', false );
92  $opts->add( 'tagfilter', '' );
93 
94  return $opts;
95  }
96 
102  protected function getCustomFilters() {
103  if ( $this->customFilters === null ) {
104  $this->customFilters = parent::getCustomFilters();
105  Hooks::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters ], '1.23' );
106  }
107 
108  return $this->customFilters;
109  }
110 
117  public function parseParameters( $par, FormOptions $opts ) {
118  $bits = preg_split( '/\s*,\s*/', trim( $par ) );
119  foreach ( $bits as $bit ) {
120  if ( 'hidebots' === $bit ) {
121  $opts['hidebots'] = true;
122  }
123  if ( 'bots' === $bit ) {
124  $opts['hidebots'] = false;
125  }
126  if ( 'hideminor' === $bit ) {
127  $opts['hideminor'] = true;
128  }
129  if ( 'minor' === $bit ) {
130  $opts['hideminor'] = false;
131  }
132  if ( 'hideliu' === $bit ) {
133  $opts['hideliu'] = true;
134  }
135  if ( 'hidepatrolled' === $bit ) {
136  $opts['hidepatrolled'] = true;
137  }
138  if ( 'hideanons' === $bit ) {
139  $opts['hideanons'] = true;
140  }
141  if ( 'hidemyself' === $bit ) {
142  $opts['hidemyself'] = true;
143  }
144  if ( 'hidecategorization' === $bit ) {
145  $opts['hidecategorization'] = true;
146  }
147 
148  if ( is_numeric( $bit ) ) {
149  $opts['limit'] = $bit;
150  }
151 
152  $m = [];
153  if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
154  $opts['limit'] = $m[1];
155  }
156  if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
157  $opts['days'] = $m[1];
158  }
159  if ( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
160  $opts['namespace'] = $m[1];
161  }
162  if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
163  $opts['tagfilter'] = $m[1];
164  }
165  }
166  }
167 
168  public function validateOptions( FormOptions $opts ) {
169  $opts->validateIntBounds( 'limit', 0, 5000 );
170  parent::validateOptions( $opts );
171  }
172 
179  public function buildMainQueryConds( FormOptions $opts ) {
180  $dbr = $this->getDB();
181  $conds = parent::buildMainQueryConds( $opts );
182 
183  // Calculate cutoff
184  $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
185  $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime % 86400 );
186  $cutoff = $dbr->timestamp( $cutoff_unixtime );
187 
188  $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
189  if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
190  $cutoff = $dbr->timestamp( $opts['from'] );
191  } else {
192  $opts->reset( 'from' );
193  }
194 
195  $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
196 
197  return $conds;
198  }
199 
207  public function doMainQuery( $conds, $opts ) {
208  $dbr = $this->getDB();
209  $user = $this->getUser();
210 
211  $tables = [ 'recentchanges' ];
212  $fields = RecentChange::selectFields();
213  $query_options = [];
214  $join_conds = [];
215 
216  // JOIN on watchlist for users
217  if ( $user->getId() && $user->isAllowed( 'viewmywatchlist' ) ) {
218  $tables[] = 'watchlist';
219  $fields[] = 'wl_user';
220  $fields[] = 'wl_notificationtimestamp';
221  $join_conds['watchlist'] = [ 'LEFT JOIN', [
222  'wl_user' => $user->getId(),
223  'wl_title=rc_title',
224  'wl_namespace=rc_namespace'
225  ] ];
226  }
227 
228  if ( $user->isAllowed( 'rollback' ) ) {
229  $tables[] = 'page';
230  $fields[] = 'page_latest';
231  $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
232  }
233 
235  $tables,
236  $fields,
237  $conds,
238  $join_conds,
239  $query_options,
240  $opts['tagfilter']
241  );
242 
243  if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
244  $opts )
245  ) {
246  return false;
247  }
248 
249  // array_merge() is used intentionally here so that hooks can, should
250  // they so desire, override the ORDER BY / LIMIT condition(s); prior to
251  // MediaWiki 1.26 this used to use the plus operator instead, which meant
252  // that extensions weren't able to change these conditions
253  $query_options = array_merge( [
254  'ORDER BY' => 'rc_timestamp DESC',
255  'LIMIT' => $opts['limit'] ], $query_options );
256  $rows = $dbr->select(
257  $tables,
258  $fields,
259  // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
260  // knowledge to use an index merge if it wants (it may use some other index though).
261  $conds + [ 'rc_new' => [ 0, 1 ] ],
262  __METHOD__,
263  $query_options,
264  $join_conds
265  );
266 
267  // Build the final data
268  if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
269  $this->filterByCategories( $rows, $opts );
270  }
271 
272  return $rows;
273  }
274 
275  protected function runMainQueryHook( &$tables, &$fields, &$conds,
276  &$query_options, &$join_conds, $opts
277  ) {
278  return parent::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
279  && Hooks::run(
280  'SpecialRecentChangesQuery',
281  [ &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ],
282  '1.23'
283  );
284  }
285 
286  protected function getDB() {
287  return wfGetDB( DB_REPLICA, 'recentchanges' );
288  }
289 
290  public function outputFeedLinks() {
291  $this->addFeedLinks( $this->getFeedQuery() );
292  }
293 
299  protected function getFeedQuery() {
300  $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
301  // API handles empty parameters in a different way
302  return $value !== '';
303  } );
304  $query['action'] = 'feedrecentchanges';
305  $feedLimit = $this->getConfig()->get( 'FeedLimit' );
306  if ( $query['limit'] > $feedLimit ) {
307  $query['limit'] = $feedLimit;
308  }
309 
310  return $query;
311  }
312 
319  public function outputChangesList( $rows, $opts ) {
320  $limit = $opts['limit'];
321 
322  $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
323  && $this->getUser()->getOption( 'shownumberswatching' );
324  $watcherCache = [];
325 
326  $dbr = $this->getDB();
327 
328  $counter = 1;
329  $list = ChangesList::newFromContext( $this->getContext() );
330  $list->initChangesListRows( $rows );
331 
332  $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
333  $rclistOutput = $list->beginRecentChangesList();
334  foreach ( $rows as $obj ) {
335  if ( $limit == 0 ) {
336  break;
337  }
338  $rc = RecentChange::newFromRow( $obj );
339 
340  # Skip CatWatch entries for hidden cats based on user preference
341  if (
342  $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE &&
343  !$userShowHiddenCats &&
344  $rc->getParam( 'hidden-cat' )
345  ) {
346  continue;
347  }
348 
349  $rc->counter = $counter++;
350  # Check if the page has been updated since the last visit
351  if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
352  && !empty( $obj->wl_notificationtimestamp )
353  ) {
354  $rc->notificationtimestamp = ( $obj->rc_timestamp >= $obj->wl_notificationtimestamp );
355  } else {
356  $rc->notificationtimestamp = false; // Default
357  }
358  # Check the number of users watching the page
359  $rc->numberofWatchingusers = 0; // Default
360  if ( $showWatcherCount && $obj->rc_namespace >= 0 ) {
361  if ( !isset( $watcherCache[$obj->rc_namespace][$obj->rc_title] ) ) {
362  $watcherCache[$obj->rc_namespace][$obj->rc_title] =
363  MediaWikiServices::getInstance()->getWatchedItemStore()->countWatchers(
364  new TitleValue( (int)$obj->rc_namespace, $obj->rc_title )
365  );
366  }
367  $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
368  }
369 
370  $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user ), $counter );
371  if ( $changeLine !== false ) {
372  $rclistOutput .= $changeLine;
373  --$limit;
374  }
375  }
376  $rclistOutput .= $list->endRecentChangesList();
377 
378  if ( $rows->numRows() === 0 ) {
379  $this->getOutput()->addHTML(
380  '<div class="mw-changeslist-empty">' .
381  $this->msg( 'recentchanges-noresult' )->parse() .
382  '</div>'
383  );
384  if ( !$this->including() ) {
385  $this->getOutput()->setStatusCode( 404 );
386  }
387  } else {
388  $this->getOutput()->addHTML( $rclistOutput );
389  }
390  }
391 
398  public function doHeader( $opts, $numRows ) {
399  $this->setTopText( $opts );
400 
401  $defaults = $opts->getAllValues();
402  $nondefaults = $opts->getChangedValues();
403 
404  $panel = [];
405  $panel[] = $this->makeLegend();
406  $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
407  $panel[] = '<hr />';
408 
409  $extraOpts = $this->getExtraOptions( $opts );
410  $extraOptsCount = count( $extraOpts );
411  $count = 0;
412  $submit = ' ' . Xml::submitButton( $this->msg( 'recentchanges-submit' )->text() );
413 
414  $out = Xml::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
415  foreach ( $extraOpts as $name => $optionRow ) {
416  # Add submit button to the last row only
417  ++$count;
418  $addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
419 
420  $out .= Xml::openElement( 'tr' );
421  if ( is_array( $optionRow ) ) {
422  $out .= Xml::tags(
423  'td',
424  [ 'class' => 'mw-label mw-' . $name . '-label' ],
425  $optionRow[0]
426  );
427  $out .= Xml::tags(
428  'td',
429  [ 'class' => 'mw-input' ],
430  $optionRow[1] . $addSubmit
431  );
432  } else {
433  $out .= Xml::tags(
434  'td',
435  [ 'class' => 'mw-input', 'colspan' => 2 ],
436  $optionRow . $addSubmit
437  );
438  }
439  $out .= Xml::closeElement( 'tr' );
440  }
441  $out .= Xml::closeElement( 'table' );
442 
443  $unconsumed = $opts->getUnconsumedValues();
444  foreach ( $unconsumed as $key => $value ) {
445  $out .= Html::hidden( $key, $value );
446  }
447 
448  $t = $this->getPageTitle();
449  $out .= Html::hidden( 'title', $t->getPrefixedText() );
450  $form = Xml::tags( 'form', [ 'action' => wfScript() ], $out );
451  $panel[] = $form;
452  $panelString = implode( "\n", $panel );
453 
454  $this->getOutput()->addHTML(
456  $this->msg( 'recentchanges-legend' )->text(),
457  $panelString,
458  [ 'class' => 'rcoptions' ]
459  )
460  );
461 
462  $this->setBottomText( $opts );
463  }
464 
470  function setTopText( FormOptions $opts ) {
472 
473  $message = $this->msg( 'recentchangestext' )->inContentLanguage();
474  if ( !$message->isDisabled() ) {
475  $this->getOutput()->addWikiText(
476  Html::rawElement( 'div',
477  [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
478  "\n" . $message->plain() . "\n"
479  ),
480  /* $lineStart */ true,
481  /* $interface */ false
482  );
483  }
484  }
485 
492  function getExtraOptions( $opts ) {
493  $opts->consumeValues( [
494  'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
495  ] );
496 
497  $extraOpts = [];
498  $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
499 
500  if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
501  $extraOpts['category'] = $this->categoryFilterForm( $opts );
502  }
503 
504  $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] );
505  if ( count( $tagFilter ) ) {
506  $extraOpts['tagfilter'] = $tagFilter;
507  }
508 
509  // Don't fire the hook for subclasses. (Or should we?)
510  if ( $this->getName() === 'Recentchanges' ) {
511  Hooks::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
512  }
513 
514  return $extraOpts;
515  }
516 
520  protected function addModules() {
521  parent::addModules();
522  $out = $this->getOutput();
523  $out->addModules( 'mediawiki.special.recentchanges' );
524  }
525 
533  public function checkLastModified() {
534  $dbr = $this->getDB();
535  $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
536 
537  return $lastmod;
538  }
539 
546  protected function namespaceFilterForm( FormOptions $opts ) {
547  $nsSelect = Html::namespaceSelector(
548  [ 'selected' => $opts['namespace'], 'all' => '' ],
549  [ 'name' => 'namespace', 'id' => 'namespace' ]
550  );
551  $nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' );
552  $invert = Xml::checkLabel(
553  $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
554  $opts['invert'],
555  [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
556  );
557  $associated = Xml::checkLabel(
558  $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
559  $opts['associated'],
560  [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
561  );
562 
563  return [ $nsLabel, "$nsSelect $invert $associated" ];
564  }
565 
572  protected function categoryFilterForm( FormOptions $opts ) {
573  list( $label, $input ) = Xml::inputLabelSep( $this->msg( 'rc_categories' )->text(),
574  'categories', 'mw-categories', false, $opts['categories'] );
575 
576  $input .= ' ' . Xml::checkLabel( $this->msg( 'rc_categories_any' )->text(),
577  'categories_any', 'mw-categories_any', $opts['categories_any'] );
578 
579  return [ $label, $input ];
580  }
581 
588  function filterByCategories( &$rows, FormOptions $opts ) {
589  $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
590 
591  if ( !count( $categories ) ) {
592  return;
593  }
594 
595  # Filter categories
596  $cats = [];
597  foreach ( $categories as $cat ) {
598  $cat = trim( $cat );
599  if ( $cat == '' ) {
600  continue;
601  }
602  $cats[] = $cat;
603  }
604 
605  # Filter articles
606  $articles = [];
607  $a2r = [];
608  $rowsarr = [];
609  foreach ( $rows as $k => $r ) {
610  $nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
611  $id = $nt->getArticleID();
612  if ( $id == 0 ) {
613  continue; # Page might have been deleted...
614  }
615  if ( !in_array( $id, $articles ) ) {
616  $articles[] = $id;
617  }
618  if ( !isset( $a2r[$id] ) ) {
619  $a2r[$id] = [];
620  }
621  $a2r[$id][] = $k;
622  $rowsarr[$k] = $r;
623  }
624 
625  # Shortcut?
626  if ( !count( $articles ) || !count( $cats ) ) {
627  return;
628  }
629 
630  # Look up
631  $catFind = new CategoryFinder;
632  $catFind->seed( $articles, $cats, $opts['categories_any'] ? 'OR' : 'AND' );
633  $match = $catFind->run();
634 
635  # Filter
636  $newrows = [];
637  foreach ( $match as $id ) {
638  foreach ( $a2r[$id] as $rev ) {
639  $k = $rev;
640  $newrows[$k] = $rowsarr[$k];
641  }
642  }
643  $rows = $newrows;
644  }
645 
655  function makeOptionsLink( $title, $override, $options, $active = false ) {
656  $params = $override + $options;
657 
658  // Bug 36524: false values have be converted to "0" otherwise
659  // wfArrayToCgi() will omit it them.
660  foreach ( $params as &$value ) {
661  if ( $value === false ) {
662  $value = '0';
663  }
664  }
665  unset( $value );
666 
667  $text = htmlspecialchars( $title );
668  if ( $active ) {
669  $text = '<strong>' . $text . '</strong>';
670  }
671 
672  return Linker::linkKnown( $this->getPageTitle(), $text, [], $params );
673  }
674 
683  function optionsPanel( $defaults, $nondefaults, $numRows ) {
684  $options = $nondefaults + $defaults;
685 
686  $note = '';
687  $msg = $this->msg( 'rclegend' );
688  if ( !$msg->isDisabled() ) {
689  $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
690  }
691 
692  $lang = $this->getLanguage();
693  $user = $this->getUser();
694  $config = $this->getConfig();
695  if ( $options['from'] ) {
696  $note .= $this->msg( 'rcnotefrom' )
697  ->numParams( $options['limit'] )
698  ->params(
699  $lang->userTimeAndDate( $options['from'], $user ),
700  $lang->userDate( $options['from'], $user ),
701  $lang->userTime( $options['from'], $user )
702  )
703  ->numParams( $numRows )
704  ->parse() . '<br />';
705  }
706 
707  # Sort data for display and make sure it's unique after we've added user data.
708  $linkLimits = $config->get( 'RCLinkLimits' );
709  $linkLimits[] = $options['limit'];
710  sort( $linkLimits );
711  $linkLimits = array_unique( $linkLimits );
712 
713  $linkDays = $config->get( 'RCLinkDays' );
714  $linkDays[] = $options['days'];
715  sort( $linkDays );
716  $linkDays = array_unique( $linkDays );
717 
718  // limit links
719  $cl = [];
720  foreach ( $linkLimits as $value ) {
721  $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
722  [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
723  }
724  $cl = $lang->pipeList( $cl );
725 
726  // day links, reset 'from' to none
727  $dl = [];
728  foreach ( $linkDays as $value ) {
729  $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
730  [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
731  }
732  $dl = $lang->pipeList( $dl );
733 
734  // show/hide links
735  $filters = [
736  'hideminor' => 'rcshowhideminor',
737  'hidebots' => 'rcshowhidebots',
738  'hideanons' => 'rcshowhideanons',
739  'hideliu' => 'rcshowhideliu',
740  'hidepatrolled' => 'rcshowhidepatr',
741  'hidemyself' => 'rcshowhidemine'
742  ];
743 
744  if ( $config->get( 'RCWatchCategoryMembership' ) ) {
745  $filters['hidecategorization'] = 'rcshowhidecategorization';
746  }
747 
748  $showhide = [ 'show', 'hide' ];
749 
750  foreach ( $this->getCustomFilters() as $key => $params ) {
751  $filters[$key] = $params['msg'];
752  }
753  // Disable some if needed
754  if ( !$user->useRCPatrol() ) {
755  unset( $filters['hidepatrolled'] );
756  }
757 
758  $links = [];
759  foreach ( $filters as $key => $msg ) {
760  // The following messages are used here:
761  // rcshowhideminor-show, rcshowhideminor-hide, rcshowhidebots-show, rcshowhidebots-hide,
762  // rcshowhideanons-show, rcshowhideanons-hide, rcshowhideliu-show, rcshowhideliu-hide,
763  // rcshowhidepatr-show, rcshowhidepatr-hide, rcshowhidemine-show, rcshowhidemine-hide,
764  // rcshowhidecategorization-show, rcshowhidecategorization-hide.
765  $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
766  // Extensions can define additional filters, but don't need to define the corresponding
767  // messages. If they don't exist, just fall back to 'show' and 'hide'.
768  if ( !$linkMessage->exists() ) {
769  $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
770  }
771 
772  $link = $this->makeOptionsLink( $linkMessage->text(),
773  [ $key => 1 - $options[$key] ], $nondefaults );
774  $links[] = "<span class=\"$msg rcshowhideoption\">"
775  . $this->msg( $msg )->rawParams( $link )->escaped() . '</span>';
776  }
777 
778  // show from this onward link
780  $now = $lang->userTimeAndDate( $timestamp, $user );
781  $timenow = $lang->userTime( $timestamp, $user );
782  $datenow = $lang->userDate( $timestamp, $user );
783  $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
784 
785  $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, $pipedLinks )
786  ->parse() . '</span>';
787 
788  $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
789  $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
790  [ 'from' => $timestamp ],
791  $nondefaults
792  ) . '</span>';
793 
794  return "{$note}$rclinks<br />$rclistfrom";
795  }
796 
797  public function isIncludable() {
798  return true;
799  }
800 
801  protected function getCacheTTL() {
802  return 60 * 5;
803  }
804 
805 }
static newFromContext(IContextSource $context)
Fetch an appropriate changes list class for the specified context Some users might want to use an enh...
Definition: ChangesList.php:74
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
namespaceFilterForm(FormOptions $opts)
Creates the choose namespace selection.
const RC_CATEGORIZE
Definition: Defines.php:140
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
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:802
null for the local 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:1555
static buildTagFilterSelector($selected= '', $ooui=false)
Build a text box to select a change tag.
Definition: ChangeTags.php:672
getContext()
Gets the context this SpecialPage is executed in.
wfScript($script= 'index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
getCustomFilters()
Get custom show/hide filters.
$batch execute()
doMainQuery($conds, $opts)
Process the query.
The "CategoryFinder" class takes a list of articles, creates an internal representation of all their ...
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
__construct($name= 'Recentchanges', $restriction= '')
setTopText(FormOptions $opts)
Send the text to be displayed above the options.
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Definition: Html.php:209
if(!isset($args[0])) $lang
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:758
addFeedLinks($params)
Adds RSS/atom links.
optionsPanel($defaults, $nondefaults, $numRows)
Creates the options panel.
Represents a page (or page fragment) title within MediaWiki.
Definition: TitleValue.php:36
$value
A special page that lists last changes made to the wiki.
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
msg()
Wrapper around wfMessage that sets the current context.
buildMainQueryConds(FormOptions $opts)
Return an array of conditions depending of options set in $opts.
including($x=null)
Whether the special page is being evaluated via transclusion.
getOutput()
Get the OutputPage being used for this instance.
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
getOptions()
Get the current FormOptions for this request.
static submitButton($value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:460
addHelpLink($to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition: hooks.txt:1007
reset($name)
Delete the option value.
static label($label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:359
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2889
validateOptions(FormOptions $opts)
categoryFilterForm(FormOptions $opts)
Create an input to filter changes by categories.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static fieldset($legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:578
static closeElement($element)
Shortcut to close an XML element.
Definition: Xml.php:118
Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
Definition: Page.php:24
getExtraOptions($opts)
Get options to be displayed in a form.
wfAppendQuery($url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
doHeader($opts, $numRows)
Set the text to be displayed above the changes.
if($limit) $timestamp
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 $options
Definition: hooks.txt:1046
static openElement($element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
$params
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
Definition: defines.php:11
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:953
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:255
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
makeOptionsLink($title, $override, $options, $active=false)
Makes change an option link which carries all the other options.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
setBottomText(FormOptions $opts)
Send the text to be displayed after the options.
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:1721
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
static selectFields()
Return the list of recentchanges fields that should be selected to create a new recentchanges object...
static inputLabelSep($label, $name, $id, $size=false, $value=false, $attribs=[])
Same as Xml::inputLabel() but return input and label in an array.
Definition: Xml.php:400
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
validateIntBounds($name, $min, $max)
static array static newFromRow($row)
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag=false)
Applies all tags-related changes to a query.
Definition: ChangeTags.php:629
getDefaultOptions()
Get a FormOptions object containing the default options.
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
static tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
getName()
Get the name of this Special Page.
Special page which uses a ChangesList to show query results.
getUser()
Shortcut to get the User executing this instance.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
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 $limit
Definition: hooks.txt:1046
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
seed($articleIds, $categories, $mode= 'AND')
Initializes the instance.
$count
static checkLabel($label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:420
execute($subpage)
Main execution point.
const DB_REPLICA
Definition: defines.php:22
getRequest()
Get the WebRequest being used for this instance.
getFeedQuery()
Get URL query parameters for action=feedrecentchanges API feed of current recent changes view...
makeLegend()
Return the legend displayed within the fieldset.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
outputChangesList($rows, $opts)
Build and output the actual changes list.
filterByCategories(&$rows, FormOptions $opts)
Filter $rows by categories set in $opts.
addModules()
Add page-specific modules.
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:511
parseParameters($par, FormOptions $opts)
Process $par and put options found in $opts.
checkLastModified()
Get last modified date, for client caching Don't use this if we are using the patrol feature...
getPageTitle($subpage=false)
Get a self-referential title object.
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:846
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:300