MediaWiki  master
ChangesListSpecialPage.php
Go to the documentation of this file.
1 <?php
30 
37 abstract class ChangesListSpecialPage extends SpecialPage {
43 
48  protected static $savedQueriesPreferenceName;
49 
54  protected static $daysPreferenceName;
55 
60  protected static $limitPreferenceName;
61 
66  protected static $collapsedPreferenceName;
67 
69  protected $rcSubpage;
70 
72  protected $rcOptions;
73 
74  // Order of both groups and filters is significant; first is top-most priority,
75  // descending from there.
76  // 'showHideSuffix' is a shortcut to and avoid spelling out
77  // details specific to subclasses here.
91 
92  // Same format as filterGroupDefinitions, but for a single group (reviewStatus)
93  // that is registered conditionally.
95 
96  // Single filter group registered conditionally
98 
99  // Single filter group registered conditionally
101 
108  protected $filterGroups = [];
109 
110  public function __construct( $name, $restriction ) {
111  parent::__construct( $name, $restriction );
112 
113  $nonRevisionTypes = [ RC_LOG ];
114  Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
115 
116  $this->filterGroupDefinitions = [
117  [
118  'name' => 'registration',
119  'title' => 'rcfilters-filtergroup-registration',
121  'filters' => [
122  [
123  'name' => 'hideliu',
124  // rcshowhideliu-show, rcshowhideliu-hide,
125  // wlshowhideliu
126  'showHideSuffix' => 'showhideliu',
127  'default' => false,
128  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
129  &$query_options, &$join_conds
130  ) {
131  $actorMigration = ActorMigration::newMigration();
132  $actorQuery = $actorMigration->getJoin( 'rc_user' );
133  $tables += $actorQuery['tables'];
134  $join_conds += $actorQuery['joins'];
135  $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
136  },
137  'isReplacedInStructuredUi' => true,
138 
139  ],
140  [
141  'name' => 'hideanons',
142  // rcshowhideanons-show, rcshowhideanons-hide,
143  // wlshowhideanons
144  'showHideSuffix' => 'showhideanons',
145  'default' => false,
146  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
147  &$query_options, &$join_conds
148  ) {
149  $actorMigration = ActorMigration::newMigration();
150  $actorQuery = $actorMigration->getJoin( 'rc_user' );
151  $tables += $actorQuery['tables'];
152  $join_conds += $actorQuery['joins'];
153  $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
154  },
155  'isReplacedInStructuredUi' => true,
156  ]
157  ],
158  ],
159 
160  [
161  'name' => 'userExpLevel',
162  'title' => 'rcfilters-filtergroup-user-experience-level',
164  'isFullCoverage' => true,
165  'filters' => [
166  [
167  'name' => 'unregistered',
168  'label' => 'rcfilters-filter-user-experience-level-unregistered-label',
169  'description' => 'rcfilters-filter-user-experience-level-unregistered-description',
170  'cssClassSuffix' => 'user-unregistered',
171  'isRowApplicableCallable' => function ( $ctx, $rc ) {
172  return !$rc->getAttribute( 'rc_user' );
173  }
174  ],
175  [
176  'name' => 'registered',
177  'label' => 'rcfilters-filter-user-experience-level-registered-label',
178  'description' => 'rcfilters-filter-user-experience-level-registered-description',
179  'cssClassSuffix' => 'user-registered',
180  'isRowApplicableCallable' => function ( $ctx, $rc ) {
181  return $rc->getAttribute( 'rc_user' );
182  }
183  ],
184  [
185  'name' => 'newcomer',
186  'label' => 'rcfilters-filter-user-experience-level-newcomer-label',
187  'description' => 'rcfilters-filter-user-experience-level-newcomer-description',
188  'cssClassSuffix' => 'user-newcomer',
189  'isRowApplicableCallable' => function ( $ctx, $rc ) {
190  $performer = $rc->getPerformer();
191  return $performer && $performer->isLoggedIn() &&
192  $performer->getExperienceLevel() === 'newcomer';
193  }
194  ],
195  [
196  'name' => 'learner',
197  'label' => 'rcfilters-filter-user-experience-level-learner-label',
198  'description' => 'rcfilters-filter-user-experience-level-learner-description',
199  'cssClassSuffix' => 'user-learner',
200  'isRowApplicableCallable' => function ( $ctx, $rc ) {
201  $performer = $rc->getPerformer();
202  return $performer && $performer->isLoggedIn() &&
203  $performer->getExperienceLevel() === 'learner';
204  },
205  ],
206  [
207  'name' => 'experienced',
208  'label' => 'rcfilters-filter-user-experience-level-experienced-label',
209  'description' => 'rcfilters-filter-user-experience-level-experienced-description',
210  'cssClassSuffix' => 'user-experienced',
211  'isRowApplicableCallable' => function ( $ctx, $rc ) {
212  $performer = $rc->getPerformer();
213  return $performer && $performer->isLoggedIn() &&
214  $performer->getExperienceLevel() === 'experienced';
215  },
216  ]
217  ],
219  'queryCallable' => [ $this, 'filterOnUserExperienceLevel' ],
220  ],
221 
222  [
223  'name' => 'authorship',
224  'title' => 'rcfilters-filtergroup-authorship',
226  'filters' => [
227  [
228  'name' => 'hidemyself',
229  'label' => 'rcfilters-filter-editsbyself-label',
230  'description' => 'rcfilters-filter-editsbyself-description',
231  // rcshowhidemine-show, rcshowhidemine-hide,
232  // wlshowhidemine
233  'showHideSuffix' => 'showhidemine',
234  'default' => false,
235  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
236  &$query_options, &$join_conds
237  ) {
238  $actorQuery = ActorMigration::newMigration()->getWhere( $dbr, 'rc_user', $ctx->getUser() );
239  $tables += $actorQuery['tables'];
240  $join_conds += $actorQuery['joins'];
241  $conds[] = 'NOT(' . $actorQuery['conds'] . ')';
242  },
243  'cssClassSuffix' => 'self',
244  'isRowApplicableCallable' => function ( $ctx, $rc ) {
245  return $ctx->getUser()->equals( $rc->getPerformer() );
246  },
247  ],
248  [
249  'name' => 'hidebyothers',
250  'label' => 'rcfilters-filter-editsbyother-label',
251  'description' => 'rcfilters-filter-editsbyother-description',
252  'default' => false,
253  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
254  &$query_options, &$join_conds
255  ) {
256  $actorQuery = ActorMigration::newMigration()
257  ->getWhere( $dbr, 'rc_user', $ctx->getUser(), false );
258  $tables += $actorQuery['tables'];
259  $join_conds += $actorQuery['joins'];
260  $conds[] = $actorQuery['conds'];
261  },
262  'cssClassSuffix' => 'others',
263  'isRowApplicableCallable' => function ( $ctx, $rc ) {
264  return !$ctx->getUser()->equals( $rc->getPerformer() );
265  },
266  ]
267  ]
268  ],
269 
270  [
271  'name' => 'automated',
272  'title' => 'rcfilters-filtergroup-automated',
274  'filters' => [
275  [
276  'name' => 'hidebots',
277  'label' => 'rcfilters-filter-bots-label',
278  'description' => 'rcfilters-filter-bots-description',
279  // rcshowhidebots-show, rcshowhidebots-hide,
280  // wlshowhidebots
281  'showHideSuffix' => 'showhidebots',
282  'default' => false,
283  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
284  &$query_options, &$join_conds
285  ) {
286  $conds['rc_bot'] = 0;
287  },
288  'cssClassSuffix' => 'bot',
289  'isRowApplicableCallable' => function ( $ctx, $rc ) {
290  return $rc->getAttribute( 'rc_bot' );
291  },
292  ],
293  [
294  'name' => 'hidehumans',
295  'label' => 'rcfilters-filter-humans-label',
296  'description' => 'rcfilters-filter-humans-description',
297  'default' => false,
298  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
299  &$query_options, &$join_conds
300  ) {
301  $conds['rc_bot'] = 1;
302  },
303  'cssClassSuffix' => 'human',
304  'isRowApplicableCallable' => function ( $ctx, $rc ) {
305  return !$rc->getAttribute( 'rc_bot' );
306  },
307  ]
308  ]
309  ],
310 
311  // significance (conditional)
312 
313  [
314  'name' => 'significance',
315  'title' => 'rcfilters-filtergroup-significance',
317  'priority' => -6,
318  'filters' => [
319  [
320  'name' => 'hideminor',
321  'label' => 'rcfilters-filter-minor-label',
322  'description' => 'rcfilters-filter-minor-description',
323  // rcshowhideminor-show, rcshowhideminor-hide,
324  // wlshowhideminor
325  'showHideSuffix' => 'showhideminor',
326  'default' => false,
327  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
328  &$query_options, &$join_conds
329  ) {
330  $conds[] = 'rc_minor = 0';
331  },
332  'cssClassSuffix' => 'minor',
333  'isRowApplicableCallable' => function ( $ctx, $rc ) {
334  return $rc->getAttribute( 'rc_minor' );
335  }
336  ],
337  [
338  'name' => 'hidemajor',
339  'label' => 'rcfilters-filter-major-label',
340  'description' => 'rcfilters-filter-major-description',
341  'default' => false,
342  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
343  &$query_options, &$join_conds
344  ) {
345  $conds[] = 'rc_minor = 1';
346  },
347  'cssClassSuffix' => 'major',
348  'isRowApplicableCallable' => function ( $ctx, $rc ) {
349  return !$rc->getAttribute( 'rc_minor' );
350  }
351  ]
352  ]
353  ],
354 
355  [
356  'name' => 'lastRevision',
357  'title' => 'rcfilters-filtergroup-lastrevision',
359  'priority' => -7,
360  'filters' => [
361  [
362  'name' => 'hidelastrevision',
363  'label' => 'rcfilters-filter-lastrevision-label',
364  'description' => 'rcfilters-filter-lastrevision-description',
365  'default' => false,
366  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
367  &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
368  $conds[] = $dbr->makeList(
369  [
370  'rc_this_oldid <> page_latest',
371  'rc_type' => $nonRevisionTypes,
372  ],
373  LIST_OR
374  );
375  },
376  'cssClassSuffix' => 'last',
377  'isRowApplicableCallable' => function ( $ctx, $rc ) {
378  return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
379  }
380  ],
381  [
382  'name' => 'hidepreviousrevisions',
383  'label' => 'rcfilters-filter-previousrevision-label',
384  'description' => 'rcfilters-filter-previousrevision-description',
385  'default' => false,
386  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
387  &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
388  $conds[] = $dbr->makeList(
389  [
390  'rc_this_oldid = page_latest',
391  'rc_type' => $nonRevisionTypes,
392  ],
393  LIST_OR
394  );
395  },
396  'cssClassSuffix' => 'previous',
397  'isRowApplicableCallable' => function ( $ctx, $rc ) {
398  return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
399  }
400  ]
401  ]
402  ],
403 
404  // With extensions, there can be change types that will not be hidden by any of these.
405  [
406  'name' => 'changeType',
407  'title' => 'rcfilters-filtergroup-changetype',
409  'priority' => -8,
410  'filters' => [
411  [
412  'name' => 'hidepageedits',
413  'label' => 'rcfilters-filter-pageedits-label',
414  'description' => 'rcfilters-filter-pageedits-description',
415  'default' => false,
416  'priority' => -2,
417  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
418  &$query_options, &$join_conds
419  ) {
420  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
421  },
422  'cssClassSuffix' => 'src-mw-edit',
423  'isRowApplicableCallable' => function ( $ctx, $rc ) {
424  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_EDIT;
425  },
426  ],
427  [
428  'name' => 'hidenewpages',
429  'label' => 'rcfilters-filter-newpages-label',
430  'description' => 'rcfilters-filter-newpages-description',
431  'default' => false,
432  'priority' => -3,
433  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
434  &$query_options, &$join_conds
435  ) {
436  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
437  },
438  'cssClassSuffix' => 'src-mw-new',
439  'isRowApplicableCallable' => function ( $ctx, $rc ) {
440  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_NEW;
441  },
442  ],
443 
444  // hidecategorization
445 
446  [
447  'name' => 'hidelog',
448  'label' => 'rcfilters-filter-logactions-label',
449  'description' => 'rcfilters-filter-logactions-description',
450  'default' => false,
451  'priority' => -5,
452  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
453  &$query_options, &$join_conds
454  ) {
455  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
456  },
457  'cssClassSuffix' => 'src-mw-log',
458  'isRowApplicableCallable' => function ( $ctx, $rc ) {
459  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_LOG;
460  }
461  ],
462  ],
463  ],
464 
465  ];
466 
467  $this->legacyReviewStatusFilterGroupDefinition = [
468  [
469  'name' => 'legacyReviewStatus',
470  'title' => 'rcfilters-filtergroup-reviewstatus',
472  'filters' => [
473  [
474  'name' => 'hidepatrolled',
475  // rcshowhidepatr-show, rcshowhidepatr-hide
476  // wlshowhidepatr
477  'showHideSuffix' => 'showhidepatr',
478  'default' => false,
479  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
480  &$query_options, &$join_conds
481  ) {
482  $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
483  },
484  'isReplacedInStructuredUi' => true,
485  ],
486  [
487  'name' => 'hideunpatrolled',
488  'default' => false,
489  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
490  &$query_options, &$join_conds
491  ) {
492  $conds[] = 'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED;
493  },
494  'isReplacedInStructuredUi' => true,
495  ],
496  ],
497  ]
498  ];
499 
500  $this->reviewStatusFilterGroupDefinition = [
501  [
502  'name' => 'reviewStatus',
503  'title' => 'rcfilters-filtergroup-reviewstatus',
505  'isFullCoverage' => true,
506  'priority' => -5,
507  'filters' => [
508  [
509  'name' => 'unpatrolled',
510  'label' => 'rcfilters-filter-reviewstatus-unpatrolled-label',
511  'description' => 'rcfilters-filter-reviewstatus-unpatrolled-description',
512  'cssClassSuffix' => 'reviewstatus-unpatrolled',
513  'isRowApplicableCallable' => function ( $ctx, $rc ) {
514  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED;
515  },
516  ],
517  [
518  'name' => 'manual',
519  'label' => 'rcfilters-filter-reviewstatus-manual-label',
520  'description' => 'rcfilters-filter-reviewstatus-manual-description',
521  'cssClassSuffix' => 'reviewstatus-manual',
522  'isRowApplicableCallable' => function ( $ctx, $rc ) {
523  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_PATROLLED;
524  },
525  ],
526  [
527  'name' => 'auto',
528  'label' => 'rcfilters-filter-reviewstatus-auto-label',
529  'description' => 'rcfilters-filter-reviewstatus-auto-description',
530  'cssClassSuffix' => 'reviewstatus-auto',
531  'isRowApplicableCallable' => function ( $ctx, $rc ) {
532  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_AUTOPATROLLED;
533  },
534  ],
535  ],
537  'queryCallable' => function ( $specialPageClassName, $ctx, $dbr,
538  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selected
539  ) {
540  if ( $selected === [] ) {
541  return;
542  }
543  $rcPatrolledValues = [
544  'unpatrolled' => RecentChange::PRC_UNPATROLLED,
545  'manual' => RecentChange::PRC_PATROLLED,
547  ];
548  // e.g. rc_patrolled IN (0, 2)
549  $conds['rc_patrolled'] = array_map( function ( $s ) use ( $rcPatrolledValues ) {
550  return $rcPatrolledValues[ $s ];
551  }, $selected );
552  }
553  ]
554  ];
555 
556  $this->hideCategorizationFilterDefinition = [
557  'name' => 'hidecategorization',
558  'label' => 'rcfilters-filter-categorization-label',
559  'description' => 'rcfilters-filter-categorization-description',
560  // rcshowhidecategorization-show, rcshowhidecategorization-hide.
561  // wlshowhidecategorization
562  'showHideSuffix' => 'showhidecategorization',
563  'default' => false,
564  'priority' => -4,
565  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
566  &$query_options, &$join_conds
567  ) {
568  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
569  },
570  'cssClassSuffix' => 'src-mw-categorize',
571  'isRowApplicableCallable' => function ( $ctx, $rc ) {
572  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_CATEGORIZE;
573  },
574  ];
575  }
576 
582  protected function areFiltersInConflict() {
583  $opts = $this->getOptions();
585  foreach ( $this->getFilterGroups() as $group ) {
586  if ( $group->getConflictingGroups() ) {
587  wfLogWarning(
588  $group->getName() .
589  " specifies conflicts with other groups but these are not supported yet."
590  );
591  }
592 
594  foreach ( $group->getConflictingFilters() as $conflictingFilter ) {
595  if ( $conflictingFilter->activelyInConflictWithGroup( $group, $opts ) ) {
596  return true;
597  }
598  }
599 
601  foreach ( $group->getFilters() as $filter ) {
603  foreach ( $filter->getConflictingFilters() as $conflictingFilter ) {
604  if (
605  $conflictingFilter->activelyInConflictWithFilter( $filter, $opts ) &&
606  $filter->activelyInConflictWithFilter( $conflictingFilter, $opts )
607  ) {
608  return true;
609  }
610  }
611 
612  }
613 
614  }
615 
616  return false;
617  }
618 
622  public function execute( $subpage ) {
623  $this->rcSubpage = $subpage;
624 
625  $this->considerActionsForDefaultSavedQuery( $subpage );
626 
627  $opts = $this->getOptions();
628  try {
629  $rows = $this->getRows();
630  if ( $rows === false ) {
631  $rows = new FakeResultWrapper( [] );
632  }
633 
634  // Used by Structured UI app to get results without MW chrome
635  if ( $this->getRequest()->getVal( 'action' ) === 'render' ) {
636  $this->getOutput()->setArticleBodyOnly( true );
637  }
638 
639  // Used by "live update" and "view newest" to check
640  // if there's new changes with minimal data transfer
641  if ( $this->getRequest()->getBool( 'peek' ) ) {
642  $code = $rows->numRows() > 0 ? 200 : 204;
643  $this->getOutput()->setStatusCode( $code );
644 
645  if ( $this->getUser()->isAnon() !==
646  $this->getRequest()->getFuzzyBool( 'isAnon' )
647  ) {
648  $this->getOutput()->setStatusCode( 205 );
649  }
650 
651  return;
652  }
653 
654  $batch = new LinkBatch;
655  foreach ( $rows as $row ) {
656  $batch->add( NS_USER, $row->rc_user_text );
657  $batch->add( NS_USER_TALK, $row->rc_user_text );
658  $batch->add( $row->rc_namespace, $row->rc_title );
659  if ( $row->rc_source === RecentChange::SRC_LOG ) {
660  $formatter = LogFormatter::newFromRow( $row );
661  foreach ( $formatter->getPreloadTitles() as $title ) {
662  $batch->addObj( $title );
663  }
664  }
665  }
666  $batch->execute();
667 
668  $this->setHeaders();
669  $this->outputHeader();
670  $this->addModules();
671  $this->webOutput( $rows, $opts );
672 
673  $rows->free();
674  } catch ( DBQueryTimeoutError $timeoutException ) {
675  MWExceptionHandler::logException( $timeoutException );
676 
677  $this->setHeaders();
678  $this->outputHeader();
679  $this->addModules();
680 
681  $this->getOutput()->setStatusCode( 500 );
682  $this->webOutputHeader( 0, $opts );
683  $this->outputTimeout();
684  }
685 
686  if ( $this->getConfig()->get( 'EnableWANCacheReaper' ) ) {
687  // Clean up any bad page entries for titles showing up in RC
689  $this->getDB(),
690  LoggerFactory::getInstance( 'objectcache' )
691  ) );
692  }
693 
694  $this->includeRcFiltersApp();
695  }
696 
704  protected function considerActionsForDefaultSavedQuery( $subpage ) {
705  if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) {
706  return;
707  }
708 
709  $knownParams = $this->getRequest()->getValues(
710  ...array_keys( $this->getOptions()->getAllValues() )
711  );
712 
713  // HACK: Temporarily until we can properly define "sticky" filters and parameters,
714  // we need to exclude several parameters we know should not be counted towards preventing
715  // the loading of defaults.
716  $excludedParams = [ 'limit' => '', 'days' => '', 'enhanced' => '', 'from' => '' ];
717  $knownParams = array_diff_key( $knownParams, $excludedParams );
718 
719  if (
720  // If there are NO known parameters in the URL request
721  // (that are not excluded) then we need to check into loading
722  // the default saved query
723  count( $knownParams ) === 0
724  ) {
725  // Get the saved queries data and parse it
726  $savedQueries = FormatJson::decode(
727  $this->getUser()->getOption( static::$savedQueriesPreferenceName ),
728  true
729  );
730 
731  if ( $savedQueries && isset( $savedQueries[ 'default' ] ) ) {
732  // Only load queries that are 'version' 2, since those
733  // have parameter representation
734  if ( isset( $savedQueries[ 'version' ] ) && $savedQueries[ 'version' ] === '2' ) {
735  $savedQueryDefaultID = $savedQueries[ 'default' ];
736  $defaultQuery = $savedQueries[ 'queries' ][ $savedQueryDefaultID ][ 'data' ];
737 
738  // Build the entire parameter list
739  $query = array_merge(
740  $defaultQuery[ 'params' ],
741  $defaultQuery[ 'highlights' ],
742  [
743  'urlversion' => '2',
744  ]
745  );
746  // Add to the query any parameters that we may have ignored before
747  // but are still valid and requested in the URL
748  $query = array_merge( $this->getRequest()->getValues(), $query );
749  unset( $query[ 'title' ] );
750  $this->getOutput()->redirect( $this->getPageTitle( $subpage )->getCanonicalURL( $query ) );
751  } else {
752  // There's a default, but the version is not 2, and the server can't
753  // actually recognize the query itself. This happens if it is before
754  // the conversion, so we need to tell the UI to reload saved query as
755  // it does the conversion to version 2
756  $this->getOutput()->addJsConfigVars(
757  'wgStructuredChangeFiltersDefaultSavedQueryExists',
758  true
759  );
760 
761  // Add the class that tells the frontend it is still loading
762  // another query
763  $this->getOutput()->addBodyClasses( 'mw-rcfilters-ui-loading' );
764  }
765  }
766  }
767  }
768 
775  protected function includeRcFiltersApp() {
776  $out = $this->getOutput();
777  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
778  $jsData = $this->getStructuredFilterJsData();
779  $messages = [];
780  foreach ( $jsData['messageKeys'] as $key ) {
781  $messages[$key] = $this->msg( $key )->plain();
782  }
783 
784  $out->addBodyClasses( 'mw-rcfilters-enabled' );
785  $collapsed = $this->getUser()->getBoolOption( static::$collapsedPreferenceName );
786  if ( $collapsed ) {
787  $out->addBodyClasses( 'mw-rcfilters-collapsed' );
788  }
789 
790  // These config and message exports should be moved into a ResourceLoader data module (T201574)
791  $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
792  $out->addJsConfigVars( 'wgStructuredChangeFiltersMessages', $messages );
793  $out->addJsConfigVars( 'wgStructuredChangeFiltersCollapsedState', $collapsed );
794 
795  $out->addJsConfigVars(
796  'StructuredChangeFiltersDisplayConfig',
797  [
798  'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
799  'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
800  'limitDefault' => $this->getDefaultLimit(),
801  'daysArray' => $this->getConfig()->get( 'RCLinkDays' ),
802  'daysDefault' => $this->getDefaultDays(),
803  ]
804  );
805 
806  $out->addJsConfigVars(
807  'wgStructuredChangeFiltersSavedQueriesPreferenceName',
808  static::$savedQueriesPreferenceName
809  );
810  $out->addJsConfigVars(
811  'wgStructuredChangeFiltersLimitPreferenceName',
812  static::$limitPreferenceName
813  );
814  $out->addJsConfigVars(
815  'wgStructuredChangeFiltersDaysPreferenceName',
816  static::$daysPreferenceName
817  );
818  $out->addJsConfigVars(
819  'wgStructuredChangeFiltersCollapsedPreferenceName',
820  static::$collapsedPreferenceName
821  );
822  } else {
823  $out->addBodyClasses( 'mw-rcfilters-disabled' );
824  }
825  }
826 
834  return [
835  'RCFiltersChangeTags' => self::getChangeTagList( $context ),
836  'StructuredChangeFiltersEditWatchlistUrl' =>
837  SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
838  ];
839  }
840 
847  protected static function getChangeTagList( ResourceLoaderContext $context ) {
848  $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
849  return $cache->getWithSetCallback(
850  $cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage() ),
851  $cache::TTL_MINUTE * 10,
852  function () use ( $context ) {
853  $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
854  $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
855 
856  $tagStats = ChangeTags::tagUsageStatistics();
857  $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
858 
859  // Sort by hits (disabled for now)
860  //arsort( $tagHitCounts );
861 
862  // HACK work around ChangeTags::truncateTagDescription() requiring a RequestContext
863  $fakeContext = RequestContext::newExtraneousContext( Title::newFromText( 'Dwimmerlaik' ) );
864  $fakeContext->setLanguage( Language::factory( $context->getLanguage() ) );
865 
866  // Build the list and data
867  $result = [];
868  foreach ( $tagHitCounts as $tagName => $hits ) {
869  if (
870  (
871  // Only get active tags
872  isset( $explicitlyDefinedTags[ $tagName ] ) ||
873  isset( $softwareActivatedTags[ $tagName ] )
874  ) &&
875  // Only get tags with more than 0 hits
876  $hits > 0
877  ) {
878  $result[] = [
879  'name' => $tagName,
880  'label' => Sanitizer::stripAllTags(
881  ChangeTags::tagDescription( $tagName, $context )
882  ),
883  'description' =>
885  $tagName,
886  self::TAG_DESC_CHARACTER_LIMIT,
887  $fakeContext
888  ),
889  'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
890  'hits' => $hits,
891  ];
892  }
893  }
894 
895  // Instead of sorting by hit count (disabled, see above), sort by display name
896  usort( $result, function ( $a, $b ) {
897  return strcasecmp( $a['label'], $b['label'] );
898  } );
899 
900  return $result;
901  },
902  [
903  'lockTSE' => 30
904  ]
905  );
906  }
907 
911  protected function outputNoResults() {
912  $this->getOutput()->addHTML(
913  '<div class="mw-changeslist-empty">' .
914  $this->msg( 'recentchanges-noresult' )->parse() .
915  '</div>'
916  );
917  }
918 
922  protected function outputTimeout() {
923  $this->getOutput()->addHTML(
924  '<div class="mw-changeslist-empty mw-changeslist-timeout">' .
925  $this->msg( 'recentchanges-timeout' )->parse() .
926  '</div>'
927  );
928  }
929 
935  public function getRows() {
936  $opts = $this->getOptions();
937 
938  $tables = [];
939  $fields = [];
940  $conds = [];
941  $query_options = [];
942  $join_conds = [];
943  $this->buildQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
944 
945  return $this->doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
946  }
947 
953  public function getOptions() {
954  if ( $this->rcOptions === null ) {
955  $this->rcOptions = $this->setup( $this->rcSubpage );
956  }
957 
958  return $this->rcOptions;
959  }
960 
970  protected function registerFilters() {
971  $this->registerFiltersFromDefinitions( $this->filterGroupDefinitions );
972 
973  // Make sure this is not being transcluded (we don't want to show this
974  // information to all users just because the user that saves the edit can
975  // patrol or is logged in)
976  if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
977  $this->registerFiltersFromDefinitions( $this->legacyReviewStatusFilterGroupDefinition );
978  $this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition );
979  }
980 
981  $changeTypeGroup = $this->getFilterGroup( 'changeType' );
982 
983  if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
984  $transformedHideCategorizationDef = $this->transformFilterDefinition(
985  $this->hideCategorizationFilterDefinition
986  );
987 
988  $transformedHideCategorizationDef['group'] = $changeTypeGroup;
989 
990  $hideCategorization = new ChangesListBooleanFilter(
991  $transformedHideCategorizationDef
992  );
993  }
994 
995  Hooks::run( 'ChangesListSpecialPageStructuredFilters', [ $this ] );
996 
997  $this->registerFiltersFromDefinitions( [] );
998 
999  $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' );
1000  $registered = $userExperienceLevel->getFilter( 'registered' );
1001  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'newcomer' ) );
1002  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'learner' ) );
1003  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'experienced' ) );
1004 
1005  $categoryFilter = $changeTypeGroup->getFilter( 'hidecategorization' );
1006  $logactionsFilter = $changeTypeGroup->getFilter( 'hidelog' );
1007  $pagecreationFilter = $changeTypeGroup->getFilter( 'hidenewpages' );
1008 
1009  $significanceTypeGroup = $this->getFilterGroup( 'significance' );
1010  $hideMinorFilter = $significanceTypeGroup->getFilter( 'hideminor' );
1011 
1012  // categoryFilter is conditional; see registerFilters
1013  if ( $categoryFilter !== null ) {
1014  $hideMinorFilter->conflictsWith(
1015  $categoryFilter,
1016  'rcfilters-hideminor-conflicts-typeofchange-global',
1017  'rcfilters-hideminor-conflicts-typeofchange',
1018  'rcfilters-typeofchange-conflicts-hideminor'
1019  );
1020  }
1021  $hideMinorFilter->conflictsWith(
1022  $logactionsFilter,
1023  'rcfilters-hideminor-conflicts-typeofchange-global',
1024  'rcfilters-hideminor-conflicts-typeofchange',
1025  'rcfilters-typeofchange-conflicts-hideminor'
1026  );
1027  $hideMinorFilter->conflictsWith(
1028  $pagecreationFilter,
1029  'rcfilters-hideminor-conflicts-typeofchange-global',
1030  'rcfilters-hideminor-conflicts-typeofchange',
1031  'rcfilters-typeofchange-conflicts-hideminor'
1032  );
1033  }
1034 
1044  protected function transformFilterDefinition( array $filterDefinition ) {
1045  return $filterDefinition;
1046  }
1047 
1058  protected function registerFiltersFromDefinitions( array $definition ) {
1059  $autoFillPriority = -1;
1060  foreach ( $definition as $groupDefinition ) {
1061  if ( !isset( $groupDefinition['priority'] ) ) {
1062  $groupDefinition['priority'] = $autoFillPriority;
1063  } else {
1064  // If it's explicitly specified, start over the auto-fill
1065  $autoFillPriority = $groupDefinition['priority'];
1066  }
1067 
1068  $autoFillPriority--;
1069 
1070  $className = $groupDefinition['class'];
1071  unset( $groupDefinition['class'] );
1072 
1073  foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
1074  $filterDefinition = $this->transformFilterDefinition( $filterDefinition );
1075  }
1076 
1077  $this->registerFilterGroup( new $className( $groupDefinition ) );
1078  }
1079  }
1080 
1084  protected function getLegacyShowHideFilters() {
1085  $filters = [];
1086  foreach ( $this->filterGroups as $group ) {
1087  if ( $group instanceof ChangesListBooleanFilterGroup ) {
1088  foreach ( $group->getFilters() as $key => $filter ) {
1089  if ( $filter->displaysOnUnstructuredUi( $this ) ) {
1090  $filters[ $key ] = $filter;
1091  }
1092  }
1093  }
1094  }
1095  return $filters;
1096  }
1097 
1106  public function setup( $parameters ) {
1107  $this->registerFilters();
1108 
1109  $opts = $this->getDefaultOptions();
1110 
1111  $opts = $this->fetchOptionsFromRequest( $opts );
1112 
1113  // Give precedence to subpage syntax
1114  if ( $parameters !== null ) {
1115  $this->parseParameters( $parameters, $opts );
1116  }
1117 
1118  $this->validateOptions( $opts );
1119 
1120  return $opts;
1121  }
1122 
1132  public function getDefaultOptions() {
1133  $opts = new FormOptions();
1134  $structuredUI = $this->isStructuredFilterUiEnabled();
1135  // If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
1136  $useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
1137 
1139  foreach ( $this->filterGroups as $filterGroup ) {
1140  $filterGroup->addOptions( $opts, $useDefaults, $structuredUI );
1141  }
1142 
1143  $opts->add( 'namespace', '', FormOptions::STRING );
1144  $opts->add( 'invert', false );
1145  $opts->add( 'associated', false );
1146  $opts->add( 'urlversion', 1 );
1147  $opts->add( 'tagfilter', '' );
1148 
1149  $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT );
1150  $opts->add( 'limit', $this->getDefaultLimit(), FormOptions::INT );
1151 
1152  $opts->add( 'from', '' );
1153 
1154  return $opts;
1155  }
1156 
1162  public function registerFilterGroup( ChangesListFilterGroup $group ) {
1163  $groupName = $group->getName();
1164 
1165  $this->filterGroups[$groupName] = $group;
1166  }
1167 
1173  protected function getFilterGroups() {
1174  return $this->filterGroups;
1175  }
1176 
1184  public function getFilterGroup( $groupName ) {
1185  return $this->filterGroups[$groupName] ?? null;
1186  }
1187 
1188  // Currently, this intentionally only includes filters that display
1189  // in the structured UI. This can be changed easily, though, if we want
1190  // to include data on filters that use the unstructured UI. messageKeys is a
1191  // special top-level value, with the value being an array of the message keys to
1192  // send to the client.
1193 
1201  public function getStructuredFilterJsData() {
1202  $output = [
1203  'groups' => [],
1204  'messageKeys' => [],
1205  ];
1206 
1207  usort( $this->filterGroups, function ( $a, $b ) {
1208  return $b->getPriority() <=> $a->getPriority();
1209  } );
1210 
1211  foreach ( $this->filterGroups as $groupName => $group ) {
1212  $groupOutput = $group->getJsData( $this );
1213  if ( $groupOutput !== null ) {
1214  $output['messageKeys'] = array_merge(
1215  $output['messageKeys'],
1216  $groupOutput['messageKeys']
1217  );
1218 
1219  unset( $groupOutput['messageKeys'] );
1220  $output['groups'][] = $groupOutput;
1221  }
1222  }
1223 
1224  return $output;
1225  }
1226 
1235  protected function fetchOptionsFromRequest( $opts ) {
1236  $opts->fetchValuesFromRequest( $this->getRequest() );
1237 
1238  return $opts;
1239  }
1240 
1247  public function parseParameters( $par, FormOptions $opts ) {
1248  $stringParameterNameSet = [];
1249  $hideParameterNameSet = [];
1250 
1251  // URL parameters can be per-group, like 'userExpLevel',
1252  // or per-filter, like 'hideminor'.
1253 
1254  foreach ( $this->filterGroups as $filterGroup ) {
1255  if ( $filterGroup instanceof ChangesListStringOptionsFilterGroup ) {
1256  $stringParameterNameSet[$filterGroup->getName()] = true;
1257  } elseif ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1258  foreach ( $filterGroup->getFilters() as $filter ) {
1259  $hideParameterNameSet[$filter->getName()] = true;
1260  }
1261  }
1262  }
1263 
1264  $bits = preg_split( '/\s*,\s*/', trim( $par ) );
1265  foreach ( $bits as $bit ) {
1266  $m = [];
1267  if ( isset( $hideParameterNameSet[$bit] ) ) {
1268  // hidefoo => hidefoo=true
1269  $opts[$bit] = true;
1270  } elseif ( isset( $hideParameterNameSet["hide$bit"] ) ) {
1271  // foo => hidefoo=false
1272  $opts["hide$bit"] = false;
1273  } elseif ( preg_match( '/^(.*)=(.*)$/', $bit, $m ) ) {
1274  if ( isset( $stringParameterNameSet[$m[1]] ) ) {
1275  $opts[$m[1]] = $m[2];
1276  }
1277  }
1278  }
1279  }
1280 
1286  public function validateOptions( FormOptions $opts ) {
1287  $isContradictory = $this->fixContradictoryOptions( $opts );
1288  $isReplaced = $this->replaceOldOptions( $opts );
1289 
1290  if ( $isContradictory || $isReplaced ) {
1291  $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
1292  $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
1293  }
1294 
1295  $opts->validateIntBounds( 'limit', 0, 5000 );
1296  $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
1297  }
1298 
1305  private function fixContradictoryOptions( FormOptions $opts ) {
1306  $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
1307 
1308  foreach ( $this->filterGroups as $filterGroup ) {
1309  if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1310  $filters = $filterGroup->getFilters();
1311 
1312  if ( count( $filters ) === 1 ) {
1313  // legacy boolean filters should not be considered
1314  continue;
1315  }
1316 
1317  $allInGroupEnabled = array_reduce(
1318  $filters,
1319  function ( $carry, $filter ) use ( $opts ) {
1320  return $carry && $opts[ $filter->getName() ];
1321  },
1322  /* initialValue */ count( $filters ) > 0
1323  );
1324 
1325  if ( $allInGroupEnabled ) {
1326  foreach ( $filters as $filter ) {
1327  $opts[ $filter->getName() ] = false;
1328  }
1329 
1330  $fixed = true;
1331  }
1332  }
1333  }
1334 
1335  return $fixed;
1336  }
1337 
1347  private function fixBackwardsCompatibilityOptions( FormOptions $opts ) {
1348  if ( $opts['hideanons'] && $opts['hideliu'] ) {
1349  $opts->reset( 'hideanons' );
1350  if ( !$opts['hidebots'] ) {
1351  $opts->reset( 'hideliu' );
1352  $opts['hidehumans'] = 1;
1353  }
1354 
1355  return true;
1356  }
1357 
1358  return false;
1359  }
1360 
1367  public function replaceOldOptions( FormOptions $opts ) {
1368  if ( !$this->isStructuredFilterUiEnabled() ) {
1369  return false;
1370  }
1371 
1372  $changed = false;
1373 
1374  // At this point 'hideanons' and 'hideliu' cannot be both true,
1375  // because fixBackwardsCompatibilityOptions resets (at least) 'hideanons' in such case
1376  if ( $opts[ 'hideanons' ] ) {
1377  $opts->reset( 'hideanons' );
1378  $opts[ 'userExpLevel' ] = 'registered';
1379  $changed = true;
1380  }
1381 
1382  if ( $opts[ 'hideliu' ] ) {
1383  $opts->reset( 'hideliu' );
1384  $opts[ 'userExpLevel' ] = 'unregistered';
1385  $changed = true;
1386  }
1387 
1388  if ( $this->getFilterGroup( 'legacyReviewStatus' ) ) {
1389  if ( $opts[ 'hidepatrolled' ] ) {
1390  $opts->reset( 'hidepatrolled' );
1391  $opts[ 'reviewStatus' ] = 'unpatrolled';
1392  $changed = true;
1393  }
1394 
1395  if ( $opts[ 'hideunpatrolled' ] ) {
1396  $opts->reset( 'hideunpatrolled' );
1397  $opts[ 'reviewStatus' ] = implode(
1399  [ 'manual', 'auto' ]
1400  );
1401  $changed = true;
1402  }
1403  }
1404 
1405  return $changed;
1406  }
1407 
1416  protected function convertParamsForLink( $params ) {
1417  foreach ( $params as &$value ) {
1418  if ( $value === false ) {
1419  $value = '0';
1420  }
1421  }
1422  unset( $value );
1423  return $params;
1424  }
1425 
1437  protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
1438  &$join_conds, FormOptions $opts
1439  ) {
1440  $dbr = $this->getDB();
1441  $isStructuredUI = $this->isStructuredFilterUiEnabled();
1442 
1444  foreach ( $this->filterGroups as $filterGroup ) {
1445  $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1446  $query_options, $join_conds, $opts, $isStructuredUI );
1447  }
1448 
1449  // Namespace filtering
1450  if ( $opts[ 'namespace' ] !== '' ) {
1451  $namespaces = explode( ';', $opts[ 'namespace' ] );
1452 
1453  if ( $opts[ 'associated' ] ) {
1454  $associatedNamespaces = array_map(
1455  function ( $ns ) {
1456  return MediaWikiServices::getInstance()->getNamespaceInfo()->
1457  getAssociated( $ns );
1458  },
1459  $namespaces
1460  );
1461  $namespaces = array_unique( array_merge( $namespaces, $associatedNamespaces ) );
1462  }
1463 
1464  if ( count( $namespaces ) === 1 ) {
1465  $operator = $opts[ 'invert' ] ? '!=' : '=';
1466  $value = $dbr->addQuotes( reset( $namespaces ) );
1467  } else {
1468  $operator = $opts[ 'invert' ] ? 'NOT IN' : 'IN';
1469  sort( $namespaces );
1470  $value = '(' . $dbr->makeList( $namespaces ) . ')';
1471  }
1472  $conds[] = "rc_namespace $operator $value";
1473  }
1474 
1475  // Calculate cutoff
1476  $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
1477  $cutoff = $dbr->timestamp( $cutoff_unixtime );
1478 
1479  $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
1480  if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
1481  $cutoff = $dbr->timestamp( $opts['from'] );
1482  } else {
1483  $opts->reset( 'from' );
1484  }
1485 
1486  $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
1487  }
1488 
1500  protected function doMainQuery( $tables, $fields, $conds,
1501  $query_options, $join_conds, FormOptions $opts
1502  ) {
1503  $rcQuery = RecentChange::getQueryInfo();
1504  $tables = array_merge( $tables, $rcQuery['tables'] );
1505  $fields = array_merge( $rcQuery['fields'], $fields );
1506  $join_conds = array_merge( $join_conds, $rcQuery['joins'] );
1507 
1509  $tables,
1510  $fields,
1511  $conds,
1512  $join_conds,
1513  $query_options,
1514  ''
1515  );
1516 
1517  if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
1518  $opts )
1519  ) {
1520  return false;
1521  }
1522 
1523  $dbr = $this->getDB();
1524 
1525  return $dbr->select(
1526  $tables,
1527  $fields,
1528  $conds,
1529  __METHOD__,
1530  $query_options,
1531  $join_conds
1532  );
1533  }
1534 
1535  protected function runMainQueryHook( &$tables, &$fields, &$conds,
1536  &$query_options, &$join_conds, $opts
1537  ) {
1538  return Hooks::run(
1539  'ChangesListSpecialPageQuery',
1540  [ $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ]
1541  );
1542  }
1543 
1549  protected function getDB() {
1550  return wfGetDB( DB_REPLICA );
1551  }
1552 
1559  private function webOutputHeader( $rowCount, $opts ) {
1560  if ( !$this->including() ) {
1561  $this->outputFeedLinks();
1562  $this->doHeader( $opts, $rowCount );
1563  }
1564  }
1565 
1572  public function webOutput( $rows, $opts ) {
1573  $this->webOutputHeader( $rows->numRows(), $opts );
1574 
1575  $this->outputChangesList( $rows, $opts );
1576  }
1577 
1581  public function outputFeedLinks() {
1582  // nothing by default
1583  }
1584 
1591  abstract public function outputChangesList( $rows, $opts );
1592 
1599  public function doHeader( $opts, $numRows ) {
1600  $this->setTopText( $opts );
1601 
1602  // @todo Lots of stuff should be done here.
1603 
1604  $this->setBottomText( $opts );
1605  }
1606 
1614  public function setTopText( FormOptions $opts ) {
1615  // nothing by default
1616  }
1617 
1625  public function setBottomText( FormOptions $opts ) {
1626  // nothing by default
1627  }
1628 
1638  public function getExtraOptions( $opts ) {
1639  return [];
1640  }
1641 
1647  public function makeLegend() {
1648  $context = $this->getContext();
1649  $user = $context->getUser();
1650  # The legend showing what the letters and stuff mean
1651  $legend = Html::openElement( 'dl' ) . "\n";
1652  # Iterates through them and gets the messages for both letter and tooltip
1653  $legendItems = $context->getConfig()->get( 'RecentChangesFlags' );
1654  if ( !( $user->useRCPatrol() || $user->useNPPatrol() ) ) {
1655  unset( $legendItems['unpatrolled'] );
1656  }
1657  foreach ( $legendItems as $key => $item ) { # generate items of the legend
1658  $label = $item['legend'] ?? $item['title'];
1659  $letter = $item['letter'];
1660  $cssClass = $item['class'] ?? $key;
1661 
1662  $legend .= Html::element( 'dt',
1663  [ 'class' => $cssClass ], $context->msg( $letter )->text()
1664  ) . "\n" .
1665  Html::rawElement( 'dd',
1666  [ 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ],
1667  $context->msg( $label )->parse()
1668  ) . "\n";
1669  }
1670  # (+-123)
1671  $legend .= Html::rawElement( 'dt',
1672  [ 'class' => 'mw-plusminus-pos' ],
1673  $context->msg( 'recentchanges-legend-plusminus' )->parse()
1674  ) . "\n";
1675  $legend .= Html::element(
1676  'dd',
1677  [ 'class' => 'mw-changeslist-legend-plusminus' ],
1678  $context->msg( 'recentchanges-label-plusminus' )->text()
1679  ) . "\n";
1680  $legend .= Html::closeElement( 'dl' ) . "\n";
1681 
1682  $legendHeading = $this->isStructuredFilterUiEnabled() ?
1683  $context->msg( 'rcfilters-legend-heading' )->parse() :
1684  $context->msg( 'recentchanges-legend-heading' )->parse();
1685 
1686  # Collapsible
1687  $collapsedState = $this->getRequest()->getCookie( 'changeslist-state' );
1688  $collapsedClass = $collapsedState === 'collapsed' ? ' mw-collapsed' : '';
1689 
1690  $legend =
1691  '<div class="mw-changeslist-legend mw-collapsible' . $collapsedClass . '">' .
1692  $legendHeading .
1693  '<div class="mw-collapsible-content">' . $legend . '</div>' .
1694  '</div>';
1695 
1696  return $legend;
1697  }
1698 
1702  protected function addModules() {
1703  $out = $this->getOutput();
1704  // Styles and behavior for the legend box (see makeLegend())
1705  $out->addModuleStyles( [
1706  'mediawiki.interface.helpers.styles',
1707  'mediawiki.special.changeslist.legend',
1708  'mediawiki.special.changeslist',
1709  ] );
1710  $out->addModules( 'mediawiki.special.changeslist.legend.js' );
1711 
1712  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
1713  $out->addModules( 'mediawiki.rcfilters.filters.ui' );
1714  $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
1715  }
1716  }
1717 
1718  protected function getGroupName() {
1719  return 'changes';
1720  }
1721 
1738  public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
1739  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
1740  ) {
1741  global $wgLearnerEdits,
1745 
1746  $LEVEL_COUNT = 5;
1747 
1748  // If all levels are selected, don't filter
1749  if ( count( $selectedExpLevels ) === $LEVEL_COUNT ) {
1750  return;
1751  }
1752 
1753  // both 'registered' and 'unregistered', experience levels, if any, are included in 'registered'
1754  if (
1755  in_array( 'registered', $selectedExpLevels ) &&
1756  in_array( 'unregistered', $selectedExpLevels )
1757  ) {
1758  return;
1759  }
1760 
1761  $actorMigration = ActorMigration::newMigration();
1762  $actorQuery = $actorMigration->getJoin( 'rc_user' );
1763  $tables += $actorQuery['tables'];
1764  $join_conds += $actorQuery['joins'];
1765 
1766  // 'registered' but not 'unregistered', experience levels, if any, are included in 'registered'
1767  if (
1768  in_array( 'registered', $selectedExpLevels ) &&
1769  !in_array( 'unregistered', $selectedExpLevels )
1770  ) {
1771  $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1772  return;
1773  }
1774 
1775  if ( $selectedExpLevels === [ 'unregistered' ] ) {
1776  $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1777  return;
1778  }
1779 
1780  $tables[] = 'user';
1781  $join_conds['user'] = [ 'LEFT JOIN', $actorQuery['fields']['rc_user'] . ' = user_id' ];
1782 
1783  if ( $now === 0 ) {
1784  $now = time();
1785  }
1786  $secondsPerDay = 86400;
1787  $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
1788  $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
1789 
1790  $aboveNewcomer = $dbr->makeList(
1791  [
1792  'user_editcount >= ' . intval( $wgLearnerEdits ),
1793  'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ),
1794  ],
1796  );
1797 
1798  $aboveLearner = $dbr->makeList(
1799  [
1800  'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
1801  'user_registration <= ' .
1802  $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ),
1803  ],
1805  );
1806 
1807  $conditions = [];
1808 
1809  if ( in_array( 'unregistered', $selectedExpLevels ) ) {
1810  $selectedExpLevels = array_diff( $selectedExpLevels, [ 'unregistered' ] );
1811  $conditions[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1812  }
1813 
1814  if ( $selectedExpLevels === [ 'newcomer' ] ) {
1815  $conditions[] = "NOT ( $aboveNewcomer )";
1816  } elseif ( $selectedExpLevels === [ 'learner' ] ) {
1817  $conditions[] = $dbr->makeList(
1818  [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
1820  );
1821  } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
1822  $conditions[] = $aboveLearner;
1823  } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
1824  $conditions[] = "NOT ( $aboveLearner )";
1825  } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
1826  $conditions[] = $dbr->makeList(
1827  [ "NOT ( $aboveNewcomer )", $aboveLearner ],
1829  );
1830  } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
1831  $conditions[] = $aboveNewcomer;
1832  } elseif ( $selectedExpLevels === [ 'experienced', 'learner', 'newcomer' ] ) {
1833  $conditions[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1834  }
1835 
1836  if ( count( $conditions ) > 1 ) {
1837  $conds[] = $dbr->makeList( $conditions, IDatabase::LIST_OR );
1838  } elseif ( count( $conditions ) === 1 ) {
1839  $conds[] = reset( $conditions );
1840  }
1841  }
1842 
1848  public function isStructuredFilterUiEnabled() {
1849  if ( $this->getRequest()->getBool( 'rcfilters' ) ) {
1850  return true;
1851  }
1852 
1853  return static::checkStructuredFilterUiEnabled( $this->getUser() );
1854  }
1855 
1863  public static function checkStructuredFilterUiEnabled( $user ) {
1864  if ( $user instanceof Config ) {
1865  wfDeprecated( __METHOD__ . ' with Config argument', '1.34' );
1866  $user = func_get_arg( 1 );
1867  }
1868  return !$user->getOption( 'rcenhancedfilters-disable' );
1869  }
1870 
1878  public function getDefaultLimit() {
1879  return $this->getUser()->getIntOption( static::$limitPreferenceName );
1880  }
1881 
1890  public function getDefaultDays() {
1891  return floatval( $this->getUser()->getOption( static::$daysPreferenceName ) );
1892  }
1893 }
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))
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
Definition: ChangeTags.php:732
getFilterGroup( $groupName)
Gets a specified ChangesListFilterGroup by name.
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
const RC_CATEGORIZE
Definition: Defines.php:142
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
Definition: hooks.txt:2633
const FLOAT
Float type, maps guessType() to WebRequest::getFloat()
Definition: FormOptions.php:48
doHeader( $opts, $numRows)
Set the text to be displayed above the changes.
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:1585
const SRC_CATEGORIZE
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:232
getContext()
Gets the context this SpecialPage is executed in.
webOutput( $rows, $opts)
Send output to the OutputPage object, only called if not used feeds.
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
areFiltersInConflict()
Check if filters are in conflict and guaranteed to return no results.
const TAG_DESC_CHARACTER_LIMIT
Maximum length of a tag description in UTF-8 characters.
including( $x=null)
Whether the special page is being evaluated via transclusion.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static truncateTagDescription( $tag, $length, IContextSource $context)
Get truncated message for the tag&#39;s long description.
Definition: ChangeTags.php:198
outputChangesList( $rows, $opts)
Build and output the actual changes list.
replaceOldOptions(FormOptions $opts)
Replace old options with their structured UI equivalents.
$filterGroupDefinitions
Definition information for the filters and their groups.
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
Definition: globals.txt:10
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing &#39;/&#39;...
Definition: Html.php:252
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
outputFeedLinks()
Output feed links.
getDefaultLimit()
Get the default value of the number of changes to display when loading the result set...
$value
static string $daysPreferenceName
Preference name for &#39;days&#39;.
reset( $name)
Delete the option value.
static string $limitPreferenceName
Preference name for &#39;limit&#39;.
static tagDescription( $tag, MessageLocalizer $context)
Get a short description for a tag.
Definition: ChangeTags.php:148
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
registerFiltersFromDefinitions(array $definition)
Register filters from a definition object.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the change_tag_def table of the database.
getOutput()
Get the OutputPage being used for this instance.
setTopText(FormOptions $opts)
Send the text to be displayed before the options.
static string $savedQueriesPreferenceName
Preference name for saved queries.
getOptions()
Get the current FormOptions for this request.
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
validateIntBounds( $name, $min, $max)
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2217
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:1980
$batch
Definition: linkcache.txt:23
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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:780
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e.g.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const PRC_PATROLLED
Class for fixing stale WANObjectCache keys using a purge event source.
static stripAllTags( $html)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed, encoded as plain text.
Definition: Sanitizer.php:1995
__construct( $name, $restriction)
transformFilterDefinition(array $filterDefinition)
Transforms filter definition to prepare it for constructor.
static newMigration()
Static constructor.
Interface for configuration instances.
Definition: Config.php:28
const LIST_AND
Definition: Defines.php:39
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
$wgExperiencedUserEdits
Name of the external diff engine to use.
fixBackwardsCompatibilityOptions(FormOptions $opts)
Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards compatibility.
includeRcFiltersApp()
Include the modules and configuration for the RCFilters app.
Represents a filter group (used on ChangesListSpecialPage and descendants)
validateBounds( $name, $min, $max)
Constrain a numeric value for a given option to a given range.
static decode( $value, $assoc=false)
Decodes a JSON string.
Definition: FormatJson.php:174
static listSoftwareActivatedTags()
Lists those tags which core or extensions report as being "active".
getDefaultOptions()
Get a FormOptions object containing the default options.
webOutputHeader( $rowCount, $opts)
Send header output to the OutputPage object, only called if not using feeds.
$cache
Definition: mcc.php:33
static logException( $e, $catcher=self::CAUGHT_BY_OTHER)
Log an exception to the exception log (if enabled).
$params
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:316
getDB()
Return a IDatabase object for reading.
doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.
array $wgLearnerEdits
The following variables define 3 user experience levels:
static newExtraneousContext(Title $title, $request=[])
Create a new extraneous context.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:780
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
Definition: Sanitizer.php:1411
static string $collapsedPreferenceName
Preference name for collapsing the active filter display.
$filter
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:216
setBottomText(FormOptions $opts)
Send the text to be displayed after the options.
$wgExperiencedUserMemberSince
Name of the external diff engine to use.
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don&#39;t need a full Title object...
Definition: SpecialPage.php:83
filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now=0)
Filter on users&#39; experience levels; this will not be called if nothing is selected.
namespace and then decline to actually register it & $namespaces
Definition: hooks.txt:925
Represents a filter group with multiple string options.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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 modifiable & $code
Definition: hooks.txt:780
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
$wgLearnerMemberSince
Name of the external diff engine to use.
const INT
Integer type, maps guessType() to WebRequest::getInt()
Definition: FormOptions.php:45
const LIST_OR
Definition: Defines.php:42
const PRC_UNPATROLLED
$filterGroups
Filter groups, and their contained filters This is an associative array (with group name as key) of C...
validateOptions(FormOptions $opts)
Validate a FormOptions object generated by getDefaultOptions() with values already populated...
registerFilterGroup(ChangesListFilterGroup $group)
Register a structured changes list filter group.
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
outputNoResults()
Add the "no results" message to the output.
static checkStructuredFilterUiEnabled( $user)
Static method to check whether StructuredFilter UI is enabled for the given user. ...
Represents a hide-based boolean filter (used on ChangesListSpecialPage and descendants) ...
static getRcFiltersConfigVars(ResourceLoaderContext $context)
Get config vars to export with the mediawiki.rcfilters.filters.ui module.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
getRows()
Get the database result for this special page instance.
convertParamsForLink( $params)
Convert parameters values from true/false to 1/0 so they are not omitted by wfArrayToCgi() T38524...
isStructuredFilterUiEnabled()
Check whether the structured filter UI is enabled.
getName()
Get the name of this Special Page.
const NONE
Signifies that no options in the group are selected, meaning the group has no effect.
Special page which uses a ChangesList to show query results.
getStructuredFilterJsData()
Gets structured filter information needed by JS.
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
Overloads the relevant methods of the real ResultsWrapper so it doesn&#39;t go anywhere near an actual da...
getUser()
Shortcut to get the User executing this instance.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
const STRING
String type, maps guessType() to WebRequest::getText()
Definition: FormOptions.php:43
getConfig()
Shortcut to get main config object.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
getExtraOptions( $opts)
Get options to be displayed in a form.
msg( $key)
Wrapper around wfMessage that sets the current context.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2633
buildQuery(&$tables, &$fields, &$conds, &$query_options, &$join_conds, FormOptions $opts)
Sets appropriate tables, fields, conditions, etc.
considerActionsForDefaultSavedQuery( $subpage)
Check whether or not the page should load defaults, and if so, whether a default saved query is relev...
MediaWiki Logger LoggerFactory implements a PSR [0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
Definition: logger.txt:5
Error thrown when a query times out.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new recentchanges object...
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
$messages
const RC_NEW
Definition: Defines.php:139
getChangedValues()
Return options modified as an array ( name => value )
const DB_REPLICA
Definition: defines.php:25
getFilterGroups()
Gets the currently registered filters groups.
getRequest()
Get the WebRequest being used for this instance.
registerFilters()
Register all filters and their groups (including those from hooks), plus handle conflicts and default...
fixContradictoryOptions(FormOptions $opts)
Fix invalid options by resetting pairs that should never appear together.
makeLegend()
Return the legend displayed within the fieldset.
getDefaultDays()
Get the default value of the number of days to display when loading the result set.
If the group is active, any unchecked filters will translate to hide parameters in the URL...
const PRC_AUTOPATROLLED
const NS_USER_TALK
Definition: Defines.php:63
setup( $parameters)
Register all the filters, including legacy hook-driven ones.
static getChangeTagList(ResourceLoaderContext $context)
Fetch the change tags list for the front end.
outputTimeout()
Add the "timeout" message to the output.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getPageTitle( $subpage=false)
Get a self-referential title object.
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1473
const RC_EDIT
Definition: Defines.php:138
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
addModules()
Add page-specific modules.
const RC_LOG
Definition: Defines.php:140
fetchOptionsFromRequest( $opts)
Fetch values for a FormOptions object from the WebRequest associated with this instance.
Object passed around to modules which contains information about the state of a specific loader reque...
static tagUsageStatistics()
Returns a map of any tags used on the wiki to number of edits tagged with them, ordered descending by...
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:319