MediaWiki  master
ChangesListSpecialPage.php
Go to the documentation of this file.
1 <?php
26 use OOUI\IconWidget;
31 
38 abstract class ChangesListSpecialPage extends SpecialPage {
43  private const TAG_DESC_CHARACTER_LIMIT = 120;
44 
49  protected static $savedQueriesPreferenceName;
50 
55  protected static $daysPreferenceName;
56 
61  protected static $limitPreferenceName;
62 
67  protected static $collapsedPreferenceName;
68 
70  protected $rcSubpage;
71 
73  protected $rcOptions;
74 
75  // Order of both groups and filters is significant; first is top-most priority,
76  // descending from there.
77  // 'showHideSuffix' is a shortcut to and avoid spelling out
78  // details specific to subclasses here.
92 
93  // Same format as filterGroupDefinitions, but for a single group (reviewStatus)
94  // that is registered conditionally.
96 
97  // Single filter group registered conditionally
99 
100  // Single filter group registered conditionally
102 
109  protected $filterGroups = [];
110 
111  public function __construct( $name, $restriction ) {
112  parent::__construct( $name, $restriction );
113 
114  $nonRevisionTypes = [ RC_LOG ];
115  $this->getHookRunner()->onSpecialWatchlistGetNonRevisionTypes( $nonRevisionTypes );
116 
117  $this->filterGroupDefinitions = [
118  [
119  'name' => 'registration',
120  'title' => 'rcfilters-filtergroup-registration',
121  'class' => ChangesListBooleanFilterGroup::class,
122  'filters' => [
123  [
124  'name' => 'hideliu',
125  // rcshowhideliu-show, rcshowhideliu-hide,
126  // wlshowhideliu
127  'showHideSuffix' => 'showhideliu',
128  'default' => false,
129  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
130  &$query_options, &$join_conds
131  ) {
132  $actorMigration = ActorMigration::newMigration();
133  $actorQuery = $actorMigration->getJoin( 'rc_user' );
134  $tables += $actorQuery['tables'];
135  $join_conds += $actorQuery['joins'];
136  $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
137  },
138  'isReplacedInStructuredUi' => true,
139 
140  ],
141  [
142  'name' => 'hideanons',
143  // rcshowhideanons-show, rcshowhideanons-hide,
144  // wlshowhideanons
145  'showHideSuffix' => 'showhideanons',
146  'default' => false,
147  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
148  &$query_options, &$join_conds
149  ) {
150  $actorMigration = ActorMigration::newMigration();
151  $actorQuery = $actorMigration->getJoin( 'rc_user' );
152  $tables += $actorQuery['tables'];
153  $join_conds += $actorQuery['joins'];
154  $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
155  },
156  'isReplacedInStructuredUi' => true,
157  ]
158  ],
159  ],
160 
161  [
162  'name' => 'userExpLevel',
163  'title' => 'rcfilters-filtergroup-user-experience-level',
164  'class' => ChangesListStringOptionsFilterGroup::class,
165  'isFullCoverage' => true,
166  'filters' => [
167  [
168  'name' => 'unregistered',
169  'label' => 'rcfilters-filter-user-experience-level-unregistered-label',
170  'description' => 'rcfilters-filter-user-experience-level-unregistered-description',
171  'cssClassSuffix' => 'user-unregistered',
172  'isRowApplicableCallable' => function ( $ctx, $rc ) {
173  return !$rc->getAttribute( 'rc_user' );
174  }
175  ],
176  [
177  'name' => 'registered',
178  'label' => 'rcfilters-filter-user-experience-level-registered-label',
179  'description' => 'rcfilters-filter-user-experience-level-registered-description',
180  'cssClassSuffix' => 'user-registered',
181  'isRowApplicableCallable' => function ( $ctx, $rc ) {
182  return $rc->getAttribute( 'rc_user' );
183  }
184  ],
185  [
186  'name' => 'newcomer',
187  'label' => 'rcfilters-filter-user-experience-level-newcomer-label',
188  'description' => 'rcfilters-filter-user-experience-level-newcomer-description',
189  'cssClassSuffix' => 'user-newcomer',
190  'isRowApplicableCallable' => function ( $ctx, $rc ) {
191  $performer = $rc->getPerformer();
192  return $performer && $performer->isLoggedIn() &&
193  $performer->getExperienceLevel() === 'newcomer';
194  }
195  ],
196  [
197  'name' => 'learner',
198  'label' => 'rcfilters-filter-user-experience-level-learner-label',
199  'description' => 'rcfilters-filter-user-experience-level-learner-description',
200  'cssClassSuffix' => 'user-learner',
201  'isRowApplicableCallable' => function ( $ctx, $rc ) {
202  $performer = $rc->getPerformer();
203  return $performer && $performer->isLoggedIn() &&
204  $performer->getExperienceLevel() === 'learner';
205  },
206  ],
207  [
208  'name' => 'experienced',
209  'label' => 'rcfilters-filter-user-experience-level-experienced-label',
210  'description' => 'rcfilters-filter-user-experience-level-experienced-description',
211  'cssClassSuffix' => 'user-experienced',
212  'isRowApplicableCallable' => function ( $ctx, $rc ) {
213  $performer = $rc->getPerformer();
214  return $performer && $performer->isLoggedIn() &&
215  $performer->getExperienceLevel() === 'experienced';
216  },
217  ]
218  ],
220  'queryCallable' => [ $this, 'filterOnUserExperienceLevel' ],
221  ],
222 
223  [
224  'name' => 'authorship',
225  'title' => 'rcfilters-filtergroup-authorship',
226  'class' => ChangesListBooleanFilterGroup::class,
227  'filters' => [
228  [
229  'name' => 'hidemyself',
230  'label' => 'rcfilters-filter-editsbyself-label',
231  'description' => 'rcfilters-filter-editsbyself-description',
232  // rcshowhidemine-show, rcshowhidemine-hide,
233  // wlshowhidemine
234  'showHideSuffix' => 'showhidemine',
235  'default' => false,
236  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
237  &$query_options, &$join_conds
238  ) {
239  $actorQuery = ActorMigration::newMigration()->getWhere( $dbr, 'rc_user', $ctx->getUser() );
240  $tables += $actorQuery['tables'];
241  $join_conds += $actorQuery['joins'];
242  $conds[] = 'NOT(' . $actorQuery['conds'] . ')';
243  },
244  'cssClassSuffix' => 'self',
245  'isRowApplicableCallable' => function ( $ctx, $rc ) {
246  return $ctx->getUser()->equals( $rc->getPerformer() );
247  },
248  ],
249  [
250  'name' => 'hidebyothers',
251  'label' => 'rcfilters-filter-editsbyother-label',
252  'description' => 'rcfilters-filter-editsbyother-description',
253  'default' => false,
254  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
255  &$query_options, &$join_conds
256  ) {
257  $actorQuery = ActorMigration::newMigration()
258  ->getWhere( $dbr, 'rc_user', $ctx->getUser(), false );
259  $tables += $actorQuery['tables'];
260  $join_conds += $actorQuery['joins'];
261  $conds[] = $actorQuery['conds'];
262  },
263  'cssClassSuffix' => 'others',
264  'isRowApplicableCallable' => function ( $ctx, $rc ) {
265  return !$ctx->getUser()->equals( $rc->getPerformer() );
266  },
267  ]
268  ]
269  ],
270 
271  [
272  'name' => 'automated',
273  'title' => 'rcfilters-filtergroup-automated',
274  'class' => ChangesListBooleanFilterGroup::class,
275  'filters' => [
276  [
277  'name' => 'hidebots',
278  'label' => 'rcfilters-filter-bots-label',
279  'description' => 'rcfilters-filter-bots-description',
280  // rcshowhidebots-show, rcshowhidebots-hide,
281  // wlshowhidebots
282  'showHideSuffix' => 'showhidebots',
283  'default' => false,
284  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
285  &$query_options, &$join_conds
286  ) {
287  $conds['rc_bot'] = 0;
288  },
289  'cssClassSuffix' => 'bot',
290  'isRowApplicableCallable' => function ( $ctx, $rc ) {
291  return $rc->getAttribute( 'rc_bot' );
292  },
293  ],
294  [
295  'name' => 'hidehumans',
296  'label' => 'rcfilters-filter-humans-label',
297  'description' => 'rcfilters-filter-humans-description',
298  'default' => false,
299  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
300  &$query_options, &$join_conds
301  ) {
302  $conds['rc_bot'] = 1;
303  },
304  'cssClassSuffix' => 'human',
305  'isRowApplicableCallable' => function ( $ctx, $rc ) {
306  return !$rc->getAttribute( 'rc_bot' );
307  },
308  ]
309  ]
310  ],
311 
312  // significance (conditional)
313 
314  [
315  'name' => 'significance',
316  'title' => 'rcfilters-filtergroup-significance',
317  'class' => ChangesListBooleanFilterGroup::class,
318  'priority' => -6,
319  'filters' => [
320  [
321  'name' => 'hideminor',
322  'label' => 'rcfilters-filter-minor-label',
323  'description' => 'rcfilters-filter-minor-description',
324  // rcshowhideminor-show, rcshowhideminor-hide,
325  // wlshowhideminor
326  'showHideSuffix' => 'showhideminor',
327  'default' => false,
328  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
329  &$query_options, &$join_conds
330  ) {
331  $conds[] = 'rc_minor = 0';
332  },
333  'cssClassSuffix' => 'minor',
334  'isRowApplicableCallable' => function ( $ctx, $rc ) {
335  return $rc->getAttribute( 'rc_minor' );
336  }
337  ],
338  [
339  'name' => 'hidemajor',
340  'label' => 'rcfilters-filter-major-label',
341  'description' => 'rcfilters-filter-major-description',
342  'default' => false,
343  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
344  &$query_options, &$join_conds
345  ) {
346  $conds[] = 'rc_minor = 1';
347  },
348  'cssClassSuffix' => 'major',
349  'isRowApplicableCallable' => function ( $ctx, $rc ) {
350  return !$rc->getAttribute( 'rc_minor' );
351  }
352  ]
353  ]
354  ],
355 
356  [
357  'name' => 'lastRevision',
358  'title' => 'rcfilters-filtergroup-lastrevision',
359  'class' => ChangesListBooleanFilterGroup::class,
360  'priority' => -7,
361  'filters' => [
362  [
363  'name' => 'hidelastrevision',
364  'label' => 'rcfilters-filter-lastrevision-label',
365  'description' => 'rcfilters-filter-lastrevision-description',
366  'default' => false,
367  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
368  &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
369  $conds[] = $dbr->makeList(
370  [
371  'rc_this_oldid <> page_latest',
372  'rc_type' => $nonRevisionTypes,
373  ],
374  LIST_OR
375  );
376  },
377  'cssClassSuffix' => 'last',
378  'isRowApplicableCallable' => function ( $ctx, $rc ) {
379  return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
380  }
381  ],
382  [
383  'name' => 'hidepreviousrevisions',
384  'label' => 'rcfilters-filter-previousrevision-label',
385  'description' => 'rcfilters-filter-previousrevision-description',
386  'default' => false,
387  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
388  &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
389  $conds[] = $dbr->makeList(
390  [
391  'rc_this_oldid = page_latest',
392  'rc_type' => $nonRevisionTypes,
393  ],
394  LIST_OR
395  );
396  },
397  'cssClassSuffix' => 'previous',
398  'isRowApplicableCallable' => function ( $ctx, $rc ) {
399  return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
400  }
401  ]
402  ]
403  ],
404 
405  // With extensions, there can be change types that will not be hidden by any of these.
406  [
407  'name' => 'changeType',
408  'title' => 'rcfilters-filtergroup-changetype',
409  'class' => ChangesListBooleanFilterGroup::class,
410  'priority' => -8,
411  'filters' => [
412  [
413  'name' => 'hidepageedits',
414  'label' => 'rcfilters-filter-pageedits-label',
415  'description' => 'rcfilters-filter-pageedits-description',
416  'default' => false,
417  'priority' => -2,
418  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
419  &$query_options, &$join_conds
420  ) {
421  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
422  },
423  'cssClassSuffix' => 'src-mw-edit',
424  'isRowApplicableCallable' => function ( $ctx, $rc ) {
425  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_EDIT;
426  },
427  ],
428  [
429  'name' => 'hidenewpages',
430  'label' => 'rcfilters-filter-newpages-label',
431  'description' => 'rcfilters-filter-newpages-description',
432  'default' => false,
433  'priority' => -3,
434  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
435  &$query_options, &$join_conds
436  ) {
437  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
438  },
439  'cssClassSuffix' => 'src-mw-new',
440  'isRowApplicableCallable' => function ( $ctx, $rc ) {
441  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_NEW;
442  },
443  ],
444 
445  // hidecategorization
446 
447  [
448  'name' => 'hidelog',
449  'label' => 'rcfilters-filter-logactions-label',
450  'description' => 'rcfilters-filter-logactions-description',
451  'default' => false,
452  'priority' => -5,
453  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
454  &$query_options, &$join_conds
455  ) {
456  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
457  },
458  'cssClassSuffix' => 'src-mw-log',
459  'isRowApplicableCallable' => function ( $ctx, $rc ) {
460  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_LOG;
461  }
462  ],
463  ],
464  ],
465 
466  ];
467 
468  $this->legacyReviewStatusFilterGroupDefinition = [
469  [
470  'name' => 'legacyReviewStatus',
471  'title' => 'rcfilters-filtergroup-reviewstatus',
472  'class' => ChangesListBooleanFilterGroup::class,
473  'filters' => [
474  [
475  'name' => 'hidepatrolled',
476  // rcshowhidepatr-show, rcshowhidepatr-hide
477  // wlshowhidepatr
478  'showHideSuffix' => 'showhidepatr',
479  'default' => false,
480  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
481  &$query_options, &$join_conds
482  ) {
483  $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
484  },
485  'isReplacedInStructuredUi' => true,
486  ],
487  [
488  'name' => 'hideunpatrolled',
489  'default' => false,
490  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
491  &$query_options, &$join_conds
492  ) {
493  $conds[] = 'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED;
494  },
495  'isReplacedInStructuredUi' => true,
496  ],
497  ],
498  ]
499  ];
500 
501  $this->reviewStatusFilterGroupDefinition = [
502  [
503  'name' => 'reviewStatus',
504  'title' => 'rcfilters-filtergroup-reviewstatus',
505  'class' => ChangesListStringOptionsFilterGroup::class,
506  'isFullCoverage' => true,
507  'priority' => -5,
508  'filters' => [
509  [
510  'name' => 'unpatrolled',
511  'label' => 'rcfilters-filter-reviewstatus-unpatrolled-label',
512  'description' => 'rcfilters-filter-reviewstatus-unpatrolled-description',
513  'cssClassSuffix' => 'reviewstatus-unpatrolled',
514  'isRowApplicableCallable' => function ( $ctx, $rc ) {
515  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED;
516  },
517  ],
518  [
519  'name' => 'manual',
520  'label' => 'rcfilters-filter-reviewstatus-manual-label',
521  'description' => 'rcfilters-filter-reviewstatus-manual-description',
522  'cssClassSuffix' => 'reviewstatus-manual',
523  'isRowApplicableCallable' => function ( $ctx, $rc ) {
524  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_PATROLLED;
525  },
526  ],
527  [
528  'name' => 'auto',
529  'label' => 'rcfilters-filter-reviewstatus-auto-label',
530  'description' => 'rcfilters-filter-reviewstatus-auto-description',
531  'cssClassSuffix' => 'reviewstatus-auto',
532  'isRowApplicableCallable' => function ( $ctx, $rc ) {
533  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_AUTOPATROLLED;
534  },
535  ],
536  ],
538  'queryCallable' => function ( $specialPageClassName, $ctx, $dbr,
539  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selected
540  ) {
541  if ( $selected === [] ) {
542  return;
543  }
544  $rcPatrolledValues = [
545  'unpatrolled' => RecentChange::PRC_UNPATROLLED,
546  'manual' => RecentChange::PRC_PATROLLED,
548  ];
549  // e.g. rc_patrolled IN (0, 2)
550  $conds['rc_patrolled'] = array_map( function ( $s ) use ( $rcPatrolledValues ) {
551  return $rcPatrolledValues[ $s ];
552  }, $selected );
553  }
554  ]
555  ];
556 
557  $this->hideCategorizationFilterDefinition = [
558  'name' => 'hidecategorization',
559  'label' => 'rcfilters-filter-categorization-label',
560  'description' => 'rcfilters-filter-categorization-description',
561  // rcshowhidecategorization-show, rcshowhidecategorization-hide.
562  // wlshowhidecategorization
563  'showHideSuffix' => 'showhidecategorization',
564  'default' => false,
565  'priority' => -4,
566  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
567  &$query_options, &$join_conds
568  ) {
569  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
570  },
571  'cssClassSuffix' => 'src-mw-categorize',
572  'isRowApplicableCallable' => function ( $ctx, $rc ) {
573  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_CATEGORIZE;
574  },
575  ];
576  }
577 
583  protected function areFiltersInConflict() {
584  $opts = $this->getOptions();
586  foreach ( $this->getFilterGroups() as $group ) {
587  if ( $group->getConflictingGroups() ) {
588  wfLogWarning(
589  $group->getName() .
590  " specifies conflicts with other groups but these are not supported yet."
591  );
592  }
593 
595  foreach ( $group->getConflictingFilters() as $conflictingFilter ) {
596  if ( $conflictingFilter->activelyInConflictWithGroup( $group, $opts ) ) {
597  return true;
598  }
599  }
600 
602  foreach ( $group->getFilters() as $filter ) {
604  foreach ( $filter->getConflictingFilters() as $conflictingFilter ) {
605  if (
606  $conflictingFilter->activelyInConflictWithFilter( $filter, $opts ) &&
607  $filter->activelyInConflictWithFilter( $conflictingFilter, $opts )
608  ) {
609  return true;
610  }
611  }
612 
613  }
614 
615  }
616 
617  return false;
618  }
619 
623  public function execute( $subpage ) {
624  $this->rcSubpage = $subpage;
625 
626  $this->considerActionsForDefaultSavedQuery( $subpage );
627 
628  // Enable OOUI and module for the clock icon.
629  if ( $this->getConfig()->get( 'WatchlistExpiry' ) ) {
630  $this->getOutput()->enableOOUI();
631  $this->getOutput()->addModules( 'mediawiki.special.changeslist.watchlistexpiry' );
632  }
633 
634  $opts = $this->getOptions();
635  try {
636  $rows = $this->getRows();
637  if ( $rows === false ) {
638  $rows = new FakeResultWrapper( [] );
639  }
640 
641  // Used by Structured UI app to get results without MW chrome
642  if ( $this->getRequest()->getVal( 'action' ) === 'render' ) {
643  $this->getOutput()->setArticleBodyOnly( true );
644  }
645 
646  // Used by "live update" and "view newest" to check
647  // if there's new changes with minimal data transfer
648  if ( $this->getRequest()->getBool( 'peek' ) ) {
649  $code = $rows->numRows() > 0 ? 200 : 204;
650  $this->getOutput()->setStatusCode( $code );
651 
652  if ( $this->getUser()->isAnon() !==
653  $this->getRequest()->getFuzzyBool( 'isAnon' )
654  ) {
655  $this->getOutput()->setStatusCode( 205 );
656  }
657 
658  return;
659  }
660 
661  $linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
662  $batch = $linkBatchFactory->newLinkBatch();
663  foreach ( $rows as $row ) {
664  $batch->add( NS_USER, $row->rc_user_text );
665  $batch->add( NS_USER_TALK, $row->rc_user_text );
666  $batch->add( $row->rc_namespace, $row->rc_title );
667  if ( $row->rc_source === RecentChange::SRC_LOG ) {
668  $formatter = LogFormatter::newFromRow( $row );
669  foreach ( $formatter->getPreloadTitles() as $title ) {
670  $batch->addObj( $title );
671  }
672  }
673  }
674  $batch->execute();
675 
676  $this->setHeaders();
677  $this->outputHeader();
678  $this->addModules();
679  $this->webOutput( $rows, $opts );
680 
681  $rows->free();
682  } catch ( DBQueryTimeoutError $timeoutException ) {
683  MWExceptionHandler::logException( $timeoutException );
684 
685  $this->setHeaders();
686  $this->outputHeader();
687  $this->addModules();
688 
689  $this->getOutput()->setStatusCode( 500 );
690  $this->webOutputHeader( 0, $opts );
691  $this->outputTimeout();
692  }
693 
694  if ( $this->getConfig()->get( 'EnableWANCacheReaper' ) ) {
695  // Clean up any bad page entries for titles showing up in RC
697  $this->getDB(),
698  LoggerFactory::getInstance( 'objectcache' )
699  ) );
700  }
701 
702  $this->includeRcFiltersApp();
703  }
704 
712  protected function considerActionsForDefaultSavedQuery( $subpage ) {
713  if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) {
714  return;
715  }
716 
717  $knownParams = $this->getRequest()->getValues(
718  ...array_keys( $this->getOptions()->getAllValues() )
719  );
720 
721  // HACK: Temporarily until we can properly define "sticky" filters and parameters,
722  // we need to exclude several parameters we know should not be counted towards preventing
723  // the loading of defaults.
724  $excludedParams = [ 'limit' => '', 'days' => '', 'enhanced' => '', 'from' => '' ];
725  $knownParams = array_diff_key( $knownParams, $excludedParams );
726 
727  if (
728  // If there are NO known parameters in the URL request
729  // (that are not excluded) then we need to check into loading
730  // the default saved query
731  count( $knownParams ) === 0
732  ) {
733  // Get the saved queries data and parse it
734  $savedQueries = FormatJson::decode(
735  $this->getUser()->getOption( static::$savedQueriesPreferenceName ),
736  true
737  );
738 
739  if ( $savedQueries && isset( $savedQueries[ 'default' ] ) ) {
740  // Only load queries that are 'version' 2, since those
741  // have parameter representation
742  if ( isset( $savedQueries[ 'version' ] ) && $savedQueries[ 'version' ] === '2' ) {
743  $savedQueryDefaultID = $savedQueries[ 'default' ];
744  $defaultQuery = $savedQueries[ 'queries' ][ $savedQueryDefaultID ][ 'data' ];
745 
746  // Build the entire parameter list
747  $query = array_merge(
748  $defaultQuery[ 'params' ],
749  $defaultQuery[ 'highlights' ],
750  [
751  'urlversion' => '2',
752  ]
753  );
754  // Add to the query any parameters that we may have ignored before
755  // but are still valid and requested in the URL
756  $query = array_merge( $this->getRequest()->getValues(), $query );
757  unset( $query[ 'title' ] );
758  $this->getOutput()->redirect( $this->getPageTitle( $subpage )->getCanonicalURL( $query ) );
759  } else {
760  // There's a default, but the version is not 2, and the server can't
761  // actually recognize the query itself. This happens if it is before
762  // the conversion, so we need to tell the UI to reload saved query as
763  // it does the conversion to version 2
764  $this->getOutput()->addJsConfigVars(
765  'wgStructuredChangeFiltersDefaultSavedQueryExists',
766  true
767  );
768 
769  // Add the class that tells the frontend it is still loading
770  // another query
771  $this->getOutput()->addBodyClasses( 'mw-rcfilters-ui-loading' );
772  }
773  }
774  }
775  }
776 
782  protected function getLinkDays() {
783  $linkDays = $this->getConfig()->get( 'RCLinkDays' );
784  $filterByAge = $this->getConfig()->get( 'RCFilterByAge' );
785  $maxAge = $this->getConfig()->get( 'RCMaxAge' );
786  if ( $filterByAge ) {
787  // Trim it to only links which are within $wgRCMaxAge.
788  // Note that we allow one link higher than the max for things like
789  // "age 56 days" being accessible through the "60 days" link.
790  sort( $linkDays );
791 
792  $maxAgeDays = $maxAge / ( 3600 * 24 );
793  foreach ( $linkDays as $i => $days ) {
794  if ( $days >= $maxAgeDays ) {
795  array_splice( $linkDays, $i + 1 );
796  break;
797  }
798  }
799  }
800 
801  return $linkDays;
802  }
803 
810  protected function includeRcFiltersApp() {
811  $out = $this->getOutput();
812  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
813  $jsData = $this->getStructuredFilterJsData();
814  $messages = [];
815  foreach ( $jsData['messageKeys'] as $key ) {
816  $messages[$key] = $this->msg( $key )->plain();
817  }
818 
819  $out->addBodyClasses( 'mw-rcfilters-enabled' );
820  $collapsed = $this->getUser()->getBoolOption( static::$collapsedPreferenceName );
821  if ( $collapsed ) {
822  $out->addBodyClasses( 'mw-rcfilters-collapsed' );
823  }
824 
825  // These config and message exports should be moved into a ResourceLoader data module (T201574)
826  $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
827  $out->addJsConfigVars( 'wgStructuredChangeFiltersMessages', $messages );
828  $out->addJsConfigVars( 'wgStructuredChangeFiltersCollapsedState', $collapsed );
829 
830  $out->addJsConfigVars(
831  'StructuredChangeFiltersDisplayConfig',
832  [
833  'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
834  'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
835  'limitDefault' => $this->getDefaultLimit(),
836  'daysArray' => $this->getLinkDays(),
837  'daysDefault' => $this->getDefaultDays(),
838  ]
839  );
840 
841  $out->addJsConfigVars(
842  'wgStructuredChangeFiltersSavedQueriesPreferenceName',
843  static::$savedQueriesPreferenceName
844  );
845  $out->addJsConfigVars(
846  'wgStructuredChangeFiltersLimitPreferenceName',
847  static::$limitPreferenceName
848  );
849  $out->addJsConfigVars(
850  'wgStructuredChangeFiltersDaysPreferenceName',
851  static::$daysPreferenceName
852  );
853  $out->addJsConfigVars(
854  'wgStructuredChangeFiltersCollapsedPreferenceName',
855  static::$collapsedPreferenceName
856  );
857  } else {
858  $out->addBodyClasses( 'mw-rcfilters-disabled' );
859  }
860  }
861 
870  public static function getRcFiltersConfigSummary( ResourceLoaderContext $context ) {
871  return [
872  // Reduce version computation by avoiding Message parsing
873  'RCFiltersChangeTags' => self::getChangeTagListSummary( $context ),
874  'StructuredChangeFiltersEditWatchlistUrl' =>
875  SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
876  ];
877  }
878 
886  public static function getRcFiltersConfigVars( ResourceLoaderContext $context ) {
887  return [
888  'RCFiltersChangeTags' => self::getChangeTagList( $context ),
889  'StructuredChangeFiltersEditWatchlistUrl' =>
890  SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
891  ];
892  }
893 
914  protected static function getChangeTagListSummary( ResourceLoaderContext $context ) {
915  $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
916  return $cache->getWithSetCallback(
917  $cache->makeKey( 'ChangesListSpecialPage-changeTagListSummary', $context->getLanguage() ),
918  WANObjectCache::TTL_DAY,
919  function ( $oldValue, &$ttl, array &$setOpts ) use ( $context ) {
920  $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
921  $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
922 
923  $tagStats = ChangeTags::tagUsageStatistics();
924  $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
925 
926  $result = [];
927  foreach ( $tagHitCounts as $tagName => $hits ) {
928  if (
929  (
930  // Only get active tags
931  isset( $explicitlyDefinedTags[ $tagName ] ) ||
932  isset( $softwareActivatedTags[ $tagName ] )
933  ) &&
934  // Only get tags with more than 0 hits
935  $hits > 0
936  ) {
937  $labelMsg = ChangeTags::tagShortDescriptionMessage( $tagName, $context );
938  if ( $labelMsg === false ) {
939  // Tag is hidden, skip it
940  continue;
941  }
942  $descriptionMsg = ChangeTags::tagLongDescriptionMessage( $tagName, $context );
943  $result[] = [
944  'name' => $tagName,
945  'labelMsg' => $labelMsg,
946  'label' => $labelMsg->plain(),
947  'descriptionMsg' => $descriptionMsg,
948  'description' => $descriptionMsg ? $descriptionMsg->plain() : '',
949  'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
950  'hits' => $hits,
951  ];
952  }
953  }
954  return $result;
955  }
956  );
957  }
958 
972  protected static function getChangeTagList( ResourceLoaderContext $context ) {
973  $tags = self::getChangeTagListSummary( $context );
974  $language = MediaWikiServices::getInstance()->getLanguageFactory()
975  ->getLanguage( $context->getLanguage() );
976  foreach ( $tags as &$tagInfo ) {
977  $tagInfo['label'] = Sanitizer::stripAllTags( $tagInfo['labelMsg']->parse() );
978  $tagInfo['description'] = $tagInfo['descriptionMsg'] ?
979  $language->truncateForVisual(
980  Sanitizer::stripAllTags( $tagInfo['descriptionMsg']->parse() ),
981  self::TAG_DESC_CHARACTER_LIMIT
982  ) :
983  '';
984  unset( $tagInfo['labelMsg'] );
985  unset( $tagInfo['descriptionMsg'] );
986  }
987 
988  // Instead of sorting by hit count (disabled for now), sort by display name
989  usort( $tags, function ( $a, $b ) {
990  return strcasecmp( $a['label'], $b['label'] );
991  } );
992  return $tags;
993  }
994 
998  protected function outputNoResults() {
999  $this->getOutput()->addHTML(
1000  '<div class="mw-changeslist-empty">' .
1001  $this->msg( 'recentchanges-noresult' )->parse() .
1002  '</div>'
1003  );
1004  }
1005 
1009  protected function outputTimeout() {
1010  $this->getOutput()->addHTML(
1011  '<div class="mw-changeslist-empty mw-changeslist-timeout">' .
1012  $this->msg( 'recentchanges-timeout' )->parse() .
1013  '</div>'
1014  );
1015  }
1016 
1022  public function getRows() {
1023  $opts = $this->getOptions();
1024 
1025  $tables = [];
1026  $fields = [];
1027  $conds = [];
1028  $query_options = [];
1029  $join_conds = [];
1030  $this->buildQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
1031 
1032  return $this->doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
1033  }
1034 
1040  public function getOptions() {
1041  if ( $this->rcOptions === null ) {
1042  $this->rcOptions = $this->setup( $this->rcSubpage );
1043  }
1044 
1045  return $this->rcOptions;
1046  }
1047 
1057  protected function registerFilters() {
1058  $this->registerFiltersFromDefinitions( $this->filterGroupDefinitions );
1059 
1060  // Make sure this is not being transcluded (we don't want to show this
1061  // information to all users just because the user that saves the edit can
1062  // patrol or is logged in)
1063  if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
1064  $this->registerFiltersFromDefinitions( $this->legacyReviewStatusFilterGroupDefinition );
1065  $this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition );
1066  }
1067 
1068  $changeTypeGroup = $this->getFilterGroup( 'changeType' );
1069 
1070  if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
1071  $transformedHideCategorizationDef = $this->transformFilterDefinition(
1072  $this->hideCategorizationFilterDefinition
1073  );
1074 
1075  $transformedHideCategorizationDef['group'] = $changeTypeGroup;
1076 
1077  $hideCategorization = new ChangesListBooleanFilter(
1078  $transformedHideCategorizationDef
1079  );
1080  }
1081 
1082  $this->getHookRunner()->onChangesListSpecialPageStructuredFilters( $this );
1083 
1084  $this->registerFiltersFromDefinitions( [] );
1085 
1086  $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' );
1087  $registered = $userExperienceLevel->getFilter( 'registered' );
1088  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'newcomer' ) );
1089  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'learner' ) );
1090  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'experienced' ) );
1091 
1092  $categoryFilter = $changeTypeGroup->getFilter( 'hidecategorization' );
1093  $logactionsFilter = $changeTypeGroup->getFilter( 'hidelog' );
1094  $pagecreationFilter = $changeTypeGroup->getFilter( 'hidenewpages' );
1095 
1096  $significanceTypeGroup = $this->getFilterGroup( 'significance' );
1097  $hideMinorFilter = $significanceTypeGroup->getFilter( 'hideminor' );
1098 
1099  // categoryFilter is conditional; see registerFilters
1100  if ( $categoryFilter !== null ) {
1101  $hideMinorFilter->conflictsWith(
1102  $categoryFilter,
1103  'rcfilters-hideminor-conflicts-typeofchange-global',
1104  'rcfilters-hideminor-conflicts-typeofchange',
1105  'rcfilters-typeofchange-conflicts-hideminor'
1106  );
1107  }
1108  $hideMinorFilter->conflictsWith(
1109  $logactionsFilter,
1110  'rcfilters-hideminor-conflicts-typeofchange-global',
1111  'rcfilters-hideminor-conflicts-typeofchange',
1112  'rcfilters-typeofchange-conflicts-hideminor'
1113  );
1114  $hideMinorFilter->conflictsWith(
1115  $pagecreationFilter,
1116  'rcfilters-hideminor-conflicts-typeofchange-global',
1117  'rcfilters-hideminor-conflicts-typeofchange',
1118  'rcfilters-typeofchange-conflicts-hideminor'
1119  );
1120  }
1121 
1131  protected function transformFilterDefinition( array $filterDefinition ) {
1132  return $filterDefinition;
1133  }
1134 
1145  protected function registerFiltersFromDefinitions( array $definition ) {
1146  $autoFillPriority = -1;
1147  foreach ( $definition as $groupDefinition ) {
1148  if ( !isset( $groupDefinition['priority'] ) ) {
1149  $groupDefinition['priority'] = $autoFillPriority;
1150  } else {
1151  // If it's explicitly specified, start over the auto-fill
1152  $autoFillPriority = $groupDefinition['priority'];
1153  }
1154 
1155  $autoFillPriority--;
1156 
1157  $className = $groupDefinition['class'];
1158  unset( $groupDefinition['class'] );
1159 
1160  foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
1161  $filterDefinition = $this->transformFilterDefinition( $filterDefinition );
1162  }
1163 
1164  $this->registerFilterGroup( new $className( $groupDefinition ) );
1165  }
1166  }
1167 
1171  protected function getLegacyShowHideFilters() {
1172  $filters = [];
1173  foreach ( $this->filterGroups as $group ) {
1174  if ( $group instanceof ChangesListBooleanFilterGroup ) {
1175  foreach ( $group->getFilters() as $key => $filter ) {
1176  if ( $filter->displaysOnUnstructuredUi() ) {
1177  $filters[ $key ] = $filter;
1178  }
1179  }
1180  }
1181  }
1182  return $filters;
1183  }
1184 
1193  public function setup( $parameters ) {
1194  $this->registerFilters();
1195 
1196  $opts = $this->getDefaultOptions();
1197 
1198  $opts = $this->fetchOptionsFromRequest( $opts );
1199 
1200  // Give precedence to subpage syntax
1201  if ( $parameters !== null ) {
1202  $this->parseParameters( $parameters, $opts );
1203  }
1204 
1205  $this->validateOptions( $opts );
1206 
1207  return $opts;
1208  }
1209 
1219  public function getDefaultOptions() {
1220  $opts = new FormOptions();
1221  $structuredUI = $this->isStructuredFilterUiEnabled();
1222  // If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
1223  $useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
1224 
1226  foreach ( $this->filterGroups as $filterGroup ) {
1227  $filterGroup->addOptions( $opts, $useDefaults, $structuredUI );
1228  }
1229 
1230  $opts->add( 'namespace', '', FormOptions::STRING );
1231  $opts->add( 'invert', false );
1232  $opts->add( 'associated', false );
1233  $opts->add( 'urlversion', 1 );
1234  $opts->add( 'tagfilter', '' );
1235 
1236  $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT );
1237  $opts->add( 'limit', $this->getDefaultLimit(), FormOptions::INT );
1238 
1239  $opts->add( 'from', '' );
1240 
1241  return $opts;
1242  }
1243 
1249  public function registerFilterGroup( ChangesListFilterGroup $group ) {
1250  $groupName = $group->getName();
1251 
1252  $this->filterGroups[$groupName] = $group;
1253  }
1254 
1260  protected function getFilterGroups() {
1261  return $this->filterGroups;
1262  }
1263 
1271  public function getFilterGroup( $groupName ) {
1272  return $this->filterGroups[$groupName] ?? null;
1273  }
1274 
1275  // Currently, this intentionally only includes filters that display
1276  // in the structured UI. This can be changed easily, though, if we want
1277  // to include data on filters that use the unstructured UI. messageKeys is a
1278  // special top-level value, with the value being an array of the message keys to
1279  // send to the client.
1280 
1288  public function getStructuredFilterJsData() {
1289  $output = [
1290  'groups' => [],
1291  'messageKeys' => [],
1292  ];
1293 
1294  usort( $this->filterGroups, function ( $a, $b ) {
1295  return $b->getPriority() <=> $a->getPriority();
1296  } );
1297 
1298  foreach ( $this->filterGroups as $groupName => $group ) {
1299  $groupOutput = $group->getJsData();
1300  if ( $groupOutput !== null ) {
1301  $output['messageKeys'] = array_merge(
1302  $output['messageKeys'],
1303  $groupOutput['messageKeys']
1304  );
1305 
1306  unset( $groupOutput['messageKeys'] );
1307  $output['groups'][] = $groupOutput;
1308  }
1309  }
1310 
1311  return $output;
1312  }
1313 
1322  protected function fetchOptionsFromRequest( $opts ) {
1323  $opts->fetchValuesFromRequest( $this->getRequest() );
1324 
1325  return $opts;
1326  }
1327 
1334  public function parseParameters( $par, FormOptions $opts ) {
1335  $stringParameterNameSet = [];
1336  $hideParameterNameSet = [];
1337 
1338  // URL parameters can be per-group, like 'userExpLevel',
1339  // or per-filter, like 'hideminor'.
1340 
1341  foreach ( $this->filterGroups as $filterGroup ) {
1342  if ( $filterGroup instanceof ChangesListStringOptionsFilterGroup ) {
1343  $stringParameterNameSet[$filterGroup->getName()] = true;
1344  } elseif ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1345  foreach ( $filterGroup->getFilters() as $filter ) {
1346  $hideParameterNameSet[$filter->getName()] = true;
1347  }
1348  }
1349  }
1350 
1351  $bits = preg_split( '/\s*,\s*/', trim( $par ) );
1352  foreach ( $bits as $bit ) {
1353  $m = [];
1354  if ( isset( $hideParameterNameSet[$bit] ) ) {
1355  // hidefoo => hidefoo=true
1356  $opts[$bit] = true;
1357  } elseif ( isset( $hideParameterNameSet["hide$bit"] ) ) {
1358  // foo => hidefoo=false
1359  $opts["hide$bit"] = false;
1360  } elseif ( preg_match( '/^(.*)=(.*)$/', $bit, $m ) ) {
1361  if ( isset( $stringParameterNameSet[$m[1]] ) ) {
1362  $opts[$m[1]] = $m[2];
1363  }
1364  }
1365  }
1366  }
1367 
1373  public function validateOptions( FormOptions $opts ) {
1374  $isContradictory = $this->fixContradictoryOptions( $opts );
1375  $isReplaced = $this->replaceOldOptions( $opts );
1376 
1377  if ( $isContradictory || $isReplaced ) {
1378  $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
1379  $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
1380  }
1381 
1382  $opts->validateIntBounds( 'limit', 0, 5000 );
1383  $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
1384  }
1385 
1392  private function fixContradictoryOptions( FormOptions $opts ) {
1393  $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
1394 
1395  foreach ( $this->filterGroups as $filterGroup ) {
1396  if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1397  $filters = $filterGroup->getFilters();
1398 
1399  if ( count( $filters ) === 1 ) {
1400  // legacy boolean filters should not be considered
1401  continue;
1402  }
1403 
1404  $allInGroupEnabled = array_reduce(
1405  $filters,
1406  function ( $carry, $filter ) use ( $opts ) {
1407  return $carry && $opts[ $filter->getName() ];
1408  },
1409  /* initialValue */ count( $filters ) > 0
1410  );
1411 
1412  if ( $allInGroupEnabled ) {
1413  foreach ( $filters as $filter ) {
1414  $opts[ $filter->getName() ] = false;
1415  }
1416 
1417  $fixed = true;
1418  }
1419  }
1420  }
1421 
1422  return $fixed;
1423  }
1424 
1434  private function fixBackwardsCompatibilityOptions( FormOptions $opts ) {
1435  if ( $opts['hideanons'] && $opts['hideliu'] ) {
1436  $opts->reset( 'hideanons' );
1437  if ( !$opts['hidebots'] ) {
1438  $opts->reset( 'hideliu' );
1439  $opts['hidehumans'] = 1;
1440  }
1441 
1442  return true;
1443  }
1444 
1445  return false;
1446  }
1447 
1454  public function replaceOldOptions( FormOptions $opts ) {
1455  if ( !$this->isStructuredFilterUiEnabled() ) {
1456  return false;
1457  }
1458 
1459  $changed = false;
1460 
1461  // At this point 'hideanons' and 'hideliu' cannot be both true,
1462  // because fixBackwardsCompatibilityOptions resets (at least) 'hideanons' in such case
1463  if ( $opts[ 'hideanons' ] ) {
1464  $opts->reset( 'hideanons' );
1465  $opts[ 'userExpLevel' ] = 'registered';
1466  $changed = true;
1467  }
1468 
1469  if ( $opts[ 'hideliu' ] ) {
1470  $opts->reset( 'hideliu' );
1471  $opts[ 'userExpLevel' ] = 'unregistered';
1472  $changed = true;
1473  }
1474 
1475  if ( $this->getFilterGroup( 'legacyReviewStatus' ) ) {
1476  if ( $opts[ 'hidepatrolled' ] ) {
1477  $opts->reset( 'hidepatrolled' );
1478  $opts[ 'reviewStatus' ] = 'unpatrolled';
1479  $changed = true;
1480  }
1481 
1482  if ( $opts[ 'hideunpatrolled' ] ) {
1483  $opts->reset( 'hideunpatrolled' );
1484  $opts[ 'reviewStatus' ] = implode(
1486  [ 'manual', 'auto' ]
1487  );
1488  $changed = true;
1489  }
1490  }
1491 
1492  return $changed;
1493  }
1494 
1503  protected function convertParamsForLink( $params ) {
1504  foreach ( $params as &$value ) {
1505  if ( $value === false ) {
1506  $value = '0';
1507  }
1508  }
1509  unset( $value );
1510  return $params;
1511  }
1512 
1524  protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
1525  &$join_conds, FormOptions $opts
1526  ) {
1527  $dbr = $this->getDB();
1528  $isStructuredUI = $this->isStructuredFilterUiEnabled();
1529 
1531  foreach ( $this->filterGroups as $filterGroup ) {
1532  $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1533  $query_options, $join_conds, $opts, $isStructuredUI );
1534  }
1535 
1536  // Namespace filtering
1537  if ( $opts[ 'namespace' ] !== '' ) {
1538  $namespaces = explode( ';', $opts[ 'namespace' ] );
1539 
1540  $namespaces = $this->expandSymbolicNamespaceFilters( $namespaces );
1541 
1542  $namespaceInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
1543  $namespaces = array_filter(
1544  $namespaces,
1545  function ( $ns ) use ( $namespaceInfo ) {
1546  return $namespaceInfo->exists( $ns );
1547  }
1548  );
1549 
1550  if ( $namespaces !== [] ) {
1551  // Namespaces are just ints, use them as int when acting with the database
1552  $namespaces = array_map( 'intval', $namespaces );
1553 
1554  if ( $opts[ 'associated' ] ) {
1555  $associatedNamespaces = array_map(
1556  function ( $ns ) use ( $namespaceInfo ){
1557  return $namespaceInfo->getAssociated( $ns );
1558  },
1559  array_filter(
1560  $namespaces,
1561  function ( $ns ) use ( $namespaceInfo ) {
1562  return $namespaceInfo->hasTalkNamespace( $ns );
1563  }
1564  )
1565  );
1566  $namespaces = array_unique( array_merge( $namespaces, $associatedNamespaces ) );
1567  }
1568 
1569  if ( count( $namespaces ) === 1 ) {
1570  $operator = $opts[ 'invert' ] ? '!=' : '=';
1571  $value = $dbr->addQuotes( reset( $namespaces ) );
1572  } else {
1573  $operator = $opts[ 'invert' ] ? 'NOT IN' : 'IN';
1574  sort( $namespaces );
1575  $value = '(' . $dbr->makeList( $namespaces ) . ')';
1576  }
1577  $conds[] = "rc_namespace $operator $value";
1578  }
1579  }
1580 
1581  // Calculate cutoff
1582  $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
1583  $cutoff = $dbr->timestamp( $cutoff_unixtime );
1584 
1585  $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
1586  if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
1587  $cutoff = $dbr->timestamp( $opts['from'] );
1588  } else {
1589  $opts->reset( 'from' );
1590  }
1591 
1592  $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
1593  }
1594 
1606  protected function doMainQuery( $tables, $fields, $conds,
1607  $query_options, $join_conds, FormOptions $opts
1608  ) {
1609  $rcQuery = RecentChange::getQueryInfo();
1610  $tables = array_merge( $tables, $rcQuery['tables'] );
1611  $fields = array_merge( $rcQuery['fields'], $fields );
1612  $join_conds = array_merge( $join_conds, $rcQuery['joins'] );
1613 
1615  $tables,
1616  $fields,
1617  $conds,
1618  $join_conds,
1619  $query_options,
1620  ''
1621  );
1622 
1623  if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
1624  $opts )
1625  ) {
1626  return false;
1627  }
1628 
1629  $dbr = $this->getDB();
1630 
1631  return $dbr->select(
1632  $tables,
1633  $fields,
1634  $conds,
1635  __METHOD__,
1636  $query_options,
1637  $join_conds
1638  );
1639  }
1640 
1641  protected function runMainQueryHook( &$tables, &$fields, &$conds,
1642  &$query_options, &$join_conds, $opts
1643  ) {
1644  return $this->getHookRunner()->onChangesListSpecialPageQuery(
1645  $this->getName(), $tables, $fields, $conds, $query_options, $join_conds, $opts );
1646  }
1647 
1653  protected function getDB() {
1654  return wfGetDB( DB_REPLICA );
1655  }
1656 
1663  private function webOutputHeader( $rowCount, $opts ) {
1664  if ( !$this->including() ) {
1665  $this->outputFeedLinks();
1666  $this->doHeader( $opts, $rowCount );
1667  }
1668  }
1669 
1676  public function webOutput( $rows, $opts ) {
1677  $this->webOutputHeader( $rows->numRows(), $opts );
1678 
1679  $this->outputChangesList( $rows, $opts );
1680  }
1681 
1685  public function outputFeedLinks() {
1686  // nothing by default
1687  }
1688 
1695  abstract public function outputChangesList( $rows, $opts );
1696 
1703  public function doHeader( $opts, $numRows ) {
1704  $this->setTopText( $opts );
1705 
1706  // @todo Lots of stuff should be done here.
1707 
1708  $this->setBottomText( $opts );
1709  }
1710 
1718  public function setTopText( FormOptions $opts ) {
1719  // nothing by default
1720  }
1721 
1729  public function setBottomText( FormOptions $opts ) {
1730  // nothing by default
1731  }
1732 
1742  public function getExtraOptions( $opts ) {
1743  return [];
1744  }
1745 
1751  public function makeLegend() {
1752  $context = $this->getContext();
1753  $user = $context->getUser();
1754  # The legend showing what the letters and stuff mean
1755  $legend = Html::openElement( 'dl' ) . "\n";
1756  # Iterates through them and gets the messages for both letter and tooltip
1757  $legendItems = $context->getConfig()->get( 'RecentChangesFlags' );
1758  if ( !( $user->useRCPatrol() || $user->useNPPatrol() ) ) {
1759  unset( $legendItems['unpatrolled'] );
1760  }
1761  foreach ( $legendItems as $key => $item ) { # generate items of the legend
1762  $label = $item['legend'] ?? $item['title'];
1763  $letter = $item['letter'];
1764  $cssClass = $item['class'] ?? $key;
1765 
1766  $legend .= Html::element( 'dt',
1767  [ 'class' => $cssClass ], $context->msg( $letter )->text()
1768  ) . "\n" .
1769  Html::rawElement( 'dd',
1770  [ 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ],
1771  $context->msg( $label )->parse()
1772  ) . "\n";
1773  }
1774  # (+-123)
1775  $legend .= Html::rawElement( 'dt',
1776  [ 'class' => 'mw-plusminus-pos' ],
1777  $context->msg( 'recentchanges-legend-plusminus' )->parse()
1778  ) . "\n";
1779  $legend .= Html::element(
1780  'dd',
1781  [ 'class' => 'mw-changeslist-legend-plusminus' ],
1782  $context->msg( 'recentchanges-label-plusminus' )->text()
1783  ) . "\n";
1784  // Watchlist expiry clock icon.
1785  if ( $context->getConfig()->get( 'WatchlistExpiry' ) ) {
1786  $widget = new IconWidget( [
1787  'icon' => 'clock',
1788  'classes' => [ 'mw-changesList-watchlistExpiry' ],
1789  ] );
1790  // Link the image to its label for assistive technologies.
1791  $watchlistLabelId = 'mw-changeslist-watchlistExpiry-label';
1792  $widget->getIconElement()->setAttributes( [
1793  'role' => 'img',
1794  'aria-labelledby' => $watchlistLabelId,
1795  ] );
1796  $legend .= Html::rawElement(
1797  'dt',
1798  [ 'class' => 'mw-changeslist-legend-watchlistexpiry' ],
1799  $widget
1800  );
1801  $legend .= Html::rawElement(
1802  'dd',
1803  [ 'class' => 'mw-changeslist-legend-watchlistexpiry', 'id' => $watchlistLabelId ],
1804  $context->msg( 'recentchanges-legend-watchlistexpiry' )->text()
1805  );
1806  }
1807  $legend .= Html::closeElement( 'dl' ) . "\n";
1808 
1809  $legendHeading = $this->isStructuredFilterUiEnabled() ?
1810  $context->msg( 'rcfilters-legend-heading' )->parse() :
1811  $context->msg( 'recentchanges-legend-heading' )->parse();
1812 
1813  # Collapsible
1814  $collapsedState = $this->getRequest()->getCookie( 'changeslist-state' );
1815  $collapsedClass = $collapsedState === 'collapsed' ? ' mw-collapsed' : '';
1816 
1817  $legend =
1818  '<div class="mw-changeslist-legend mw-collapsible' . $collapsedClass . '">' .
1819  $legendHeading .
1820  '<div class="mw-collapsible-content">' . $legend . '</div>' .
1821  '</div>';
1822 
1823  return $legend;
1824  }
1825 
1829  protected function addModules() {
1830  $out = $this->getOutput();
1831  // Styles and behavior for the legend box (see makeLegend())
1832  $out->addModuleStyles( [
1833  'mediawiki.interface.helpers.styles',
1834  'mediawiki.special.changeslist.legend',
1835  'mediawiki.special.changeslist',
1836  ] );
1837  $out->addModules( 'mediawiki.special.changeslist.legend.js' );
1838 
1839  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
1840  $out->addModules( 'mediawiki.rcfilters.filters.ui' );
1841  $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
1842  }
1843  }
1844 
1845  protected function getGroupName() {
1846  return 'changes';
1847  }
1848 
1865  public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
1866  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
1867  ) {
1868  global $wgLearnerEdits,
1872 
1873  $LEVEL_COUNT = 5;
1874 
1875  // If all levels are selected, don't filter
1876  if ( count( $selectedExpLevels ) === $LEVEL_COUNT ) {
1877  return;
1878  }
1879 
1880  // both 'registered' and 'unregistered', experience levels, if any, are included in 'registered'
1881  if (
1882  in_array( 'registered', $selectedExpLevels ) &&
1883  in_array( 'unregistered', $selectedExpLevels )
1884  ) {
1885  return;
1886  }
1887 
1888  $actorMigration = ActorMigration::newMigration();
1889  $actorQuery = $actorMigration->getJoin( 'rc_user' );
1890  $tables += $actorQuery['tables'];
1891  $join_conds += $actorQuery['joins'];
1892 
1893  // 'registered' but not 'unregistered', experience levels, if any, are included in 'registered'
1894  if (
1895  in_array( 'registered', $selectedExpLevels ) &&
1896  !in_array( 'unregistered', $selectedExpLevels )
1897  ) {
1898  $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1899  return;
1900  }
1901 
1902  if ( $selectedExpLevels === [ 'unregistered' ] ) {
1903  $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1904  return;
1905  }
1906 
1907  $tables[] = 'user';
1908  $join_conds['user'] = [ 'LEFT JOIN', $actorQuery['fields']['rc_user'] . ' = user_id' ];
1909 
1910  if ( $now === 0 ) {
1911  $now = time();
1912  }
1913  $secondsPerDay = 86400;
1914  $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
1915  $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
1916 
1917  $aboveNewcomer = $dbr->makeList(
1918  [
1919  'user_editcount >= ' . intval( $wgLearnerEdits ),
1920  'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ),
1921  ],
1923  );
1924 
1925  $aboveLearner = $dbr->makeList(
1926  [
1927  'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
1928  'user_registration <= ' .
1929  $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ),
1930  ],
1932  );
1933 
1934  $conditions = [];
1935 
1936  if ( in_array( 'unregistered', $selectedExpLevels ) ) {
1937  $selectedExpLevels = array_diff( $selectedExpLevels, [ 'unregistered' ] );
1938  $conditions[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1939  }
1940 
1941  if ( $selectedExpLevels === [ 'newcomer' ] ) {
1942  $conditions[] = "NOT ( $aboveNewcomer )";
1943  } elseif ( $selectedExpLevels === [ 'learner' ] ) {
1944  $conditions[] = $dbr->makeList(
1945  [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
1947  );
1948  } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
1949  $conditions[] = $aboveLearner;
1950  } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
1951  $conditions[] = "NOT ( $aboveLearner )";
1952  } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
1953  $conditions[] = $dbr->makeList(
1954  [ "NOT ( $aboveNewcomer )", $aboveLearner ],
1956  );
1957  } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
1958  $conditions[] = $aboveNewcomer;
1959  } elseif ( $selectedExpLevels === [ 'experienced', 'learner', 'newcomer' ] ) {
1960  $conditions[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1961  }
1962 
1963  if ( count( $conditions ) > 1 ) {
1964  $conds[] = $dbr->makeList( $conditions, IDatabase::LIST_OR );
1965  } elseif ( count( $conditions ) === 1 ) {
1966  $conds[] = reset( $conditions );
1967  }
1968  }
1969 
1975  public function isStructuredFilterUiEnabled() {
1976  if ( $this->getRequest()->getBool( 'rcfilters' ) ) {
1977  return true;
1978  }
1979 
1980  return static::checkStructuredFilterUiEnabled( $this->getUser() );
1981  }
1982 
1990  public static function checkStructuredFilterUiEnabled( $user ) {
1991  if ( $user instanceof Config ) {
1992  wfDeprecated( __METHOD__ . ' with Config argument', '1.34' );
1993  $user = func_get_arg( 1 );
1994  }
1995  return !$user->getOption( 'rcenhancedfilters-disable' );
1996  }
1997 
2005  public function getDefaultLimit() {
2006  return $this->getUser()->getIntOption( static::$limitPreferenceName );
2007  }
2008 
2017  public function getDefaultDays() {
2018  return floatval( $this->getUser()->getOption( static::$daysPreferenceName ) );
2019  }
2020 
2021  private function expandSymbolicNamespaceFilters( array $namespaces ) {
2022  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
2023  $symbolicFilters = [
2024  'all-contents' => $nsInfo->getSubjectNamespaces(),
2025  'all-discussions' => $nsInfo->getTalkNamespaces(),
2026  ];
2027  $additionalNamespaces = [];
2028  foreach ( $symbolicFilters as $name => $values ) {
2029  if ( in_array( $name, $namespaces ) ) {
2030  $additionalNamespaces = array_merge( $additionalNamespaces, $values );
2031  }
2032  }
2033  $namespaces = array_diff( $namespaces, array_keys( $symbolicFilters ) );
2034  $namespaces = array_merge( $namespaces, $additionalNamespaces );
2035  return array_unique( $namespaces );
2036  }
2037 }
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:697
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:246
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:827
ChangesListFilterGroup\getName
getName()
Definition: ChangesListFilterGroup.php:282
ChangesListSpecialPage\getExtraOptions
getExtraOptions( $opts)
Get options to be displayed in a form.
Definition: ChangesListSpecialPage.php:1742
ChangesListSpecialPage\__construct
__construct( $name, $restriction)
Definition: ChangesListSpecialPage.php:111
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:712
Sanitizer\stripAllTags
static stripAllTags( $html)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed,...
Definition: Sanitizer.php:1574
FormOptions\FLOAT
const FLOAT
Float type, maps guessType() to WebRequest::getFloat()
Definition: FormOptions.php:49
ChangesListSpecialPage\includeRcFiltersApp
includeRcFiltersApp()
Include the modules and configuration for the RCFilters app.
Definition: ChangesListSpecialPage.php:810
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:743
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:163
$wgExperiencedUserMemberSince
$wgExperiencedUserMemberSince
Specify the difference engine to use.
Definition: DefaultSettings.php:9403
ChangesListSpecialPage\makeLegend
makeLegend()
Return the legend displayed within the fieldset.
Definition: ChangesListSpecialPage.php:1751
ChangesListSpecialPage\execute
execute( $subpage)
Definition: ChangesListSpecialPage.php:623
ChangesListSpecialPage\webOutputHeader
webOutputHeader( $rowCount, $opts)
Send header output to the OutputPage object, only called if not using feeds.
Definition: ChangesListSpecialPage.php:1663
ChangesListSpecialPage\fixContradictoryOptions
fixContradictoryOptions(FormOptions $opts)
Fix invalid options by resetting pairs that should never appear together.
Definition: ChangesListSpecialPage.php:1392
ChangesListSpecialPage\parseParameters
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
Definition: ChangesListSpecialPage.php:1334
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1815
ChangesListSpecialPage\doMainQuery
doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.
Definition: ChangesListSpecialPage.php:1606
RC_LOG
const RC_LOG
Definition: Defines.php:133
ChangesListSpecialPage\expandSymbolicNamespaceFilters
expandSymbolicNamespaceFilters(array $namespaces)
Definition: ChangesListSpecialPage.php:2021
ChangesListSpecialPage\fixBackwardsCompatibilityOptions
fixBackwardsCompatibilityOptions(FormOptions $opts)
Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards compatibility.
Definition: ChangesListSpecialPage.php:1434
ChangesListSpecialPage
Special page which uses a ChangesList to show query results.
Definition: ChangesListSpecialPage.php:38
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:2017
$s
$s
Definition: mergeMessageFileList.php:184
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:92
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:976
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:1322
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1087
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:914
RecentChange\SRC_CATEGORIZE
const SRC_CATEGORIZE
Definition: RecentChange.php:80
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:164
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:78
ActorMigration\newMigration
static newMigration()
Static constructor.
Definition: ActorMigration.php:156
LIST_AND
const LIST_AND
Definition: Defines.php:48
ChangesListSpecialPage\outputNoResults
outputNoResults()
Add the "no results" message to the output.
Definition: ChangesListSpecialPage.php:998
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:1703
ChangesListSpecialPage\checkStructuredFilterUiEnabled
static checkStructuredFilterUiEnabled( $user)
Static method to check whether StructuredFilter UI is enabled for the given user.
Definition: ChangesListSpecialPage.php:1990
$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:169
$wgExperiencedUserEdits
$wgExperiencedUserEdits
Specify the difference engine to use.
Definition: DefaultSettings.php:9402
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:668
ChangesListSpecialPage\webOutput
webOutput( $rows, $opts)
Send output to the OutputPage object, only called if not used feeds.
Definition: ChangesListSpecialPage.php:1676
ChangeTags\modifyDisplayQuery
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
Definition: ChangeTags.php:773
Config
Interface for configuration instances.
Definition: Config.php:30
ChangesListSpecialPage\TAG_DESC_CHARACTER_LIMIT
const TAG_DESC_CHARACTER_LIMIT
Maximum length of a tag description in UTF-8 characters.
Definition: ChangesListSpecialPage.php:43
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:1010
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:793
ChangesListSpecialPage\$filterGroupDefinitions
array $filterGroupDefinitions
Definition information for the filters and their groups.
Definition: ChangesListSpecialPage.php:91
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that $function is deprecated.
Definition: GlobalFunctions.php:1027
ChangesListSpecialPage\$reviewStatusFilterGroupDefinition
$reviewStatusFilterGroupDefinition
Definition: ChangesListSpecialPage.php:98
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:72
Wikimedia\Rdbms\DBQueryTimeoutError
Error thrown when a query times out.
Definition: DBQueryTimeoutError.php:30
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:1503
ChangesListSpecialPage\getRcFiltersConfigVars
static getRcFiltersConfigVars(ResourceLoaderContext $context)
Get config vars to export with the mediawiki.rcfilters.filters.ui module.
Definition: ChangesListSpecialPage.php:886
ChangesListSpecialPage\getRows
getRows()
Get the database result for this special page instance.
Definition: ChangesListSpecialPage.php:1022
ChangesListSpecialPage\outputFeedLinks
outputFeedLinks()
Output feed links.
Definition: ChangesListSpecialPage.php:1685
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2459
ChangesListSpecialPage\runMainQueryHook
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
Definition: ChangesListSpecialPage.php:1641
ChangesListSpecialPage\isStructuredFilterUiEnabled
isStructuredFilterUiEnabled()
Check whether the structured filter UI is enabled.
Definition: ChangesListSpecialPage.php:1975
ChangesListSpecialPage\$daysPreferenceName
static string $daysPreferenceName
Preference name for 'days'.
Definition: ChangesListSpecialPage.php:55
ChangesListSpecialPage\$hideCategorizationFilterDefinition
$hideCategorizationFilterDefinition
Definition: ChangesListSpecialPage.php:101
ChangesListSpecialPage\getStructuredFilterJsData
getStructuredFilterJsData()
Gets structured filter information needed by JS.
Definition: ChangesListSpecialPage.php:1288
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:1260
$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:571
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:753
RecentChange\SRC_EDIT
const SRC_EDIT
Definition: RecentChange.php:76
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
ResourceLoaderContext\getLanguage
getLanguage()
Definition: ResourceLoaderContext.php:156
RecentChange\SRC_NEW
const SRC_NEW
Definition: RecentChange.php:77
ChangesListSpecialPage\buildQuery
buildQuery(&$tables, &$fields, &$conds, &$query_options, &$join_conds, FormOptions $opts)
Sets appropriate tables, fields, conditions, etc.
Definition: ChangesListSpecialPage.php:1524
ChangesListSpecialPage\getDefaultLimit
getDefaultLimit()
Get the default value of the number of changes to display when loading the result set.
Definition: ChangesListSpecialPage.php:2005
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:717
RecentChange\PRC_PATROLLED
const PRC_PATROLLED
Definition: RecentChange.php:83
ChangeTags\listExplicitlyDefinedTags
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the change_tag_def table of the database.
Definition: ChangeTags.php:1472
ChangesListSpecialPage\$rcOptions
FormOptions $rcOptions
Definition: ChangesListSpecialPage.php:73
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:1057
ChangesListSpecialPage\$savedQueriesPreferenceName
static string $savedQueriesPreferenceName
Preference name for saved queries.
Definition: ChangesListSpecialPage.php:49
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:41
ChangesListSpecialPage\setup
setup( $parameters)
Register all the filters, including legacy hook-driven ones.
Definition: ChangesListSpecialPage.php:1193
ChangesListSpecialPage\getChangeTagList
static getChangeTagList(ResourceLoaderContext $context)
Get information about change tags to export to JS via getRcFiltersConfigVars().
Definition: ChangesListSpecialPage.php:972
ChangesListSpecialPage\getFilterGroup
getFilterGroup( $groupName)
Gets a specified ChangesListFilterGroup by name.
Definition: ChangesListSpecialPage.php:1271
ChangesListSpecialPage\outputTimeout
outputTimeout()
Add the "timeout" message to the output.
Definition: ChangesListSpecialPage.php:1009
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:733
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:84
ChangeTags\listSoftwareActivatedTags
static listSoftwareActivatedTags()
Lists those tags which core or extensions report as being "active".
Definition: ChangeTags.php:1425
$wgLearnerEdits
$wgLearnerEdits
The following variables define 3 user experience levels:
Definition: DefaultSettings.php:9400
ChangesListSpecialPage\addModules
addModules()
Add page-specific modules.
Definition: ChangesListSpecialPage.php:1829
FormOptions\STRING
const STRING
String type, maps guessType() to WebRequest::getText()
Definition: FormOptions.php:43
ChangesListSpecialPage\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: ChangesListSpecialPage.php:1845
ChangesListSpecialPage\areFiltersInConflict
areFiltersInConflict()
Check if filters are in conflict and guaranteed to return no results.
Definition: ChangesListSpecialPage.php:583
ChangesListSpecialPage\getDefaultOptions
getDefaultOptions()
Get a FormOptions object containing the default options.
Definition: ChangesListSpecialPage.php:1219
ChangesListSpecialPage\transformFilterDefinition
transformFilterDefinition(array $filterDefinition)
Transforms filter definition to prepare it for constructor.
Definition: ChangesListSpecialPage.php:1131
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:1653
RecentChange\PRC_UNPATROLLED
const PRC_UNPATROLLED
Definition: RecentChange.php:82
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:109
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:67
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:9401
ChangesListSpecialPage\$rcSubpage
string $rcSubpage
Definition: ChangesListSpecialPage.php:70
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:1558
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:1865
ChangesListSpecialPage\replaceOldOptions
replaceOldOptions(FormOptions $opts)
Replace old options with their structured UI equivalents.
Definition: ChangesListSpecialPage.php:1454
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:1145
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:1729
ChangeTags\tagLongDescriptionMessage
static tagLongDescriptionMessage( $tag, MessageLocalizer $context)
Get the message object for the tag's long description.
Definition: ChangeTags.php:220
ChangesListSpecialPage\validateOptions
validateOptions(FormOptions $opts)
Validate a FormOptions object generated by getDefaultOptions() with values already populated.
Definition: ChangesListSpecialPage.php:1373
ChangesListSpecialPage\registerFilterGroup
registerFilterGroup(ChangesListFilterGroup $group)
Register a structured changes list filter group.
Definition: ChangesListSpecialPage.php:1249
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:1040
ChangesListSpecialPage\getLinkDays
getLinkDays()
Definition: ChangesListSpecialPage.php:782
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:662
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:251
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:61
ChangesListSpecialPage\getLegacyShowHideFilters
getLegacyShowHideFilters()
Definition: ChangesListSpecialPage.php:1171
ChangesListSpecialPage\$legacyReviewStatusFilterGroupDefinition
$legacyReviewStatusFilterGroupDefinition
Definition: ChangesListSpecialPage.php:95
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:346
ChangesListSpecialPage\setTopText
setTopText(FormOptions $opts)
Send the text to be displayed before the options.
Definition: ChangesListSpecialPage.php:1718
ChangesListSpecialPage\getRcFiltersConfigSummary
static getRcFiltersConfigSummary(ResourceLoaderContext $context)
Get essential data about getRcFiltersConfigVars() for change detection.
Definition: ChangesListSpecialPage.php:870