MediaWiki  master
ChangesListSpecialPage.php
Go to the documentation of this file.
1 <?php
30 
37 abstract class ChangesListSpecialPage extends SpecialPage {
42  private const TAG_DESC_CHARACTER_LIMIT = 120;
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  $this->getHookRunner()->onSpecialWatchlistGetNonRevisionTypes( $nonRevisionTypes );
115 
116  $this->filterGroupDefinitions = [
117  [
118  'name' => 'registration',
119  'title' => 'rcfilters-filtergroup-registration',
120  'class' => ChangesListBooleanFilterGroup::class,
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',
163  'class' => ChangesListStringOptionsFilterGroup::class,
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',
225  'class' => ChangesListBooleanFilterGroup::class,
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',
273  'class' => ChangesListBooleanFilterGroup::class,
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',
316  'class' => ChangesListBooleanFilterGroup::class,
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',
358  'class' => ChangesListBooleanFilterGroup::class,
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',
408  'class' => ChangesListBooleanFilterGroup::class,
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',
471  'class' => ChangesListBooleanFilterGroup::class,
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',
504  'class' => ChangesListStringOptionsFilterGroup::class,
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 
774  protected function getLinkDays() {
775  $linkDays = $this->getConfig()->get( 'RCLinkDays' );
776  $filterByAge = $this->getConfig()->get( 'RCFilterByAge' );
777  $maxAge = $this->getConfig()->get( 'RCMaxAge' );
778  if ( $filterByAge ) {
779  // Trim it to only links which are within $wgRCMaxAge.
780  // Note that we allow one link higher than the max for things like
781  // "age 56 days" being accessible through the "60 days" link.
782  sort( $linkDays );
783 
784  $maxAgeDays = $maxAge / ( 3600 * 24 );
785  foreach ( $linkDays as $i => $days ) {
786  if ( $days >= $maxAgeDays ) {
787  array_splice( $linkDays, $i + 1 );
788  break;
789  }
790  }
791  }
792 
793  return $linkDays;
794  }
795 
802  protected function includeRcFiltersApp() {
803  $out = $this->getOutput();
804  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
805  $jsData = $this->getStructuredFilterJsData();
806  $messages = [];
807  foreach ( $jsData['messageKeys'] as $key ) {
808  $messages[$key] = $this->msg( $key )->plain();
809  }
810 
811  $out->addBodyClasses( 'mw-rcfilters-enabled' );
812  $collapsed = $this->getUser()->getBoolOption( static::$collapsedPreferenceName );
813  if ( $collapsed ) {
814  $out->addBodyClasses( 'mw-rcfilters-collapsed' );
815  }
816 
817  // These config and message exports should be moved into a ResourceLoader data module (T201574)
818  $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
819  $out->addJsConfigVars( 'wgStructuredChangeFiltersMessages', $messages );
820  $out->addJsConfigVars( 'wgStructuredChangeFiltersCollapsedState', $collapsed );
821 
822  $out->addJsConfigVars(
823  'StructuredChangeFiltersDisplayConfig',
824  [
825  'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
826  'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
827  'limitDefault' => $this->getDefaultLimit(),
828  'daysArray' => $this->getLinkDays(),
829  'daysDefault' => $this->getDefaultDays(),
830  ]
831  );
832 
833  $out->addJsConfigVars(
834  'wgStructuredChangeFiltersSavedQueriesPreferenceName',
835  static::$savedQueriesPreferenceName
836  );
837  $out->addJsConfigVars(
838  'wgStructuredChangeFiltersLimitPreferenceName',
839  static::$limitPreferenceName
840  );
841  $out->addJsConfigVars(
842  'wgStructuredChangeFiltersDaysPreferenceName',
843  static::$daysPreferenceName
844  );
845  $out->addJsConfigVars(
846  'wgStructuredChangeFiltersCollapsedPreferenceName',
847  static::$collapsedPreferenceName
848  );
849  } else {
850  $out->addBodyClasses( 'mw-rcfilters-disabled' );
851  }
852  }
853 
863  return [
864  // Reduce version computation by avoiding Message parsing
865  'RCFiltersChangeTags' => self::getChangeTagListSummary( $context ),
866  'StructuredChangeFiltersEditWatchlistUrl' =>
867  SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
868  ];
869  }
870 
879  return [
880  'RCFiltersChangeTags' => self::getChangeTagList( $context ),
881  'StructuredChangeFiltersEditWatchlistUrl' =>
882  SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
883  ];
884  }
885 
907  $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
908  return $cache->getWithSetCallback(
909  $cache->makeKey( 'ChangesListSpecialPage-changeTagListSummary', $context->getLanguage() ),
910  WANObjectCache::TTL_DAY,
911  function ( $oldValue, &$ttl, array &$setOpts ) use ( $context ) {
912  $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
913  $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
914 
915  $tagStats = ChangeTags::tagUsageStatistics();
916  $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
917 
918  $result = [];
919  foreach ( $tagHitCounts as $tagName => $hits ) {
920  if (
921  (
922  // Only get active tags
923  isset( $explicitlyDefinedTags[ $tagName ] ) ||
924  isset( $softwareActivatedTags[ $tagName ] )
925  ) &&
926  // Only get tags with more than 0 hits
927  $hits > 0
928  ) {
929  $labelMsg = ChangeTags::tagShortDescriptionMessage( $tagName, $context );
930  if ( $labelMsg === false ) {
931  // Tag is hidden, skip it
932  continue;
933  }
934  $descriptionMsg = ChangeTags::tagLongDescriptionMessage( $tagName, $context );
935  $result[] = [
936  'name' => $tagName,
937  'labelMsg' => $labelMsg,
938  'label' => $labelMsg->plain(),
939  'descriptionMsg' => $descriptionMsg,
940  'description' => $descriptionMsg ? $descriptionMsg->plain() : '',
941  'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
942  'hits' => $hits,
943  ];
944  }
945  }
946  return $result;
947  }
948  );
949  }
950 
964  protected static function getChangeTagList( ResourceLoaderContext $context ) {
966  $language = MediaWikiServices::getInstance()->getLanguageFactory()
967  ->getLanguage( $context->getLanguage() );
968  foreach ( $tags as &$tagInfo ) {
969  $tagInfo['label'] = Sanitizer::stripAllTags( $tagInfo['labelMsg']->parse() );
970  $tagInfo['description'] = $tagInfo['descriptionMsg'] ?
971  $language->truncateForVisual(
972  Sanitizer::stripAllTags( $tagInfo['descriptionMsg']->parse() ),
973  self::TAG_DESC_CHARACTER_LIMIT
974  ) :
975  '';
976  unset( $tagInfo['labelMsg'] );
977  unset( $tagInfo['descriptionMsg'] );
978  }
979 
980  // Instead of sorting by hit count (disabled for now), sort by display name
981  usort( $tags, function ( $a, $b ) {
982  return strcasecmp( $a['label'], $b['label'] );
983  } );
984  return $tags;
985  }
986 
990  protected function outputNoResults() {
991  $this->getOutput()->addHTML(
992  '<div class="mw-changeslist-empty">' .
993  $this->msg( 'recentchanges-noresult' )->parse() .
994  '</div>'
995  );
996  }
997 
1001  protected function outputTimeout() {
1002  $this->getOutput()->addHTML(
1003  '<div class="mw-changeslist-empty mw-changeslist-timeout">' .
1004  $this->msg( 'recentchanges-timeout' )->parse() .
1005  '</div>'
1006  );
1007  }
1008 
1014  public function getRows() {
1015  $opts = $this->getOptions();
1016 
1017  $tables = [];
1018  $fields = [];
1019  $conds = [];
1020  $query_options = [];
1021  $join_conds = [];
1022  $this->buildQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
1023 
1024  return $this->doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
1025  }
1026 
1032  public function getOptions() {
1033  if ( $this->rcOptions === null ) {
1034  $this->rcOptions = $this->setup( $this->rcSubpage );
1035  }
1036 
1037  return $this->rcOptions;
1038  }
1039 
1049  protected function registerFilters() {
1050  $this->registerFiltersFromDefinitions( $this->filterGroupDefinitions );
1051 
1052  // Make sure this is not being transcluded (we don't want to show this
1053  // information to all users just because the user that saves the edit can
1054  // patrol or is logged in)
1055  if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
1056  $this->registerFiltersFromDefinitions( $this->legacyReviewStatusFilterGroupDefinition );
1057  $this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition );
1058  }
1059 
1060  $changeTypeGroup = $this->getFilterGroup( 'changeType' );
1061 
1062  if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
1063  $transformedHideCategorizationDef = $this->transformFilterDefinition(
1064  $this->hideCategorizationFilterDefinition
1065  );
1066 
1067  $transformedHideCategorizationDef['group'] = $changeTypeGroup;
1068 
1069  $hideCategorization = new ChangesListBooleanFilter(
1070  $transformedHideCategorizationDef
1071  );
1072  }
1073 
1074  $this->getHookRunner()->onChangesListSpecialPageStructuredFilters( $this );
1075 
1076  $this->registerFiltersFromDefinitions( [] );
1077 
1078  $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' );
1079  $registered = $userExperienceLevel->getFilter( 'registered' );
1080  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'newcomer' ) );
1081  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'learner' ) );
1082  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'experienced' ) );
1083 
1084  $categoryFilter = $changeTypeGroup->getFilter( 'hidecategorization' );
1085  $logactionsFilter = $changeTypeGroup->getFilter( 'hidelog' );
1086  $pagecreationFilter = $changeTypeGroup->getFilter( 'hidenewpages' );
1087 
1088  $significanceTypeGroup = $this->getFilterGroup( 'significance' );
1089  $hideMinorFilter = $significanceTypeGroup->getFilter( 'hideminor' );
1090 
1091  // categoryFilter is conditional; see registerFilters
1092  if ( $categoryFilter !== null ) {
1093  $hideMinorFilter->conflictsWith(
1094  $categoryFilter,
1095  'rcfilters-hideminor-conflicts-typeofchange-global',
1096  'rcfilters-hideminor-conflicts-typeofchange',
1097  'rcfilters-typeofchange-conflicts-hideminor'
1098  );
1099  }
1100  $hideMinorFilter->conflictsWith(
1101  $logactionsFilter,
1102  'rcfilters-hideminor-conflicts-typeofchange-global',
1103  'rcfilters-hideminor-conflicts-typeofchange',
1104  'rcfilters-typeofchange-conflicts-hideminor'
1105  );
1106  $hideMinorFilter->conflictsWith(
1107  $pagecreationFilter,
1108  'rcfilters-hideminor-conflicts-typeofchange-global',
1109  'rcfilters-hideminor-conflicts-typeofchange',
1110  'rcfilters-typeofchange-conflicts-hideminor'
1111  );
1112  }
1113 
1123  protected function transformFilterDefinition( array $filterDefinition ) {
1124  return $filterDefinition;
1125  }
1126 
1137  protected function registerFiltersFromDefinitions( array $definition ) {
1138  $autoFillPriority = -1;
1139  foreach ( $definition as $groupDefinition ) {
1140  if ( !isset( $groupDefinition['priority'] ) ) {
1141  $groupDefinition['priority'] = $autoFillPriority;
1142  } else {
1143  // If it's explicitly specified, start over the auto-fill
1144  $autoFillPriority = $groupDefinition['priority'];
1145  }
1146 
1147  $autoFillPriority--;
1148 
1149  $className = $groupDefinition['class'];
1150  unset( $groupDefinition['class'] );
1151 
1152  foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
1153  $filterDefinition = $this->transformFilterDefinition( $filterDefinition );
1154  }
1155 
1156  $this->registerFilterGroup( new $className( $groupDefinition ) );
1157  }
1158  }
1159 
1163  protected function getLegacyShowHideFilters() {
1164  $filters = [];
1165  foreach ( $this->filterGroups as $group ) {
1166  if ( $group instanceof ChangesListBooleanFilterGroup ) {
1167  foreach ( $group->getFilters() as $key => $filter ) {
1168  if ( $filter->displaysOnUnstructuredUi() ) {
1169  $filters[ $key ] = $filter;
1170  }
1171  }
1172  }
1173  }
1174  return $filters;
1175  }
1176 
1185  public function setup( $parameters ) {
1186  $this->registerFilters();
1187 
1188  $opts = $this->getDefaultOptions();
1189 
1190  $opts = $this->fetchOptionsFromRequest( $opts );
1191 
1192  // Give precedence to subpage syntax
1193  if ( $parameters !== null ) {
1194  $this->parseParameters( $parameters, $opts );
1195  }
1196 
1197  $this->validateOptions( $opts );
1198 
1199  return $opts;
1200  }
1201 
1211  public function getDefaultOptions() {
1212  $opts = new FormOptions();
1213  $structuredUI = $this->isStructuredFilterUiEnabled();
1214  // If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
1215  $useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
1216 
1218  foreach ( $this->filterGroups as $filterGroup ) {
1219  $filterGroup->addOptions( $opts, $useDefaults, $structuredUI );
1220  }
1221 
1222  $opts->add( 'namespace', '', FormOptions::STRING );
1223  $opts->add( 'invert', false );
1224  $opts->add( 'associated', false );
1225  $opts->add( 'urlversion', 1 );
1226  $opts->add( 'tagfilter', '' );
1227 
1228  $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT );
1229  $opts->add( 'limit', $this->getDefaultLimit(), FormOptions::INT );
1230 
1231  $opts->add( 'from', '' );
1232 
1233  return $opts;
1234  }
1235 
1241  public function registerFilterGroup( ChangesListFilterGroup $group ) {
1242  $groupName = $group->getName();
1243 
1244  $this->filterGroups[$groupName] = $group;
1245  }
1246 
1252  protected function getFilterGroups() {
1253  return $this->filterGroups;
1254  }
1255 
1263  public function getFilterGroup( $groupName ) {
1264  return $this->filterGroups[$groupName] ?? null;
1265  }
1266 
1267  // Currently, this intentionally only includes filters that display
1268  // in the structured UI. This can be changed easily, though, if we want
1269  // to include data on filters that use the unstructured UI. messageKeys is a
1270  // special top-level value, with the value being an array of the message keys to
1271  // send to the client.
1272 
1280  public function getStructuredFilterJsData() {
1281  $output = [
1282  'groups' => [],
1283  'messageKeys' => [],
1284  ];
1285 
1286  usort( $this->filterGroups, function ( $a, $b ) {
1287  return $b->getPriority() <=> $a->getPriority();
1288  } );
1289 
1290  foreach ( $this->filterGroups as $groupName => $group ) {
1291  $groupOutput = $group->getJsData();
1292  if ( $groupOutput !== null ) {
1293  $output['messageKeys'] = array_merge(
1294  $output['messageKeys'],
1295  $groupOutput['messageKeys']
1296  );
1297 
1298  unset( $groupOutput['messageKeys'] );
1299  $output['groups'][] = $groupOutput;
1300  }
1301  }
1302 
1303  return $output;
1304  }
1305 
1314  protected function fetchOptionsFromRequest( $opts ) {
1315  $opts->fetchValuesFromRequest( $this->getRequest() );
1316 
1317  return $opts;
1318  }
1319 
1326  public function parseParameters( $par, FormOptions $opts ) {
1327  $stringParameterNameSet = [];
1328  $hideParameterNameSet = [];
1329 
1330  // URL parameters can be per-group, like 'userExpLevel',
1331  // or per-filter, like 'hideminor'.
1332 
1333  foreach ( $this->filterGroups as $filterGroup ) {
1334  if ( $filterGroup instanceof ChangesListStringOptionsFilterGroup ) {
1335  $stringParameterNameSet[$filterGroup->getName()] = true;
1336  } elseif ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1337  foreach ( $filterGroup->getFilters() as $filter ) {
1338  $hideParameterNameSet[$filter->getName()] = true;
1339  }
1340  }
1341  }
1342 
1343  $bits = preg_split( '/\s*,\s*/', trim( $par ) );
1344  foreach ( $bits as $bit ) {
1345  $m = [];
1346  if ( isset( $hideParameterNameSet[$bit] ) ) {
1347  // hidefoo => hidefoo=true
1348  $opts[$bit] = true;
1349  } elseif ( isset( $hideParameterNameSet["hide$bit"] ) ) {
1350  // foo => hidefoo=false
1351  $opts["hide$bit"] = false;
1352  } elseif ( preg_match( '/^(.*)=(.*)$/', $bit, $m ) ) {
1353  if ( isset( $stringParameterNameSet[$m[1]] ) ) {
1354  $opts[$m[1]] = $m[2];
1355  }
1356  }
1357  }
1358  }
1359 
1365  public function validateOptions( FormOptions $opts ) {
1366  $isContradictory = $this->fixContradictoryOptions( $opts );
1367  $isReplaced = $this->replaceOldOptions( $opts );
1368 
1369  if ( $isContradictory || $isReplaced ) {
1370  $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
1371  $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
1372  }
1373 
1374  $opts->validateIntBounds( 'limit', 0, 5000 );
1375  $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
1376  }
1377 
1384  private function fixContradictoryOptions( FormOptions $opts ) {
1385  $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
1386 
1387  foreach ( $this->filterGroups as $filterGroup ) {
1388  if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1389  $filters = $filterGroup->getFilters();
1390 
1391  if ( count( $filters ) === 1 ) {
1392  // legacy boolean filters should not be considered
1393  continue;
1394  }
1395 
1396  $allInGroupEnabled = array_reduce(
1397  $filters,
1398  function ( $carry, $filter ) use ( $opts ) {
1399  return $carry && $opts[ $filter->getName() ];
1400  },
1401  /* initialValue */ count( $filters ) > 0
1402  );
1403 
1404  if ( $allInGroupEnabled ) {
1405  foreach ( $filters as $filter ) {
1406  $opts[ $filter->getName() ] = false;
1407  }
1408 
1409  $fixed = true;
1410  }
1411  }
1412  }
1413 
1414  return $fixed;
1415  }
1416 
1426  private function fixBackwardsCompatibilityOptions( FormOptions $opts ) {
1427  if ( $opts['hideanons'] && $opts['hideliu'] ) {
1428  $opts->reset( 'hideanons' );
1429  if ( !$opts['hidebots'] ) {
1430  $opts->reset( 'hideliu' );
1431  $opts['hidehumans'] = 1;
1432  }
1433 
1434  return true;
1435  }
1436 
1437  return false;
1438  }
1439 
1446  public function replaceOldOptions( FormOptions $opts ) {
1447  if ( !$this->isStructuredFilterUiEnabled() ) {
1448  return false;
1449  }
1450 
1451  $changed = false;
1452 
1453  // At this point 'hideanons' and 'hideliu' cannot be both true,
1454  // because fixBackwardsCompatibilityOptions resets (at least) 'hideanons' in such case
1455  if ( $opts[ 'hideanons' ] ) {
1456  $opts->reset( 'hideanons' );
1457  $opts[ 'userExpLevel' ] = 'registered';
1458  $changed = true;
1459  }
1460 
1461  if ( $opts[ 'hideliu' ] ) {
1462  $opts->reset( 'hideliu' );
1463  $opts[ 'userExpLevel' ] = 'unregistered';
1464  $changed = true;
1465  }
1466 
1467  if ( $this->getFilterGroup( 'legacyReviewStatus' ) ) {
1468  if ( $opts[ 'hidepatrolled' ] ) {
1469  $opts->reset( 'hidepatrolled' );
1470  $opts[ 'reviewStatus' ] = 'unpatrolled';
1471  $changed = true;
1472  }
1473 
1474  if ( $opts[ 'hideunpatrolled' ] ) {
1475  $opts->reset( 'hideunpatrolled' );
1476  $opts[ 'reviewStatus' ] = implode(
1478  [ 'manual', 'auto' ]
1479  );
1480  $changed = true;
1481  }
1482  }
1483 
1484  return $changed;
1485  }
1486 
1495  protected function convertParamsForLink( $params ) {
1496  foreach ( $params as &$value ) {
1497  if ( $value === false ) {
1498  $value = '0';
1499  }
1500  }
1501  unset( $value );
1502  return $params;
1503  }
1504 
1516  protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
1517  &$join_conds, FormOptions $opts
1518  ) {
1519  $dbr = $this->getDB();
1520  $isStructuredUI = $this->isStructuredFilterUiEnabled();
1521 
1523  foreach ( $this->filterGroups as $filterGroup ) {
1524  $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1525  $query_options, $join_conds, $opts, $isStructuredUI );
1526  }
1527 
1528  // Namespace filtering
1529  if ( $opts[ 'namespace' ] !== '' ) {
1530  $namespaces = explode( ';', $opts[ 'namespace' ] );
1531 
1532  $namespaces = $this->expandSymbolicNamespaceFilters( $namespaces );
1533 
1534  if ( $opts[ 'associated' ] ) {
1535  $namespaceInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
1536  $associatedNamespaces = array_map(
1537  function ( $ns ) use ( $namespaceInfo ){
1538  return $namespaceInfo->getAssociated( $ns );
1539  },
1540  array_filter(
1541  $namespaces,
1542  function ( $ns ) use ( $namespaceInfo ) {
1543  return $namespaceInfo->hasTalkNamespace( $ns );
1544  }
1545  )
1546  );
1547  $namespaces = array_unique( array_merge( $namespaces, $associatedNamespaces ) );
1548  }
1549 
1550  if ( count( $namespaces ) === 1 ) {
1551  $operator = $opts[ 'invert' ] ? '!=' : '=';
1552  $value = $dbr->addQuotes( reset( $namespaces ) );
1553  } else {
1554  $operator = $opts[ 'invert' ] ? 'NOT IN' : 'IN';
1555  sort( $namespaces );
1556  $value = '(' . $dbr->makeList( $namespaces ) . ')';
1557  }
1558  $conds[] = "rc_namespace $operator $value";
1559  }
1560 
1561  // Calculate cutoff
1562  $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
1563  $cutoff = $dbr->timestamp( $cutoff_unixtime );
1564 
1565  $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
1566  if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
1567  $cutoff = $dbr->timestamp( $opts['from'] );
1568  } else {
1569  $opts->reset( 'from' );
1570  }
1571 
1572  $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
1573  }
1574 
1586  protected function doMainQuery( $tables, $fields, $conds,
1587  $query_options, $join_conds, FormOptions $opts
1588  ) {
1589  $rcQuery = RecentChange::getQueryInfo();
1590  $tables = array_merge( $tables, $rcQuery['tables'] );
1591  $fields = array_merge( $rcQuery['fields'], $fields );
1592  $join_conds = array_merge( $join_conds, $rcQuery['joins'] );
1593 
1595  $tables,
1596  $fields,
1597  $conds,
1598  $join_conds,
1599  $query_options,
1600  ''
1601  );
1602 
1603  if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
1604  $opts )
1605  ) {
1606  return false;
1607  }
1608 
1609  $dbr = $this->getDB();
1610 
1611  return $dbr->select(
1612  $tables,
1613  $fields,
1614  $conds,
1615  __METHOD__,
1616  $query_options,
1617  $join_conds
1618  );
1619  }
1620 
1621  protected function runMainQueryHook( &$tables, &$fields, &$conds,
1622  &$query_options, &$join_conds, $opts
1623  ) {
1624  return $this->getHookRunner()->onChangesListSpecialPageQuery(
1625  $this->getName(), $tables, $fields, $conds, $query_options, $join_conds, $opts );
1626  }
1627 
1633  protected function getDB() {
1634  return wfGetDB( DB_REPLICA );
1635  }
1636 
1643  private function webOutputHeader( $rowCount, $opts ) {
1644  if ( !$this->including() ) {
1645  $this->outputFeedLinks();
1646  $this->doHeader( $opts, $rowCount );
1647  }
1648  }
1649 
1656  public function webOutput( $rows, $opts ) {
1657  $this->webOutputHeader( $rows->numRows(), $opts );
1658 
1659  $this->outputChangesList( $rows, $opts );
1660  }
1661 
1665  public function outputFeedLinks() {
1666  // nothing by default
1667  }
1668 
1675  abstract public function outputChangesList( $rows, $opts );
1676 
1683  public function doHeader( $opts, $numRows ) {
1684  $this->setTopText( $opts );
1685 
1686  // @todo Lots of stuff should be done here.
1687 
1688  $this->setBottomText( $opts );
1689  }
1690 
1698  public function setTopText( FormOptions $opts ) {
1699  // nothing by default
1700  }
1701 
1709  public function setBottomText( FormOptions $opts ) {
1710  // nothing by default
1711  }
1712 
1722  public function getExtraOptions( $opts ) {
1723  return [];
1724  }
1725 
1731  public function makeLegend() {
1732  $context = $this->getContext();
1733  $user = $context->getUser();
1734  # The legend showing what the letters and stuff mean
1735  $legend = Html::openElement( 'dl' ) . "\n";
1736  # Iterates through them and gets the messages for both letter and tooltip
1737  $legendItems = $context->getConfig()->get( 'RecentChangesFlags' );
1738  if ( !( $user->useRCPatrol() || $user->useNPPatrol() ) ) {
1739  unset( $legendItems['unpatrolled'] );
1740  }
1741  foreach ( $legendItems as $key => $item ) { # generate items of the legend
1742  $label = $item['legend'] ?? $item['title'];
1743  $letter = $item['letter'];
1744  $cssClass = $item['class'] ?? $key;
1745 
1746  $legend .= Html::element( 'dt',
1747  [ 'class' => $cssClass ], $context->msg( $letter )->text()
1748  ) . "\n" .
1749  Html::rawElement( 'dd',
1750  [ 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ],
1751  $context->msg( $label )->parse()
1752  ) . "\n";
1753  }
1754  # (+-123)
1755  $legend .= Html::rawElement( 'dt',
1756  [ 'class' => 'mw-plusminus-pos' ],
1757  $context->msg( 'recentchanges-legend-plusminus' )->parse()
1758  ) . "\n";
1759  $legend .= Html::element(
1760  'dd',
1761  [ 'class' => 'mw-changeslist-legend-plusminus' ],
1762  $context->msg( 'recentchanges-label-plusminus' )->text()
1763  ) . "\n";
1764  $legend .= Html::closeElement( 'dl' ) . "\n";
1765 
1766  $legendHeading = $this->isStructuredFilterUiEnabled() ?
1767  $context->msg( 'rcfilters-legend-heading' )->parse() :
1768  $context->msg( 'recentchanges-legend-heading' )->parse();
1769 
1770  # Collapsible
1771  $collapsedState = $this->getRequest()->getCookie( 'changeslist-state' );
1772  $collapsedClass = $collapsedState === 'collapsed' ? ' mw-collapsed' : '';
1773 
1774  $legend =
1775  '<div class="mw-changeslist-legend mw-collapsible' . $collapsedClass . '">' .
1776  $legendHeading .
1777  '<div class="mw-collapsible-content">' . $legend . '</div>' .
1778  '</div>';
1779 
1780  return $legend;
1781  }
1782 
1786  protected function addModules() {
1787  $out = $this->getOutput();
1788  // Styles and behavior for the legend box (see makeLegend())
1789  $out->addModuleStyles( [
1790  'mediawiki.interface.helpers.styles',
1791  'mediawiki.special.changeslist.legend',
1792  'mediawiki.special.changeslist',
1793  ] );
1794  $out->addModules( 'mediawiki.special.changeslist.legend.js' );
1795 
1796  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
1797  $out->addModules( 'mediawiki.rcfilters.filters.ui' );
1798  $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
1799  }
1800  }
1801 
1802  protected function getGroupName() {
1803  return 'changes';
1804  }
1805 
1822  public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
1823  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
1824  ) {
1825  global $wgLearnerEdits,
1829 
1830  $LEVEL_COUNT = 5;
1831 
1832  // If all levels are selected, don't filter
1833  if ( count( $selectedExpLevels ) === $LEVEL_COUNT ) {
1834  return;
1835  }
1836 
1837  // both 'registered' and 'unregistered', experience levels, if any, are included in 'registered'
1838  if (
1839  in_array( 'registered', $selectedExpLevels ) &&
1840  in_array( 'unregistered', $selectedExpLevels )
1841  ) {
1842  return;
1843  }
1844 
1845  $actorMigration = ActorMigration::newMigration();
1846  $actorQuery = $actorMigration->getJoin( 'rc_user' );
1847  $tables += $actorQuery['tables'];
1848  $join_conds += $actorQuery['joins'];
1849 
1850  // 'registered' but not 'unregistered', experience levels, if any, are included in 'registered'
1851  if (
1852  in_array( 'registered', $selectedExpLevels ) &&
1853  !in_array( 'unregistered', $selectedExpLevels )
1854  ) {
1855  $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1856  return;
1857  }
1858 
1859  if ( $selectedExpLevels === [ 'unregistered' ] ) {
1860  $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1861  return;
1862  }
1863 
1864  $tables[] = 'user';
1865  $join_conds['user'] = [ 'LEFT JOIN', $actorQuery['fields']['rc_user'] . ' = user_id' ];
1866 
1867  if ( $now === 0 ) {
1868  $now = time();
1869  }
1870  $secondsPerDay = 86400;
1871  $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
1872  $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
1873 
1874  $aboveNewcomer = $dbr->makeList(
1875  [
1876  'user_editcount >= ' . intval( $wgLearnerEdits ),
1877  'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ),
1878  ],
1880  );
1881 
1882  $aboveLearner = $dbr->makeList(
1883  [
1884  'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
1885  'user_registration <= ' .
1886  $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ),
1887  ],
1889  );
1890 
1891  $conditions = [];
1892 
1893  if ( in_array( 'unregistered', $selectedExpLevels ) ) {
1894  $selectedExpLevels = array_diff( $selectedExpLevels, [ 'unregistered' ] );
1895  $conditions[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1896  }
1897 
1898  if ( $selectedExpLevels === [ 'newcomer' ] ) {
1899  $conditions[] = "NOT ( $aboveNewcomer )";
1900  } elseif ( $selectedExpLevels === [ 'learner' ] ) {
1901  $conditions[] = $dbr->makeList(
1902  [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
1904  );
1905  } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
1906  $conditions[] = $aboveLearner;
1907  } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
1908  $conditions[] = "NOT ( $aboveLearner )";
1909  } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
1910  $conditions[] = $dbr->makeList(
1911  [ "NOT ( $aboveNewcomer )", $aboveLearner ],
1913  );
1914  } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
1915  $conditions[] = $aboveNewcomer;
1916  } elseif ( $selectedExpLevels === [ 'experienced', 'learner', 'newcomer' ] ) {
1917  $conditions[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1918  }
1919 
1920  if ( count( $conditions ) > 1 ) {
1921  $conds[] = $dbr->makeList( $conditions, IDatabase::LIST_OR );
1922  } elseif ( count( $conditions ) === 1 ) {
1923  $conds[] = reset( $conditions );
1924  }
1925  }
1926 
1932  public function isStructuredFilterUiEnabled() {
1933  if ( $this->getRequest()->getBool( 'rcfilters' ) ) {
1934  return true;
1935  }
1936 
1937  return static::checkStructuredFilterUiEnabled( $this->getUser() );
1938  }
1939 
1947  public static function checkStructuredFilterUiEnabled( $user ) {
1948  if ( $user instanceof Config ) {
1949  wfDeprecated( __METHOD__ . ' with Config argument', '1.34' );
1950  $user = func_get_arg( 1 );
1951  }
1952  return !$user->getOption( 'rcenhancedfilters-disable' );
1953  }
1954 
1962  public function getDefaultLimit() {
1963  return $this->getUser()->getIntOption( static::$limitPreferenceName );
1964  }
1965 
1974  public function getDefaultDays() {
1975  return floatval( $this->getUser()->getOption( static::$daysPreferenceName ) );
1976  }
1977 
1978  private function expandSymbolicNamespaceFilters( array $namespaces ) {
1979  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
1980  $symbolicFilters = [
1981  'all-contents' => $nsInfo->getSubjectNamespaces(),
1982  'all-discussions' => $nsInfo->getTalkNamespaces(),
1983  ];
1984  $additionalNamespaces = [];
1985  foreach ( $symbolicFilters as $name => $values ) {
1986  if ( in_array( $name, $namespaces ) ) {
1987  $additionalNamespaces = array_merge( $additionalNamespaces, $values );
1988  }
1989  }
1990  $namespaces = array_diff( $namespaces, array_keys( $symbolicFilters ) );
1991  $namespaces = array_merge( $namespaces, $additionalNamespaces );
1992  return array_unique( $namespaces );
1993  }
1994 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:669
ResourceLoaderContext
Context object that contains information about the state of a specific ResourceLoader web request.
Definition: ResourceLoaderContext.php:33
RecentChange\getQueryInfo
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new recentchanges object.
Definition: RecentChange.php:234
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:800
ChangesListFilterGroup\getName
getName()
Definition: ChangesListFilterGroup.php:282
ChangesListSpecialPage\getExtraOptions
getExtraOptions( $opts)
Get options to be displayed in a form.
Definition: ChangesListSpecialPage.php:1722
ChangesListSpecialPage\__construct
__construct( $name, $restriction)
Definition: ChangesListSpecialPage.php:110
ChangesListSpecialPage\considerActionsForDefaultSavedQuery
considerActionsForDefaultSavedQuery( $subpage)
Check whether or not the page should load defaults, and if so, whether a default saved query is relev...
Definition: ChangesListSpecialPage.php:704
Sanitizer\stripAllTags
static stripAllTags( $html)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed,...
Definition: Sanitizer.php:1856
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:35
FormOptions\FLOAT
const FLOAT
Float type, maps guessType() to WebRequest::getFloat()
Definition: FormOptions.php:49
LinkBatch\add
add( $ns, $dbkey)
Definition: LinkBatch.php:130
ChangesListSpecialPage\includeRcFiltersApp
includeRcFiltersApp()
Include the modules and configuration for the RCFilters app.
Definition: ChangesListSpecialPage.php:802
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:716
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:146
$wgExperiencedUserMemberSince
$wgExperiencedUserMemberSince
Specify the difference engine to use.
Definition: DefaultSettings.php:9343
ChangesListSpecialPage\makeLegend
makeLegend()
Return the legend displayed within the fieldset.
Definition: ChangesListSpecialPage.php:1731
ChangesListSpecialPage\execute
execute( $subpage)
Definition: ChangesListSpecialPage.php:622
ChangesListSpecialPage\webOutputHeader
webOutputHeader( $rowCount, $opts)
Send header output to the OutputPage object, only called if not using feeds.
Definition: ChangesListSpecialPage.php:1643
ChangesListSpecialPage\fixContradictoryOptions
fixContradictoryOptions(FormOptions $opts)
Fix invalid options by resetting pairs that should never appear together.
Definition: ChangesListSpecialPage.php:1384
ChangesListSpecialPage\parseParameters
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
Definition: ChangesListSpecialPage.php:1326
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1806
ChangesListSpecialPage\doMainQuery
doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.
Definition: ChangesListSpecialPage.php:1586
RC_LOG
const RC_LOG
Definition: Defines.php:133
ChangesListSpecialPage\expandSymbolicNamespaceFilters
expandSymbolicNamespaceFilters(array $namespaces)
Definition: ChangesListSpecialPage.php:1978
ChangesListSpecialPage\fixBackwardsCompatibilityOptions
fixBackwardsCompatibilityOptions(FormOptions $opts)
Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards compatibility.
Definition: ChangesListSpecialPage.php:1426
ChangesListSpecialPage
Special page which uses a ChangesList to show query results.
Definition: ChangesListSpecialPage.php:37
DeferredUpdates\addUpdate
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred update queue for execution at the appropriate time.
Definition: DeferredUpdates.php:106
ChangesListBooleanFilter
Represents a hide-based boolean filter (used on ChangesListSpecialPage and descendants)
Definition: ChangesListBooleanFilter.php:31
RC_EDIT
const RC_EDIT
Definition: Defines.php:131
WANCacheReapUpdate
Class for fixing stale WANObjectCache keys using a purge event source.
Definition: WANCacheReapUpdate.php:26
ChangesListSpecialPage\getDefaultDays
getDefaultDays()
Get the default value of the number of days to display when loading the result set.
Definition: ChangesListSpecialPage.php:1974
$s
$s
Definition: mergeMessageFileList.php:185
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:90
Sanitizer\escapeClass
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
Definition: Sanitizer.php:1260
FormOptions\reset
reset( $name)
Delete the option value.
Definition: FormOptions.php:207
ChangesListSpecialPage\fetchOptionsFromRequest
fetchOptionsFromRequest( $opts)
Fetch values for a FormOptions object from the WebRequest associated with this instance.
Definition: ChangesListSpecialPage.php:1314
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1064
FormOptions\validateIntBounds
validateIntBounds( $name, $min, $max)
Definition: FormOptions.php:255
ChangesListSpecialPage\getChangeTagListSummary
static getChangeTagListSummary(ResourceLoaderContext $context)
Get information about change tags, without parsing messages, for getRcFiltersConfigSummary().
Definition: ChangesListSpecialPage.php:906
RecentChange\SRC_CATEGORIZE
const SRC_CATEGORIZE
Definition: RecentChange.php:78
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:160
Wikimedia\Rdbms\FakeResultWrapper
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Definition: FakeResultWrapper.php:11
ChangesListFilterGroup
Represents a filter group (used on ChangesListSpecialPage and descendants)
Definition: ChangesListFilterGroup.php:37
RecentChange\SRC_LOG
const SRC_LOG
Definition: RecentChange.php:76
ActorMigration\newMigration
static newMigration()
Static constructor.
Definition: ActorMigration.php:139
LIST_AND
const LIST_AND
Definition: Defines.php:48
ChangesListSpecialPage\outputNoResults
outputNoResults()
Add the "no results" message to the output.
Definition: ChangesListSpecialPage.php:990
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
ChangesListSpecialPage\doHeader
doHeader( $opts, $numRows)
Set the text to be displayed above the changes.
Definition: ChangesListSpecialPage.php:1683
ChangesListSpecialPage\checkStructuredFilterUiEnabled
static checkStructuredFilterUiEnabled( $user)
Static method to check whether StructuredFilter UI is enabled for the given user.
Definition: ChangesListSpecialPage.php:1947
$dbr
$dbr
Definition: testCompression.php:54
ChangeTags\tagShortDescriptionMessage
static tagShortDescriptionMessage( $tag, MessageLocalizer $context)
Get the message object for the tag's short description.
Definition: ChangeTags.php:155
$wgExperiencedUserEdits
$wgExperiencedUserEdits
Specify the difference engine to use.
Definition: DefaultSettings.php:9342
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:315
MWExceptionHandler\logException
static logException(Throwable $e, $catcher=self::CAUGHT_BY_OTHER, $extraData=[])
Log a throwable to the exception log (if enabled).
Definition: MWExceptionHandler.php:645
ChangesListSpecialPage\webOutput
webOutput( $rows, $opts)
Send output to the OutputPage object, only called if not used feeds.
Definition: ChangesListSpecialPage.php:1656
ChangeTags\modifyDisplayQuery
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
Definition: ChangeTags.php:784
Config
Interface for configuration instances.
Definition: Config.php:28
ChangesListSpecialPage\TAG_DESC_CHARACTER_LIMIT
const TAG_DESC_CHARACTER_LIMIT
Maximum length of a tag description in UTF-8 characters.
Definition: ChangesListSpecialPage.php:42
FormatJson\decode
static decode( $value, $assoc=false)
Decodes a JSON string.
Definition: FormatJson.php:174
LIST_OR
const LIST_OR
Definition: Defines.php:51
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:974
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:766
ChangesListSpecialPage\$filterGroupDefinitions
array $filterGroupDefinitions
Definition information for the filters and their groups.
Definition: ChangesListSpecialPage.php:90
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1030
ChangesListSpecialPage\$reviewStatusFilterGroupDefinition
$reviewStatusFilterGroupDefinition
Definition: ChangesListSpecialPage.php:97
MediaWiki\Logger\LoggerFactory
PSR-3 logger instance factory.
Definition: LoggerFactory.php:45
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:70
Wikimedia\Rdbms\DBQueryTimeoutError
Error thrown when a query times out.
Definition: DBQueryTimeoutError.php:29
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
ChangesListSpecialPage\convertParamsForLink
convertParamsForLink( $params)
Convert parameters values from true/false to 1/0 so they are not omitted by wfArrayToCgi() T38524.
Definition: ChangesListSpecialPage.php:1495
ChangesListSpecialPage\getRcFiltersConfigVars
static getRcFiltersConfigVars(ResourceLoaderContext $context)
Get config vars to export with the mediawiki.rcfilters.filters.ui module.
Definition: ChangesListSpecialPage.php:878
ChangesListSpecialPage\getRows
getRows()
Get the database result for this special page instance.
Definition: ChangesListSpecialPage.php:1014
ChangesListSpecialPage\outputFeedLinks
outputFeedLinks()
Output feed links.
Definition: ChangesListSpecialPage.php:1665
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2463
ChangesListSpecialPage\runMainQueryHook
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
Definition: ChangesListSpecialPage.php:1621
ChangesListSpecialPage\isStructuredFilterUiEnabled
isStructuredFilterUiEnabled()
Check whether the structured filter UI is enabled.
Definition: ChangesListSpecialPage.php:1932
ChangesListSpecialPage\$daysPreferenceName
static string $daysPreferenceName
Preference name for 'days'.
Definition: ChangesListSpecialPage.php:54
ChangesListSpecialPage\$hideCategorizationFilterDefinition
$hideCategorizationFilterDefinition
Definition: ChangesListSpecialPage.php:100
ChangesListSpecialPage\getStructuredFilterJsData
getStructuredFilterJsData()
Gets structured filter information needed by JS.
Definition: ChangesListSpecialPage.php:1280
ChangesListStringOptionsFilterGroup\SEPARATOR
const SEPARATOR
Delimiter.
Definition: ChangesListStringOptionsFilterGroup.php:46
ChangesListSpecialPage\outputChangesList
outputChangesList( $rows, $opts)
Build and output the actual changes list.
ChangesListSpecialPage\getFilterGroups
getFilterGroups()
Gets the currently registered filters groups.
Definition: ChangesListSpecialPage.php:1252
$title
$title
Definition: testCompression.php:38
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:551
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:726
RecentChange\SRC_EDIT
const SRC_EDIT
Definition: RecentChange.php:74
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
RecentChange\SRC_NEW
const SRC_NEW
Definition: RecentChange.php:75
ChangesListSpecialPage\buildQuery
buildQuery(&$tables, &$fields, &$conds, &$query_options, &$join_conds, FormOptions $opts)
Sets appropriate tables, fields, conditions, etc.
Definition: ChangesListSpecialPage.php:1516
ChangesListSpecialPage\getDefaultLimit
getDefaultLimit()
Get the default value of the number of changes to display when loading the result set.
Definition: ChangesListSpecialPage.php:1962
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:689
RecentChange\PRC_PATROLLED
const PRC_PATROLLED
Definition: RecentChange.php:81
ChangeTags\listExplicitlyDefinedTags
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the change_tag_def table of the database.
Definition: ChangeTags.php:1458
ChangesListSpecialPage\$rcOptions
FormOptions $rcOptions
Definition: ChangesListSpecialPage.php:72
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:72
ChangesListSpecialPage\registerFilters
registerFilters()
Register all filters and their groups (including those from hooks), plus handle conflicts and default...
Definition: ChangesListSpecialPage.php:1049
ChangesListSpecialPage\$savedQueriesPreferenceName
static string $savedQueriesPreferenceName
Preference name for saved queries.
Definition: ChangesListSpecialPage.php:48
FormOptions\validateBounds
validateBounds( $name, $min, $max)
Constrain a numeric value for a given option to a given range.
Definition: FormOptions.php:270
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:39
ChangesListSpecialPage\setup
setup( $parameters)
Register all the filters, including legacy hook-driven ones.
Definition: ChangesListSpecialPage.php:1185
ChangesListSpecialPage\getChangeTagList
static getChangeTagList(ResourceLoaderContext $context)
Get information about change tags to export to JS via getRcFiltersConfigVars().
Definition: ChangesListSpecialPage.php:964
ChangesListSpecialPage\getFilterGroup
getFilterGroup( $groupName)
Gets a specified ChangesListFilterGroup by name.
Definition: ChangesListSpecialPage.php:1263
ChangesListSpecialPage\outputTimeout
outputTimeout()
Add the "timeout" message to the output.
Definition: ChangesListSpecialPage.php:1001
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:706
ChangesListStringOptionsFilterGroup\NONE
const NONE
Signifies that no options in the group are selected, meaning the group has no effect.
Definition: ChangesListStringOptionsFilterGroup.php:59
RC_NEW
const RC_NEW
Definition: Defines.php:132
RecentChange\PRC_AUTOPATROLLED
const PRC_AUTOPATROLLED
Definition: RecentChange.php:82
ChangeTags\listSoftwareActivatedTags
static listSoftwareActivatedTags()
Lists those tags which core or extensions report as being "active".
Definition: ChangeTags.php:1411
$wgLearnerEdits
$wgLearnerEdits
The following variables define 3 user experience levels:
Definition: DefaultSettings.php:9340
ChangesListSpecialPage\addModules
addModules()
Add page-specific modules.
Definition: ChangesListSpecialPage.php:1786
FormOptions\STRING
const STRING
String type, maps guessType() to WebRequest::getText()
Definition: FormOptions.php:43
$context
$context
Definition: load.php:43
ChangesListSpecialPage\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: ChangesListSpecialPage.php:1802
ChangesListSpecialPage\areFiltersInConflict
areFiltersInConflict()
Check if filters are in conflict and guaranteed to return no results.
Definition: ChangesListSpecialPage.php:582
ChangesListSpecialPage\getDefaultOptions
getDefaultOptions()
Get a FormOptions object containing the default options.
Definition: ChangesListSpecialPage.php:1211
ChangesListSpecialPage\transformFilterDefinition
transformFilterDefinition(array $filterDefinition)
Transforms filter definition to prepare it for constructor.
Definition: ChangesListSpecialPage.php:1123
ChangesListBooleanFilterGroup
If the group is active, any unchecked filters will translate to hide parameters in the URL.
Definition: ChangesListBooleanFilterGroup.php:13
$cache
$cache
Definition: mcc.php:33
FormOptions\INT
const INT
Integer type, maps guessType() to WebRequest::getInt()
Definition: FormOptions.php:45
ChangesListSpecialPage\getDB
getDB()
Return a IDatabase object for reading.
Definition: ChangesListSpecialPage.php:1633
RecentChange\PRC_UNPATROLLED
const PRC_UNPATROLLED
Definition: RecentChange.php:80
ChangesListSpecialPage\$filterGroups
ChangesListFilterGroup[] $filterGroups
Filter groups, and their contained filters This is an associative array (with group name as key) of C...
Definition: ChangesListSpecialPage.php:108
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:251
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
ChangesListSpecialPage\$collapsedPreferenceName
static string $collapsedPreferenceName
Preference name for collapsing the active filter display.
Definition: ChangesListSpecialPage.php:66
ChangesListFilter
Represents a filter (used on ChangesListSpecialPage and descendants)
Definition: ChangesListFilter.php:29
NS_USER
const NS_USER
Definition: Defines.php:71
$wgLearnerMemberSince
$wgLearnerMemberSince
Specify the difference engine to use.
Definition: DefaultSettings.php:9341
ChangesListSpecialPage\$rcSubpage
string $rcSubpage
Definition: ChangesListSpecialPage.php:69
ChangeTags\tagUsageStatistics
static tagUsageStatistics()
Returns a map of any tags used on the wiki to number of edits tagged with them, ordered descending by...
Definition: ChangeTags.php:1544
ChangesListSpecialPage\filterOnUserExperienceLevel
filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now=0)
Filter on users' experience levels; this will not be called if nothing is selected.
Definition: ChangesListSpecialPage.php:1822
ChangesListSpecialPage\replaceOldOptions
replaceOldOptions(FormOptions $opts)
Replace old options with their structured UI equivalents.
Definition: ChangesListSpecialPage.php:1446
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:135
FormOptions
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
ChangesListSpecialPage\registerFiltersFromDefinitions
registerFiltersFromDefinitions(array $definition)
Register filters from a definition object.
Definition: ChangesListSpecialPage.php:1137
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
FormOptions\getChangedValues
getChangedValues()
Return options modified as an array ( name => value )
Definition: FormOptions.php:308
ChangesListSpecialPage\setBottomText
setBottomText(FormOptions $opts)
Send the text to be displayed after the options.
Definition: ChangesListSpecialPage.php:1709
ChangeTags\tagLongDescriptionMessage
static tagLongDescriptionMessage( $tag, MessageLocalizer $context)
Get the message object for the tag's long description.
Definition: ChangeTags.php:206
ChangesListSpecialPage\validateOptions
validateOptions(FormOptions $opts)
Validate a FormOptions object generated by getDefaultOptions() with values already populated.
Definition: ChangesListSpecialPage.php:1365
ChangesListSpecialPage\registerFilterGroup
registerFilterGroup(ChangesListFilterGroup $group)
Register a structured changes list filter group.
Definition: ChangesListSpecialPage.php:1241
ChangesListStringOptionsFilterGroup
Represents a filter group with multiple string options.
Definition: ChangesListStringOptionsFilterGroup.php:37
ChangesListSpecialPage\getOptions
getOptions()
Get the current FormOptions for this request.
Definition: ChangesListSpecialPage.php:1032
ChangesListSpecialPage\getLinkDays
getLinkDays()
Definition: ChangesListSpecialPage.php:774
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:636
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:243
ChangesListFilter\getConflictingFilters
getConflictingFilters()
Get filters conflicting with this filter.
Definition: ChangesListFilter.php:430
ChangesListSpecialPage\$limitPreferenceName
static string $limitPreferenceName
Preference name for 'limit'.
Definition: ChangesListSpecialPage.php:60
ChangesListSpecialPage\getLegacyShowHideFilters
getLegacyShowHideFilters()
Definition: ChangesListSpecialPage.php:1163
ChangesListSpecialPage\$legacyReviewStatusFilterGroupDefinition
$legacyReviewStatusFilterGroupDefinition
Definition: ChangesListSpecialPage.php:94
wfArrayToCgi
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e....
Definition: GlobalFunctions.php:347
ChangesListSpecialPage\setTopText
setTopText(FormOptions $opts)
Send the text to be displayed before the options.
Definition: ChangesListSpecialPage.php:1698
ChangesListSpecialPage\getRcFiltersConfigSummary
static getRcFiltersConfigSummary(ResourceLoaderContext $context)
Get essential data about getRcFiltersConfigVars() for change detection.
Definition: ChangesListSpecialPage.php:862