MediaWiki  master
ChangesListSpecialPage.php
Go to the documentation of this file.
1 <?php
27 use OOUI\IconWidget;
32 
39 abstract class ChangesListSpecialPage extends SpecialPage {
44  private const TAG_DESC_CHARACTER_LIMIT = 120;
45 
47  protected $rcSubpage;
48 
50  protected $rcOptions;
51 
52  // Order of both groups and filters is significant; first is top-most priority,
53  // descending from there.
54  // 'showHideSuffix' is a shortcut to and avoid spelling out
55  // details specific to subclasses here.
69 
75 
78 
81 
88  protected $filterGroups = [];
89 
90  public function __construct( $name, $restriction ) {
91  parent::__construct( $name, $restriction );
92 
93  $nonRevisionTypes = [ RC_LOG ];
94  $this->getHookRunner()->onSpecialWatchlistGetNonRevisionTypes( $nonRevisionTypes );
95 
96  $this->filterGroupDefinitions = [
97  [
98  'name' => 'registration',
99  'title' => 'rcfilters-filtergroup-registration',
100  'class' => ChangesListBooleanFilterGroup::class,
101  'filters' => [
102  [
103  'name' => 'hideliu',
104  // rcshowhideliu-show, rcshowhideliu-hide,
105  // wlshowhideliu
106  'showHideSuffix' => 'showhideliu',
107  'default' => false,
108  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
109  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
110  ) {
111  $conds['actor_user'] = null;
112  },
113  'isReplacedInStructuredUi' => true,
114 
115  ],
116  [
117  'name' => 'hideanons',
118  // rcshowhideanons-show, rcshowhideanons-hide,
119  // wlshowhideanons
120  'showHideSuffix' => 'showhideanons',
121  'default' => false,
122  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
123  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
124  ) {
125  $conds[] = 'actor_user IS NOT NULL';
126  },
127  'isReplacedInStructuredUi' => true,
128  ]
129  ],
130  ],
131 
132  [
133  'name' => 'userExpLevel',
134  'title' => 'rcfilters-filtergroup-user-experience-level',
135  'class' => ChangesListStringOptionsFilterGroup::class,
136  'isFullCoverage' => true,
137  'filters' => [
138  [
139  'name' => 'unregistered',
140  'label' => 'rcfilters-filter-user-experience-level-unregistered-label',
141  'description' => 'rcfilters-filter-user-experience-level-unregistered-description',
142  'cssClassSuffix' => 'user-unregistered',
143  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
144  return !$rc->getAttribute( 'rc_user' );
145  }
146  ],
147  [
148  'name' => 'registered',
149  'label' => 'rcfilters-filter-user-experience-level-registered-label',
150  'description' => 'rcfilters-filter-user-experience-level-registered-description',
151  'cssClassSuffix' => 'user-registered',
152  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
153  return $rc->getAttribute( 'rc_user' );
154  }
155  ],
156  [
157  'name' => 'newcomer',
158  'label' => 'rcfilters-filter-user-experience-level-newcomer-label',
159  'description' => 'rcfilters-filter-user-experience-level-newcomer-description',
160  'cssClassSuffix' => 'user-newcomer',
161  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
162  $performer = $rc->getPerformerIdentity();
163  return $performer->isRegistered() &&
164  MediaWikiServices::getInstance()
165  ->getUserFactory()
166  ->newFromUserIdentity( $performer )
167  ->getExperienceLevel() === 'newcomer';
168  }
169  ],
170  [
171  'name' => 'learner',
172  'label' => 'rcfilters-filter-user-experience-level-learner-label',
173  'description' => 'rcfilters-filter-user-experience-level-learner-description',
174  'cssClassSuffix' => 'user-learner',
175  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
176  $performer = $rc->getPerformerIdentity();
177  return $performer->isRegistered() &&
178  MediaWikiServices::getInstance()
179  ->getUserFactory()
180  ->newFromUserIdentity( $performer )
181  ->getExperienceLevel() === 'learner';
182  },
183  ],
184  [
185  'name' => 'experienced',
186  'label' => 'rcfilters-filter-user-experience-level-experienced-label',
187  'description' => 'rcfilters-filter-user-experience-level-experienced-description',
188  'cssClassSuffix' => 'user-experienced',
189  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
190  $performer = $rc->getPerformerIdentity();
191  return $performer->isRegistered() &&
192  MediaWikiServices::getInstance()
193  ->getUserFactory()
194  ->newFromUserIdentity( $performer )
195  ->getExperienceLevel() === 'experienced';
196  },
197  ]
198  ],
200  'queryCallable' => [ $this, 'filterOnUserExperienceLevel' ],
201  ],
202 
203  [
204  'name' => 'authorship',
205  'title' => 'rcfilters-filtergroup-authorship',
206  'class' => ChangesListBooleanFilterGroup::class,
207  'filters' => [
208  [
209  'name' => 'hidemyself',
210  'label' => 'rcfilters-filter-editsbyself-label',
211  'description' => 'rcfilters-filter-editsbyself-description',
212  // rcshowhidemine-show, rcshowhidemine-hide,
213  // wlshowhidemine
214  'showHideSuffix' => 'showhidemine',
215  'default' => false,
216  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
217  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
218  ) {
219  $user = $ctx->getUser();
220  $conds[] = 'actor_name<>' . $dbr->addQuotes( $user->getName() );
221  },
222  'cssClassSuffix' => 'self',
223  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
224  return $ctx->getUser()->equals( $rc->getPerformerIdentity() );
225  },
226  ],
227  [
228  'name' => 'hidebyothers',
229  'label' => 'rcfilters-filter-editsbyother-label',
230  'description' => 'rcfilters-filter-editsbyother-description',
231  'default' => false,
232  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
233  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
234  ) {
235  $user = $ctx->getUser();
236  if ( $user->isAnon() ) {
237  $conds['actor_name'] = $user->getName();
238  } else {
239  $conds['actor_user'] = $user->getId();
240  }
241  },
242  'cssClassSuffix' => 'others',
243  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
244  return !$ctx->getUser()->equals( $rc->getPerformerIdentity() );
245  },
246  ]
247  ]
248  ],
249 
250  [
251  'name' => 'automated',
252  'title' => 'rcfilters-filtergroup-automated',
253  'class' => ChangesListBooleanFilterGroup::class,
254  'filters' => [
255  [
256  'name' => 'hidebots',
257  'label' => 'rcfilters-filter-bots-label',
258  'description' => 'rcfilters-filter-bots-description',
259  // rcshowhidebots-show, rcshowhidebots-hide,
260  // wlshowhidebots
261  'showHideSuffix' => 'showhidebots',
262  'default' => false,
263  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
264  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
265  ) {
266  $conds['rc_bot'] = 0;
267  },
268  'cssClassSuffix' => 'bot',
269  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
270  return $rc->getAttribute( 'rc_bot' );
271  },
272  ],
273  [
274  'name' => 'hidehumans',
275  'label' => 'rcfilters-filter-humans-label',
276  'description' => 'rcfilters-filter-humans-description',
277  'default' => false,
278  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
279  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
280  ) {
281  $conds['rc_bot'] = 1;
282  },
283  'cssClassSuffix' => 'human',
284  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
285  return !$rc->getAttribute( 'rc_bot' );
286  },
287  ]
288  ]
289  ],
290 
291  // significance (conditional)
292 
293  [
294  'name' => 'significance',
295  'title' => 'rcfilters-filtergroup-significance',
296  'class' => ChangesListBooleanFilterGroup::class,
297  'priority' => -6,
298  'filters' => [
299  [
300  'name' => 'hideminor',
301  'label' => 'rcfilters-filter-minor-label',
302  'description' => 'rcfilters-filter-minor-description',
303  // rcshowhideminor-show, rcshowhideminor-hide,
304  // wlshowhideminor
305  'showHideSuffix' => 'showhideminor',
306  'default' => false,
307  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
308  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
309  ) {
310  $conds[] = 'rc_minor = 0';
311  },
312  'cssClassSuffix' => 'minor',
313  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
314  return $rc->getAttribute( 'rc_minor' );
315  }
316  ],
317  [
318  'name' => 'hidemajor',
319  'label' => 'rcfilters-filter-major-label',
320  'description' => 'rcfilters-filter-major-description',
321  'default' => false,
322  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
323  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
324  ) {
325  $conds[] = 'rc_minor = 1';
326  },
327  'cssClassSuffix' => 'major',
328  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
329  return !$rc->getAttribute( 'rc_minor' );
330  }
331  ]
332  ]
333  ],
334 
335  [
336  'name' => 'lastRevision',
337  'title' => 'rcfilters-filtergroup-lastrevision',
338  'class' => ChangesListBooleanFilterGroup::class,
339  'priority' => -7,
340  'filters' => [
341  [
342  'name' => 'hidelastrevision',
343  'label' => 'rcfilters-filter-lastrevision-label',
344  'description' => 'rcfilters-filter-lastrevision-description',
345  'default' => false,
346  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
347  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
348  ) use ( $nonRevisionTypes ) {
349  $conds[] = $dbr->makeList(
350  [
351  'rc_this_oldid <> page_latest',
352  'rc_type' => $nonRevisionTypes,
353  ],
354  LIST_OR
355  );
356  },
357  'cssClassSuffix' => 'last',
358  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
359  return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
360  }
361  ],
362  [
363  'name' => 'hidepreviousrevisions',
364  'label' => 'rcfilters-filter-previousrevision-label',
365  'description' => 'rcfilters-filter-previousrevision-description',
366  'default' => false,
367  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
368  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
369  ) use ( $nonRevisionTypes ) {
370  $conds[] = $dbr->makeList(
371  [
372  'rc_this_oldid = page_latest',
373  'rc_type' => $nonRevisionTypes,
374  ],
375  LIST_OR
376  );
377  },
378  'cssClassSuffix' => 'previous',
379  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
380  return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
381  }
382  ]
383  ]
384  ],
385 
386  // With extensions, there can be change types that will not be hidden by any of these.
387  [
388  'name' => 'changeType',
389  'title' => 'rcfilters-filtergroup-changetype',
390  'class' => ChangesListBooleanFilterGroup::class,
391  'priority' => -8,
392  'filters' => [
393  [
394  'name' => 'hidepageedits',
395  'label' => 'rcfilters-filter-pageedits-label',
396  'description' => 'rcfilters-filter-pageedits-description',
397  'default' => false,
398  'priority' => -2,
399  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
400  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
401  ) {
402  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
403  },
404  'cssClassSuffix' => 'src-mw-edit',
405  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
406  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_EDIT;
407  },
408  ],
409  [
410  'name' => 'hidenewpages',
411  'label' => 'rcfilters-filter-newpages-label',
412  'description' => 'rcfilters-filter-newpages-description',
413  'default' => false,
414  'priority' => -3,
415  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
416  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
417  ) {
418  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
419  },
420  'cssClassSuffix' => 'src-mw-new',
421  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
422  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_NEW;
423  },
424  ],
425 
426  // hidecategorization
427 
428  [
429  'name' => 'hidelog',
430  'label' => 'rcfilters-filter-logactions-label',
431  'description' => 'rcfilters-filter-logactions-description',
432  'default' => false,
433  'priority' => -5,
434  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
435  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
436  ) {
437  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
438  },
439  'cssClassSuffix' => 'src-mw-log',
440  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
441  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_LOG;
442  }
443  ],
444  ],
445  ],
446 
447  ];
448 
449  $this->legacyReviewStatusFilterGroupDefinition = [
450  [
451  'name' => 'legacyReviewStatus',
452  'title' => 'rcfilters-filtergroup-reviewstatus',
453  'class' => ChangesListBooleanFilterGroup::class,
454  'filters' => [
455  [
456  'name' => 'hidepatrolled',
457  // rcshowhidepatr-show, rcshowhidepatr-hide
458  // wlshowhidepatr
459  'showHideSuffix' => 'showhidepatr',
460  'default' => false,
461  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
462  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
463  ) {
464  $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
465  },
466  'isReplacedInStructuredUi' => true,
467  ],
468  [
469  'name' => 'hideunpatrolled',
470  'default' => false,
471  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
472  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
473  ) {
474  $conds[] = 'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED;
475  },
476  'isReplacedInStructuredUi' => true,
477  ],
478  ],
479  ]
480  ];
481 
482  $this->reviewStatusFilterGroupDefinition = [
483  [
484  'name' => 'reviewStatus',
485  'title' => 'rcfilters-filtergroup-reviewstatus',
486  'class' => ChangesListStringOptionsFilterGroup::class,
487  'isFullCoverage' => true,
488  'priority' => -5,
489  'filters' => [
490  [
491  'name' => 'unpatrolled',
492  'label' => 'rcfilters-filter-reviewstatus-unpatrolled-label',
493  'description' => 'rcfilters-filter-reviewstatus-unpatrolled-description',
494  'cssClassSuffix' => 'reviewstatus-unpatrolled',
495  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
496  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED;
497  },
498  ],
499  [
500  'name' => 'manual',
501  'label' => 'rcfilters-filter-reviewstatus-manual-label',
502  'description' => 'rcfilters-filter-reviewstatus-manual-description',
503  'cssClassSuffix' => 'reviewstatus-manual',
504  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
505  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_PATROLLED;
506  },
507  ],
508  [
509  'name' => 'auto',
510  'label' => 'rcfilters-filter-reviewstatus-auto-label',
511  'description' => 'rcfilters-filter-reviewstatus-auto-description',
512  'cssClassSuffix' => 'reviewstatus-auto',
513  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
514  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_AUTOPATROLLED;
515  },
516  ],
517  ],
519  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
520  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selected
521  ) {
522  if ( $selected === [] ) {
523  return;
524  }
525  $rcPatrolledValues = [
526  'unpatrolled' => RecentChange::PRC_UNPATROLLED,
527  'manual' => RecentChange::PRC_PATROLLED,
529  ];
530  // e.g. rc_patrolled IN (0, 2)
531  $conds['rc_patrolled'] = array_map( static function ( $s ) use ( $rcPatrolledValues ) {
532  return $rcPatrolledValues[ $s ];
533  }, $selected );
534  }
535  ]
536  ];
537 
538  $this->hideCategorizationFilterDefinition = [
539  'name' => 'hidecategorization',
540  'label' => 'rcfilters-filter-categorization-label',
541  'description' => 'rcfilters-filter-categorization-description',
542  // rcshowhidecategorization-show, rcshowhidecategorization-hide.
543  // wlshowhidecategorization
544  'showHideSuffix' => 'showhidecategorization',
545  'default' => false,
546  'priority' => -4,
547  'queryCallable' => static function ( string $specialClassName, IContextSource $ctx,
548  IDatabase $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds
549  ) {
550  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
551  },
552  'cssClassSuffix' => 'src-mw-categorize',
553  'isRowApplicableCallable' => static function ( IContextSource $ctx, RecentChange $rc ) {
554  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_CATEGORIZE;
555  },
556  ];
557  }
558 
564  protected function areFiltersInConflict() {
565  $opts = $this->getOptions();
567  foreach ( $this->getFilterGroups() as $group ) {
568  if ( $group->getConflictingGroups() ) {
569  wfLogWarning(
570  $group->getName() .
571  " specifies conflicts with other groups but these are not supported yet."
572  );
573  }
574 
576  foreach ( $group->getConflictingFilters() as $conflictingFilter ) {
577  if ( $conflictingFilter->activelyInConflictWithGroup( $group, $opts ) ) {
578  return true;
579  }
580  }
581 
583  foreach ( $group->getFilters() as $filter ) {
585  foreach ( $filter->getConflictingFilters() as $conflictingFilter ) {
586  if (
587  $conflictingFilter->activelyInConflictWithFilter( $filter, $opts ) &&
588  $filter->activelyInConflictWithFilter( $conflictingFilter, $opts )
589  ) {
590  return true;
591  }
592  }
593 
594  }
595 
596  }
597 
598  return false;
599  }
600 
604  public function execute( $subpage ) {
605  $this->rcSubpage = $subpage;
606 
607  $this->considerActionsForDefaultSavedQuery( $subpage );
608 
609  // Enable OOUI and module for the clock icon.
610  if ( $this->getConfig()->get( 'WatchlistExpiry' ) ) {
611  $this->getOutput()->enableOOUI();
612  $this->getOutput()->addModules( 'mediawiki.special.changeslist.watchlistexpiry' );
613  }
614 
615  $opts = $this->getOptions();
616  try {
617  $rows = $this->getRows();
618  if ( $rows === false ) {
619  $rows = new FakeResultWrapper( [] );
620  }
621 
622  // Used by Structured UI app to get results without MW chrome
623  if ( $this->getRequest()->getRawVal( 'action' ) === 'render' ) {
624  $this->getOutput()->setArticleBodyOnly( true );
625  }
626 
627  // Used by "live update" and "view newest" to check
628  // if there's new changes with minimal data transfer
629  if ( $this->getRequest()->getBool( 'peek' ) ) {
630  $code = $rows->numRows() > 0 ? 200 : 204;
631  $this->getOutput()->setStatusCode( $code );
632 
633  if ( $this->getUser()->isAnon() !==
634  $this->getRequest()->getFuzzyBool( 'isAnon' )
635  ) {
636  $this->getOutput()->setStatusCode( 205 );
637  }
638 
639  return;
640  }
641 
642  $linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
643  $batch = $linkBatchFactory->newLinkBatch();
644  foreach ( $rows as $row ) {
645  $batch->add( NS_USER, $row->rc_user_text );
646  $batch->add( NS_USER_TALK, $row->rc_user_text );
647  $batch->add( $row->rc_namespace, $row->rc_title );
648  if ( $row->rc_source === RecentChange::SRC_LOG ) {
649  $formatter = LogFormatter::newFromRow( $row );
650  foreach ( $formatter->getPreloadTitles() as $title ) {
651  $batch->addObj( $title );
652  }
653  }
654  }
655  $batch->execute();
656 
657  $this->setHeaders();
658  $this->outputHeader();
659  $this->addModules();
660  $this->webOutput( $rows, $opts );
661 
662  $rows->free();
663  } catch ( DBQueryTimeoutError $timeoutException ) {
664  MWExceptionHandler::logException( $timeoutException );
665 
666  $this->setHeaders();
667  $this->outputHeader();
668  $this->addModules();
669 
670  $this->getOutput()->setStatusCode( 500 );
671  $this->webOutputHeader( 0, $opts );
672  $this->outputTimeout();
673  }
674 
675  if ( $this->getConfig()->get( 'EnableWANCacheReaper' ) ) {
676  // Clean up any bad page entries for titles showing up in RC
678  $this->getDB(),
679  LoggerFactory::getInstance( 'objectcache' )
680  ) );
681  }
682 
683  $this->includeRcFiltersApp();
684  }
685 
693  protected function considerActionsForDefaultSavedQuery( $subpage ) {
694  if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) {
695  return;
696  }
697 
698  $knownParams = $this->getRequest()->getValues(
699  ...array_keys( $this->getOptions()->getAllValues() )
700  );
701 
702  // HACK: Temporarily until we can properly define "sticky" filters and parameters,
703  // we need to exclude several parameters we know should not be counted towards preventing
704  // the loading of defaults.
705  $excludedParams = [ 'limit' => '', 'days' => '', 'enhanced' => '', 'from' => '' ];
706  $knownParams = array_diff_key( $knownParams, $excludedParams );
707 
708  if (
709  // If there are NO known parameters in the URL request
710  // (that are not excluded) then we need to check into loading
711  // the default saved query
712  count( $knownParams ) === 0
713  ) {
714  // Get the saved queries data and parse it
715  $savedQueries = FormatJson::decode(
716  MediaWikiServices::getInstance()
717  ->getUserOptionsLookup()
718  ->getOption( $this->getUser(), $this->getSavedQueriesPreferenceName() ),
719  true
720  );
721 
722  if ( $savedQueries && isset( $savedQueries[ 'default' ] ) ) {
723  // Only load queries that are 'version' 2, since those
724  // have parameter representation
725  if ( isset( $savedQueries[ 'version' ] ) && $savedQueries[ 'version' ] === '2' ) {
726  $savedQueryDefaultID = $savedQueries[ 'default' ];
727  $defaultQuery = $savedQueries[ 'queries' ][ $savedQueryDefaultID ][ 'data' ];
728 
729  // Build the entire parameter list
730  $query = array_merge(
731  $defaultQuery[ 'params' ],
732  $defaultQuery[ 'highlights' ],
733  [
734  'urlversion' => '2',
735  ]
736  );
737  // Add to the query any parameters that we may have ignored before
738  // but are still valid and requested in the URL
739  $query = array_merge( $this->getRequest()->getValues(), $query );
740  unset( $query[ 'title' ] );
741  $this->getOutput()->redirect( $this->getPageTitle( $subpage )->getCanonicalURL( $query ) );
742  } else {
743  // There's a default, but the version is not 2, and the server can't
744  // actually recognize the query itself. This happens if it is before
745  // the conversion, so we need to tell the UI to reload saved query as
746  // it does the conversion to version 2
747  $this->getOutput()->addJsConfigVars(
748  'wgStructuredChangeFiltersDefaultSavedQueryExists',
749  true
750  );
751 
752  // Add the class that tells the frontend it is still loading
753  // another query
754  $this->getOutput()->addBodyClasses( 'mw-rcfilters-ui-loading' );
755  }
756  }
757  }
758  }
759 
765  protected function getLinkDays() {
766  $linkDays = $this->getConfig()->get( 'RCLinkDays' );
767  $filterByAge = $this->getConfig()->get( 'RCFilterByAge' );
768  $maxAge = $this->getConfig()->get( 'RCMaxAge' );
769  if ( $filterByAge ) {
770  // Trim it to only links which are within $wgRCMaxAge.
771  // Note that we allow one link higher than the max for things like
772  // "age 56 days" being accessible through the "60 days" link.
773  sort( $linkDays );
774 
775  $maxAgeDays = $maxAge / ( 3600 * 24 );
776  foreach ( $linkDays as $i => $days ) {
777  if ( $days >= $maxAgeDays ) {
778  array_splice( $linkDays, $i + 1 );
779  break;
780  }
781  }
782  }
783 
784  return $linkDays;
785  }
786 
793  protected function includeRcFiltersApp() {
794  $out = $this->getOutput();
795  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
796  $jsData = $this->getStructuredFilterJsData();
797  $messages = [];
798  foreach ( $jsData['messageKeys'] as $key ) {
799  $messages[$key] = $this->msg( $key )->plain();
800  }
801 
802  $out->addBodyClasses( 'mw-rcfilters-enabled' );
803  $collapsed = MediaWikiServices::getInstance()->getUserOptionsLookup()
804  ->getBoolOption( $this->getUser(), $this->getCollapsedPreferenceName() );
805  if ( $collapsed ) {
806  $out->addBodyClasses( 'mw-rcfilters-collapsed' );
807  }
808 
809  // These config and message exports should be moved into a ResourceLoader data module (T201574)
810  $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
811  $out->addJsConfigVars( 'wgStructuredChangeFiltersMessages', $messages );
812  $out->addJsConfigVars( 'wgStructuredChangeFiltersCollapsedState', $collapsed );
813 
814  $out->addJsConfigVars(
815  'StructuredChangeFiltersDisplayConfig',
816  [
817  'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
818  'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
819  'limitDefault' => $this->getDefaultLimit(),
820  'daysArray' => $this->getLinkDays(),
821  'daysDefault' => $this->getDefaultDays(),
822  ]
823  );
824 
825  $out->addJsConfigVars(
826  'wgStructuredChangeFiltersSavedQueriesPreferenceName',
828  );
829  $out->addJsConfigVars(
830  'wgStructuredChangeFiltersLimitPreferenceName',
831  $this->getLimitPreferenceName()
832  );
833  $out->addJsConfigVars(
834  'wgStructuredChangeFiltersDaysPreferenceName',
836  );
837  $out->addJsConfigVars(
838  'wgStructuredChangeFiltersCollapsedPreferenceName',
840  );
841  } else {
842  $out->addBodyClasses( 'mw-rcfilters-disabled' );
843  }
844  }
845 
854  public static function getRcFiltersConfigSummary( ResourceLoaderContext $context ) {
855  return [
856  // Reduce version computation by avoiding Message parsing
857  'RCFiltersChangeTags' => self::getChangeTagListSummary( $context ),
858  'StructuredChangeFiltersEditWatchlistUrl' =>
859  SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
860  ];
861  }
862 
870  public static function getRcFiltersConfigVars( ResourceLoaderContext $context ) {
871  return [
872  'RCFiltersChangeTags' => self::getChangeTagList( $context ),
873  'StructuredChangeFiltersEditWatchlistUrl' =>
874  SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
875  ];
876  }
877 
898  protected static function getChangeTagListSummary( ResourceLoaderContext $context ) {
899  $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
900  return $cache->getWithSetCallback(
901  $cache->makeKey( 'ChangesListSpecialPage-changeTagListSummary', $context->getLanguage() ),
902  WANObjectCache::TTL_DAY,
903  static function ( $oldValue, &$ttl, array &$setOpts ) use ( $context ) {
904  $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
905  $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
906 
907  $tagStats = ChangeTags::tagUsageStatistics();
908  $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
909 
910  $result = [];
911  foreach ( $tagHitCounts as $tagName => $hits ) {
912  if (
913  (
914  // Only get active tags
915  isset( $explicitlyDefinedTags[ $tagName ] ) ||
916  isset( $softwareActivatedTags[ $tagName ] )
917  ) &&
918  // Only get tags with more than 0 hits
919  $hits > 0
920  ) {
921  $labelMsg = ChangeTags::tagShortDescriptionMessage( $tagName, $context );
922  $descriptionMsg = ChangeTags::tagLongDescriptionMessage( $tagName, $context );
923  $result[] = [
924  'name' => $tagName,
925  'labelMsg' => $labelMsg,
926  'label' => $labelMsg ? $labelMsg->plain() : $tagName,
927  'descriptionMsg' => $descriptionMsg,
928  'description' => $descriptionMsg ? $descriptionMsg->plain() : '',
929  'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
930  'hits' => $hits,
931  ];
932  }
933  }
934  return $result;
935  }
936  );
937  }
938 
952  protected static function getChangeTagList( ResourceLoaderContext $context ) {
953  $tags = self::getChangeTagListSummary( $context );
954  $language = MediaWikiServices::getInstance()->getLanguageFactory()
955  ->getLanguage( $context->getLanguage() );
956  foreach ( $tags as &$tagInfo ) {
957  if ( $tagInfo['labelMsg'] ) {
958  $tagInfo['label'] = Sanitizer::stripAllTags( $tagInfo['labelMsg']->parse() );
959  } else {
960  $tagInfo['label'] = $context->msg( 'rcfilters-tag-hidden', $tagInfo['name'] )->text();
961  }
962  $tagInfo['description'] = $tagInfo['descriptionMsg'] ?
963  $language->truncateForVisual(
964  Sanitizer::stripAllTags( $tagInfo['descriptionMsg']->parse() ),
965  self::TAG_DESC_CHARACTER_LIMIT
966  ) :
967  '';
968  unset( $tagInfo['labelMsg'] );
969  unset( $tagInfo['descriptionMsg'] );
970  }
971 
972  // Instead of sorting by hit count (disabled for now), sort by display name
973  usort( $tags, static function ( $a, $b ) {
974  return strcasecmp( $a['label'], $b['label'] );
975  } );
976  return $tags;
977  }
978 
982  protected function outputNoResults() {
983  $this->getOutput()->addHTML(
985  'div',
986  [ 'class' => 'mw-changeslist-empty' ],
987  $this->msg( 'recentchanges-noresult' )->parse()
988  )
989  );
990  }
991 
995  protected function outputTimeout() {
996  $this->getOutput()->addHTML(
997  '<div class="mw-changeslist-empty mw-changeslist-timeout">' .
998  $this->msg( 'recentchanges-timeout' )->parse() .
999  '</div>'
1000  );
1001  }
1002 
1008  public function getRows() {
1009  $opts = $this->getOptions();
1010 
1011  $tables = [];
1012  $fields = [];
1013  $conds = [];
1014  $query_options = [];
1015  $join_conds = [];
1016  $this->buildQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
1017 
1018  return $this->doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
1019  }
1020 
1026  public function getOptions() {
1027  if ( $this->rcOptions === null ) {
1028  $this->rcOptions = $this->setup( $this->rcSubpage );
1029  }
1030 
1031  return $this->rcOptions;
1032  }
1033 
1043  protected function registerFilters() {
1044  $this->registerFiltersFromDefinitions( $this->filterGroupDefinitions );
1045 
1046  // Make sure this is not being transcluded (we don't want to show this
1047  // information to all users just because the user that saves the edit can
1048  // patrol or is logged in)
1049  if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
1050  $this->registerFiltersFromDefinitions( $this->legacyReviewStatusFilterGroupDefinition );
1051  $this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition );
1052  }
1053 
1054  $changeTypeGroup = $this->getFilterGroup( 'changeType' );
1055 
1056  if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
1057  $transformedHideCategorizationDef = $this->transformFilterDefinition(
1058  $this->hideCategorizationFilterDefinition
1059  );
1060 
1061  $transformedHideCategorizationDef['group'] = $changeTypeGroup;
1062 
1063  $hideCategorization = new ChangesListBooleanFilter(
1064  $transformedHideCategorizationDef
1065  );
1066  }
1067 
1068  $this->getHookRunner()->onChangesListSpecialPageStructuredFilters( $this );
1069 
1070  $this->registerFiltersFromDefinitions( [] );
1071 
1072  $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' );
1073  $registered = $userExperienceLevel->getFilter( 'registered' );
1074  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'newcomer' ) );
1075  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'learner' ) );
1076  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'experienced' ) );
1077 
1078  $categoryFilter = $changeTypeGroup->getFilter( 'hidecategorization' );
1079  $logactionsFilter = $changeTypeGroup->getFilter( 'hidelog' );
1080  $pagecreationFilter = $changeTypeGroup->getFilter( 'hidenewpages' );
1081 
1082  $significanceTypeGroup = $this->getFilterGroup( 'significance' );
1083  $hideMinorFilter = $significanceTypeGroup->getFilter( 'hideminor' );
1084 
1085  // categoryFilter is conditional; see registerFilters
1086  if ( $categoryFilter !== null ) {
1087  $hideMinorFilter->conflictsWith(
1088  $categoryFilter,
1089  'rcfilters-hideminor-conflicts-typeofchange-global',
1090  'rcfilters-hideminor-conflicts-typeofchange',
1091  'rcfilters-typeofchange-conflicts-hideminor'
1092  );
1093  }
1094  $hideMinorFilter->conflictsWith(
1095  $logactionsFilter,
1096  'rcfilters-hideminor-conflicts-typeofchange-global',
1097  'rcfilters-hideminor-conflicts-typeofchange',
1098  'rcfilters-typeofchange-conflicts-hideminor'
1099  );
1100  $hideMinorFilter->conflictsWith(
1101  $pagecreationFilter,
1102  'rcfilters-hideminor-conflicts-typeofchange-global',
1103  'rcfilters-hideminor-conflicts-typeofchange',
1104  'rcfilters-typeofchange-conflicts-hideminor'
1105  );
1106  }
1107 
1117  protected function transformFilterDefinition( array $filterDefinition ) {
1118  return $filterDefinition;
1119  }
1120 
1131  protected function registerFiltersFromDefinitions( array $definition ) {
1132  $autoFillPriority = -1;
1133  foreach ( $definition as $groupDefinition ) {
1134  if ( !isset( $groupDefinition['priority'] ) ) {
1135  $groupDefinition['priority'] = $autoFillPriority;
1136  } else {
1137  // If it's explicitly specified, start over the auto-fill
1138  $autoFillPriority = $groupDefinition['priority'];
1139  }
1140 
1141  $autoFillPriority--;
1142 
1143  $className = $groupDefinition['class'];
1144  unset( $groupDefinition['class'] );
1145 
1146  foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
1147  $filterDefinition = $this->transformFilterDefinition( $filterDefinition );
1148  }
1149 
1150  $this->registerFilterGroup( new $className( $groupDefinition ) );
1151  }
1152  }
1153 
1157  protected function getLegacyShowHideFilters() {
1158  $filters = [];
1159  foreach ( $this->filterGroups as $group ) {
1160  if ( $group instanceof ChangesListBooleanFilterGroup ) {
1161  foreach ( $group->getFilters() as $key => $filter ) {
1162  if ( $filter->displaysOnUnstructuredUi() ) {
1163  $filters[ $key ] = $filter;
1164  }
1165  }
1166  }
1167  }
1168  return $filters;
1169  }
1170 
1179  public function setup( $parameters ) {
1180  $this->registerFilters();
1181 
1182  $opts = $this->getDefaultOptions();
1183 
1184  $opts = $this->fetchOptionsFromRequest( $opts );
1185 
1186  // Give precedence to subpage syntax
1187  if ( $parameters !== null ) {
1188  $this->parseParameters( $parameters, $opts );
1189  }
1190 
1191  $this->validateOptions( $opts );
1192 
1193  return $opts;
1194  }
1195 
1205  public function getDefaultOptions() {
1206  $opts = new FormOptions();
1207  $structuredUI = $this->isStructuredFilterUiEnabled();
1208  // If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
1209  $useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
1210 
1212  foreach ( $this->filterGroups as $filterGroup ) {
1213  $filterGroup->addOptions( $opts, $useDefaults, $structuredUI );
1214  }
1215 
1216  $opts->add( 'namespace', '', FormOptions::STRING );
1217  $opts->add( 'invert', false );
1218  $opts->add( 'associated', false );
1219  $opts->add( 'urlversion', 1 );
1220  $opts->add( 'tagfilter', '' );
1221 
1222  $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT );
1223  $opts->add( 'limit', $this->getDefaultLimit(), FormOptions::INT );
1224 
1225  $opts->add( 'from', '' );
1226 
1227  return $opts;
1228  }
1229 
1235  public function registerFilterGroup( ChangesListFilterGroup $group ) {
1236  $groupName = $group->getName();
1237 
1238  $this->filterGroups[$groupName] = $group;
1239  }
1240 
1246  protected function getFilterGroups() {
1247  return $this->filterGroups;
1248  }
1249 
1257  public function getFilterGroup( $groupName ) {
1258  return $this->filterGroups[$groupName] ?? null;
1259  }
1260 
1261  // Currently, this intentionally only includes filters that display
1262  // in the structured UI. This can be changed easily, though, if we want
1263  // to include data on filters that use the unstructured UI. messageKeys is a
1264  // special top-level value, with the value being an array of the message keys to
1265  // send to the client.
1266 
1274  public function getStructuredFilterJsData() {
1275  $output = [
1276  'groups' => [],
1277  'messageKeys' => [],
1278  ];
1279 
1280  usort( $this->filterGroups, static function ( ChangesListFilterGroup $a, ChangesListFilterGroup $b ) {
1281  return $b->getPriority() <=> $a->getPriority();
1282  } );
1283 
1284  foreach ( $this->filterGroups as $groupName => $group ) {
1285  $groupOutput = $group->getJsData();
1286  if ( $groupOutput !== null ) {
1287  $output['messageKeys'] = array_merge(
1288  $output['messageKeys'],
1289  $groupOutput['messageKeys']
1290  );
1291 
1292  unset( $groupOutput['messageKeys'] );
1293  $output['groups'][] = $groupOutput;
1294  }
1295  }
1296 
1297  return $output;
1298  }
1299 
1308  protected function fetchOptionsFromRequest( $opts ) {
1309  $opts->fetchValuesFromRequest( $this->getRequest() );
1310 
1311  return $opts;
1312  }
1313 
1320  public function parseParameters( $par, FormOptions $opts ) {
1321  $stringParameterNameSet = [];
1322  $hideParameterNameSet = [];
1323 
1324  // URL parameters can be per-group, like 'userExpLevel',
1325  // or per-filter, like 'hideminor'.
1326 
1327  foreach ( $this->filterGroups as $filterGroup ) {
1328  if ( $filterGroup instanceof ChangesListStringOptionsFilterGroup ) {
1329  $stringParameterNameSet[$filterGroup->getName()] = true;
1330  } elseif ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1331  foreach ( $filterGroup->getFilters() as $filter ) {
1332  $hideParameterNameSet[$filter->getName()] = true;
1333  }
1334  }
1335  }
1336 
1337  $bits = preg_split( '/\s*,\s*/', trim( $par ) );
1338  foreach ( $bits as $bit ) {
1339  $m = [];
1340  if ( isset( $hideParameterNameSet[$bit] ) ) {
1341  // hidefoo => hidefoo=true
1342  $opts[$bit] = true;
1343  } elseif ( isset( $hideParameterNameSet["hide$bit"] ) ) {
1344  // foo => hidefoo=false
1345  $opts["hide$bit"] = false;
1346  } elseif ( preg_match( '/^(.*)=(.*)$/', $bit, $m ) ) {
1347  if ( isset( $stringParameterNameSet[$m[1]] ) ) {
1348  $opts[$m[1]] = $m[2];
1349  }
1350  }
1351  }
1352  }
1353 
1359  public function validateOptions( FormOptions $opts ) {
1360  $isContradictory = $this->fixContradictoryOptions( $opts );
1361  $isReplaced = $this->replaceOldOptions( $opts );
1362 
1363  if ( $isContradictory || $isReplaced ) {
1364  $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
1365  $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
1366  }
1367 
1368  $opts->validateIntBounds( 'limit', 0, 5000 );
1369  $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
1370  }
1371 
1378  private function fixContradictoryOptions( FormOptions $opts ) {
1379  $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
1380 
1381  foreach ( $this->filterGroups as $filterGroup ) {
1382  if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1383  $filters = $filterGroup->getFilters();
1384 
1385  if ( count( $filters ) === 1 ) {
1386  // legacy boolean filters should not be considered
1387  continue;
1388  }
1389 
1390  $allInGroupEnabled = array_reduce(
1391  $filters,
1392  static function ( bool $carry, ChangesListBooleanFilter $filter ) use ( $opts ) {
1393  return $carry && $opts[ $filter->getName() ];
1394  },
1395  /* initialValue */ count( $filters ) > 0
1396  );
1397 
1398  if ( $allInGroupEnabled ) {
1399  foreach ( $filters as $filter ) {
1400  $opts[ $filter->getName() ] = false;
1401  }
1402 
1403  $fixed = true;
1404  }
1405  }
1406  }
1407 
1408  return $fixed;
1409  }
1410 
1420  private function fixBackwardsCompatibilityOptions( FormOptions $opts ) {
1421  if ( $opts['hideanons'] && $opts['hideliu'] ) {
1422  $opts->reset( 'hideanons' );
1423  if ( !$opts['hidebots'] ) {
1424  $opts->reset( 'hideliu' );
1425  $opts['hidehumans'] = 1;
1426  }
1427 
1428  return true;
1429  }
1430 
1431  return false;
1432  }
1433 
1440  public function replaceOldOptions( FormOptions $opts ) {
1441  if ( !$this->isStructuredFilterUiEnabled() ) {
1442  return false;
1443  }
1444 
1445  $changed = false;
1446 
1447  // At this point 'hideanons' and 'hideliu' cannot be both true,
1448  // because fixBackwardsCompatibilityOptions resets (at least) 'hideanons' in such case
1449  if ( $opts[ 'hideanons' ] ) {
1450  $opts->reset( 'hideanons' );
1451  $opts[ 'userExpLevel' ] = 'registered';
1452  $changed = true;
1453  }
1454 
1455  if ( $opts[ 'hideliu' ] ) {
1456  $opts->reset( 'hideliu' );
1457  $opts[ 'userExpLevel' ] = 'unregistered';
1458  $changed = true;
1459  }
1460 
1461  if ( $this->getFilterGroup( 'legacyReviewStatus' ) ) {
1462  if ( $opts[ 'hidepatrolled' ] ) {
1463  $opts->reset( 'hidepatrolled' );
1464  $opts[ 'reviewStatus' ] = 'unpatrolled';
1465  $changed = true;
1466  }
1467 
1468  if ( $opts[ 'hideunpatrolled' ] ) {
1469  $opts->reset( 'hideunpatrolled' );
1470  $opts[ 'reviewStatus' ] = implode(
1472  [ 'manual', 'auto' ]
1473  );
1474  $changed = true;
1475  }
1476  }
1477 
1478  return $changed;
1479  }
1480 
1489  protected function convertParamsForLink( $params ) {
1490  foreach ( $params as &$value ) {
1491  if ( $value === false ) {
1492  $value = '0';
1493  }
1494  }
1495  unset( $value );
1496  return $params;
1497  }
1498 
1510  protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
1511  &$join_conds, FormOptions $opts
1512  ) {
1513  $dbr = $this->getDB();
1514  $isStructuredUI = $this->isStructuredFilterUiEnabled();
1515 
1517  foreach ( $this->filterGroups as $filterGroup ) {
1518  $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1519  $query_options, $join_conds, $opts, $isStructuredUI );
1520  }
1521 
1522  // Namespace filtering
1523  if ( $opts[ 'namespace' ] !== '' ) {
1524  $namespaces = explode( ';', $opts[ 'namespace' ] );
1525 
1526  $namespaces = $this->expandSymbolicNamespaceFilters( $namespaces );
1527 
1528  $namespaceInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
1529  $namespaces = array_filter(
1530  $namespaces,
1531  static function ( $ns ) use ( $namespaceInfo ) {
1532  return $namespaceInfo->exists( $ns );
1533  }
1534  );
1535 
1536  if ( $namespaces !== [] ) {
1537  // Namespaces are just ints, use them as int when acting with the database
1538  $namespaces = array_map( 'intval', $namespaces );
1539 
1540  if ( $opts[ 'associated' ] ) {
1541  $associatedNamespaces = array_map(
1542  static function ( $ns ) use ( $namespaceInfo ){
1543  return $namespaceInfo->getAssociated( $ns );
1544  },
1545  array_filter(
1546  $namespaces,
1547  static function ( $ns ) use ( $namespaceInfo ) {
1548  return $namespaceInfo->hasTalkNamespace( $ns );
1549  }
1550  )
1551  );
1552  $namespaces = array_unique( array_merge( $namespaces, $associatedNamespaces ) );
1553  }
1554 
1555  if ( count( $namespaces ) === 1 ) {
1556  $operator = $opts[ 'invert' ] ? '!=' : '=';
1557  $value = $dbr->addQuotes( reset( $namespaces ) );
1558  } else {
1559  $operator = $opts[ 'invert' ] ? 'NOT IN' : 'IN';
1560  sort( $namespaces );
1561  $value = '(' . $dbr->makeList( $namespaces ) . ')';
1562  }
1563  $conds[] = "rc_namespace $operator $value";
1564  }
1565  }
1566 
1567  // Calculate cutoff
1568  $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
1569  $cutoff = $dbr->timestamp( $cutoff_unixtime );
1570 
1571  $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
1572  if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
1573  $cutoff = $dbr->timestamp( $opts['from'] );
1574  } else {
1575  $opts->reset( 'from' );
1576  }
1577 
1578  $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
1579  }
1580 
1592  protected function doMainQuery( $tables, $fields, $conds,
1593  $query_options, $join_conds, FormOptions $opts
1594  ) {
1595  $rcQuery = RecentChange::getQueryInfo();
1596  $tables = array_merge( $tables, $rcQuery['tables'] );
1597  $fields = array_merge( $rcQuery['fields'], $fields );
1598  $join_conds = array_merge( $join_conds, $rcQuery['joins'] );
1599 
1601  $tables,
1602  $fields,
1603  $conds,
1604  $join_conds,
1605  $query_options,
1606  ''
1607  );
1608 
1609  if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
1610  $opts )
1611  ) {
1612  return false;
1613  }
1614 
1615  $dbr = $this->getDB();
1616 
1617  return $dbr->select(
1618  $tables,
1619  $fields,
1620  $conds,
1621  __METHOD__,
1622  $query_options,
1623  $join_conds
1624  );
1625  }
1626 
1627  protected function runMainQueryHook( &$tables, &$fields, &$conds,
1628  &$query_options, &$join_conds, $opts
1629  ) {
1630  return $this->getHookRunner()->onChangesListSpecialPageQuery(
1631  $this->getName(), $tables, $fields, $conds, $query_options, $join_conds, $opts );
1632  }
1633 
1639  protected function getDB() {
1640  return wfGetDB( DB_REPLICA );
1641  }
1642 
1649  private function webOutputHeader( $rowCount, $opts ) {
1650  if ( !$this->including() ) {
1651  $this->outputFeedLinks();
1652  $this->doHeader( $opts, $rowCount );
1653  }
1654  }
1655 
1662  public function webOutput( $rows, $opts ) {
1663  $this->webOutputHeader( $rows->numRows(), $opts );
1664 
1665  $this->outputChangesList( $rows, $opts );
1666  }
1667 
1668  public function outputFeedLinks() {
1669  // nothing by default
1670  }
1671 
1678  abstract public function outputChangesList( $rows, $opts );
1679 
1686  public function doHeader( $opts, $numRows ) {
1687  $this->setTopText( $opts );
1688 
1689  // @todo Lots of stuff should be done here.
1690 
1691  $this->setBottomText( $opts );
1692  }
1693 
1701  public function setTopText( FormOptions $opts ) {
1702  // nothing by default
1703  }
1704 
1712  public function setBottomText( FormOptions $opts ) {
1713  // nothing by default
1714  }
1715 
1725  public function getExtraOptions( $opts ) {
1726  return [];
1727  }
1728 
1734  public function makeLegend() {
1735  $context = $this->getContext();
1736  $user = $context->getUser();
1737  # The legend showing what the letters and stuff mean
1738  $legend = Html::openElement( 'dl' ) . "\n";
1739  # Iterates through them and gets the messages for both letter and tooltip
1740  $legendItems = $context->getConfig()->get( 'RecentChangesFlags' );
1741  if ( !( $user->useRCPatrol() || $user->useNPPatrol() ) ) {
1742  unset( $legendItems['unpatrolled'] );
1743  }
1744  foreach ( $legendItems as $key => $item ) { # generate items of the legend
1745  $label = $item['legend'] ?? $item['title'];
1746  $letter = $item['letter'];
1747  $cssClass = $item['class'] ?? $key;
1748 
1749  $legend .= Html::element( 'dt',
1750  [ 'class' => $cssClass ], $context->msg( $letter )->text()
1751  ) . "\n" .
1752  Html::rawElement( 'dd',
1753  [ 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ],
1754  $context->msg( $label )->parse()
1755  ) . "\n";
1756  }
1757  # (+-123)
1758  $legend .= Html::rawElement( 'dt',
1759  [ 'class' => 'mw-plusminus-pos' ],
1760  $context->msg( 'recentchanges-legend-plusminus' )->parse()
1761  ) . "\n";
1762  $legend .= Html::element(
1763  'dd',
1764  [ 'class' => 'mw-changeslist-legend-plusminus' ],
1765  $context->msg( 'recentchanges-label-plusminus' )->text()
1766  ) . "\n";
1767  // Watchlist expiry clock icon.
1768  if ( $context->getConfig()->get( 'WatchlistExpiry' ) ) {
1769  $widget = new IconWidget( [
1770  'icon' => 'clock',
1771  'classes' => [ 'mw-changesList-watchlistExpiry' ],
1772  ] );
1773  // Link the image to its label for assistive technologies.
1774  $watchlistLabelId = 'mw-changeslist-watchlistExpiry-label';
1775  $widget->getIconElement()->setAttributes( [
1776  'role' => 'img',
1777  'aria-labelledby' => $watchlistLabelId,
1778  ] );
1779  $legend .= Html::rawElement(
1780  'dt',
1781  [ 'class' => 'mw-changeslist-legend-watchlistexpiry' ],
1782  $widget
1783  );
1784  $legend .= Html::element(
1785  'dd',
1786  [ 'class' => 'mw-changeslist-legend-watchlistexpiry', 'id' => $watchlistLabelId ],
1787  $context->msg( 'recentchanges-legend-watchlistexpiry' )->text()
1788  );
1789  }
1790  $legend .= Html::closeElement( 'dl' ) . "\n";
1791 
1792  $legendHeading = $this->isStructuredFilterUiEnabled() ?
1793  $context->msg( 'rcfilters-legend-heading' )->parse() :
1794  $context->msg( 'recentchanges-legend-heading' )->parse();
1795 
1796  # Collapsible
1797  $collapsedState = $this->getRequest()->getCookie( 'changeslist-state' );
1798  $collapsedClass = $collapsedState === 'collapsed' ? 'mw-collapsed' : '';
1799 
1800  $legend = Html::rawElement(
1801  'div',
1802  [ 'class' => [ 'mw-changeslist-legend', 'mw-collapsible', $collapsedClass ] ],
1803  $legendHeading .
1804  Html::rawElement( 'div', [ 'class' => 'mw-collapsible-content' ], $legend )
1805  );
1806 
1807  return $legend;
1808  }
1809 
1813  protected function addModules() {
1814  $out = $this->getOutput();
1815  // Styles and behavior for the legend box (see makeLegend())
1816  $out->addModuleStyles( [
1817  'mediawiki.interface.helpers.styles',
1818  'mediawiki.special.changeslist.legend',
1819  'mediawiki.special.changeslist',
1820  ] );
1821  $out->addModules( 'mediawiki.special.changeslist.legend.js' );
1822 
1823  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
1824  $out->addModules( 'mediawiki.rcfilters.filters.ui' );
1825  $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
1826  }
1827  }
1828 
1829  protected function getGroupName() {
1830  return 'changes';
1831  }
1832 
1849  public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
1850  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
1851  ) {
1852  global $wgLearnerEdits,
1856 
1857  $LEVEL_COUNT = 5;
1858 
1859  // If all levels are selected, don't filter
1860  if ( count( $selectedExpLevels ) === $LEVEL_COUNT ) {
1861  return;
1862  }
1863 
1864  // both 'registered' and 'unregistered', experience levels, if any, are included in 'registered'
1865  if (
1866  in_array( 'registered', $selectedExpLevels ) &&
1867  in_array( 'unregistered', $selectedExpLevels )
1868  ) {
1869  return;
1870  }
1871 
1872  // 'registered' but not 'unregistered', experience levels, if any, are included in 'registered'
1873  if (
1874  in_array( 'registered', $selectedExpLevels ) &&
1875  !in_array( 'unregistered', $selectedExpLevels )
1876  ) {
1877  $conds[] = 'actor_user IS NOT NULL';
1878  return;
1879  }
1880 
1881  if ( $selectedExpLevels === [ 'unregistered' ] ) {
1882  $conds['actor_user'] = null;
1883  return;
1884  }
1885 
1886  $tables[] = 'user';
1887  $join_conds['user'] = [ 'LEFT JOIN', 'actor_user=user_id' ];
1888 
1889  if ( $now === 0 ) {
1890  $now = time();
1891  }
1892  $secondsPerDay = 86400;
1893  $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
1894  $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
1895 
1896  $aboveNewcomer = $dbr->makeList(
1897  [
1898  'user_editcount >= ' . intval( $wgLearnerEdits ),
1899  $dbr->makeList( [
1900  'user_registration IS NULL',
1901  'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ),
1902  ], IDatabase::LIST_OR ),
1903  ],
1905  );
1906 
1907  $aboveLearner = $dbr->makeList(
1908  [
1909  'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
1910  $dbr->makeList( [
1911  'user_registration IS NULL',
1912  'user_registration <= ' .
1913  $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ),
1914  ], IDatabase::LIST_OR ),
1915  ],
1917  );
1918 
1919  $conditions = [];
1920 
1921  if ( in_array( 'unregistered', $selectedExpLevels ) ) {
1922  $selectedExpLevels = array_diff( $selectedExpLevels, [ 'unregistered' ] );
1923  $conditions['actor_user'] = null;
1924  }
1925 
1926  if ( $selectedExpLevels === [ 'newcomer' ] ) {
1927  $conditions[] = "NOT ( $aboveNewcomer )";
1928  } elseif ( $selectedExpLevels === [ 'learner' ] ) {
1929  $conditions[] = $dbr->makeList(
1930  [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
1932  );
1933  } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
1934  $conditions[] = $aboveLearner;
1935  } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
1936  $conditions[] = "NOT ( $aboveLearner )";
1937  } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
1938  $conditions[] = $dbr->makeList(
1939  [ "NOT ( $aboveNewcomer )", $aboveLearner ],
1941  );
1942  } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
1943  $conditions[] = $aboveNewcomer;
1944  } elseif ( $selectedExpLevels === [ 'experienced', 'learner', 'newcomer' ] ) {
1945  $conditions[] = 'actor_user IS NOT NULL';
1946  }
1947 
1948  if ( count( $conditions ) > 1 ) {
1949  $conds[] = $dbr->makeList( $conditions, IDatabase::LIST_OR );
1950  } elseif ( count( $conditions ) === 1 ) {
1951  $conds[] = reset( $conditions );
1952  }
1953  }
1954 
1960  public function isStructuredFilterUiEnabled() {
1961  if ( $this->getRequest()->getBool( 'rcfilters' ) ) {
1962  return true;
1963  }
1964 
1965  return static::checkStructuredFilterUiEnabled( $this->getUser() );
1966  }
1967 
1975  public static function checkStructuredFilterUiEnabled( $user ) {
1976  if ( $user instanceof Config ) {
1977  wfDeprecated( __METHOD__ . ' with Config argument', '1.34' );
1978  $user = func_get_arg( 1 );
1979  }
1980  return !MediaWikiServices::getInstance()
1981  ->getUserOptionsLookup()
1982  ->getOption( $user, 'rcenhancedfilters-disable' );
1983  }
1984 
1992  public function getDefaultLimit() {
1993  return MediaWikiServices::getInstance()
1994  ->getUserOptionsLookup()
1995  ->getIntOption( $this->getUser(), $this->getLimitPreferenceName() );
1996  }
1997 
2006  public function getDefaultDays() {
2007  return floatval( MediaWikiServices::getInstance()
2008  ->getUserOptionsLookup()
2009  ->getOption( $this->getUser(), $this->getDefaultDaysPreferenceName() ) );
2010  }
2011 
2018  abstract protected function getLimitPreferenceName(): string;
2019 
2026  abstract protected function getSavedQueriesPreferenceName(): string;
2027 
2034  abstract protected function getDefaultDaysPreferenceName(): string;
2035 
2042  abstract protected function getCollapsedPreferenceName(): string;
2043 
2048  private function expandSymbolicNamespaceFilters( array $namespaces ) {
2049  $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
2050  $symbolicFilters = [
2051  'all-contents' => $nsInfo->getSubjectNamespaces(),
2052  'all-discussions' => $nsInfo->getTalkNamespaces(),
2053  ];
2054  $additionalNamespaces = [];
2055  foreach ( $symbolicFilters as $name => $values ) {
2056  if ( in_array( $name, $namespaces ) ) {
2057  $additionalNamespaces = array_merge( $additionalNamespaces, $values );
2058  }
2059  }
2060  $namespaces = array_diff( $namespaces, array_keys( $symbolicFilters ) );
2061  $namespaces = array_merge( $namespaces, $additionalNamespaces );
2062  return array_unique( $namespaces );
2063  }
2064 }
LIST_OR
const LIST_OR
Definition: Defines.php:46
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:744
ResourceLoaderContext
Context object that contains information about the state of a specific ResourceLoader web request.
Definition: ResourceLoaderContext.php:34
RecentChange\getQueryInfo
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new recentchanges object.
Definition: RecentChange.php:257
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:912
ChangesListFilterGroup\getName
getName()
Definition: ChangesListFilterGroup.php:282
ChangesListSpecialPage\getExtraOptions
getExtraOptions( $opts)
Get options to be displayed in a form.
Definition: ChangesListSpecialPage.php:1725
ChangesListSpecialPage\__construct
__construct( $name, $restriction)
Definition: ChangesListSpecialPage.php:90
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:693
RC_EDIT
const RC_EDIT
Definition: Defines.php:115
Sanitizer\stripAllTags
static stripAllTags( $html)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed,...
Definition: Sanitizer.php:1577
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:793
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:790
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:200
$wgExperiencedUserMemberSince
$wgExperiencedUserMemberSince
Number of days the user must exist before becoming "experienced".
Definition: DefaultSettings.php:5145
ChangesListSpecialPage\makeLegend
makeLegend()
Return the legend displayed within the fieldset.
Definition: ChangesListSpecialPage.php:1734
ChangesListSpecialPage\execute
execute( $subpage)
Definition: ChangesListSpecialPage.php:604
ChangesListSpecialPage\webOutputHeader
webOutputHeader( $rowCount, $opts)
Send header output to the OutputPage object, only called if not using feeds.
Definition: ChangesListSpecialPage.php:1649
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:80
ChangesListSpecialPage\fixContradictoryOptions
fixContradictoryOptions(FormOptions $opts)
Fix invalid options by resetting pairs that should never appear together.
Definition: ChangesListSpecialPage.php:1378
ChangesListSpecialPage\parseParameters
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
Definition: ChangesListSpecialPage.php:1320
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1657
ChangesListSpecialPage\doMainQuery
doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.
Definition: ChangesListSpecialPage.php:1592
LIST_AND
const LIST_AND
Definition: Defines.php:43
ChangesListSpecialPage\expandSymbolicNamespaceFilters
expandSymbolicNamespaceFilters(array $namespaces)
Definition: ChangesListSpecialPage.php:2048
ChangesListSpecialPage\fixBackwardsCompatibilityOptions
fixBackwardsCompatibilityOptions(FormOptions $opts)
Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards compatibility.
Definition: ChangesListSpecialPage.php:1420
ChangesListSpecialPage
Special page which uses a ChangesList to show query results.
Definition: ChangesListSpecialPage.php:39
DeferredUpdates\addUpdate
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the pending update queue for execution at the appropriate time.
Definition: DeferredUpdates.php:119
ChangesListSpecialPage\$legacyReviewStatusFilterGroupDefinition
array $legacyReviewStatusFilterGroupDefinition
Same format as filterGroupDefinitions, but for a single group (reviewStatus) that is registered condi...
Definition: ChangesListSpecialPage.php:74
ChangesListBooleanFilter
Represents a hide-based boolean filter (used on ChangesListSpecialPage and descendants)
Definition: ChangesListBooleanFilter.php:31
WANCacheReapUpdate
Class for fixing stale WANObjectCache keys using a purge event source.
Definition: WANCacheReapUpdate.php:26
ChangesListFilter\getName
getName()
Definition: ChangesListFilter.php:269
ChangesListSpecialPage\getDefaultDays
getDefaultDays()
Get the default value of the number of days to display when loading the result set.
Definition: ChangesListSpecialPage.php:2006
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:107
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:973
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:1308
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1048
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:898
RecentChange\SRC_CATEGORIZE
const SRC_CATEGORIZE
Definition: RecentChange.php:89
RC_NEW
const RC_NEW
Definition: Defines.php:116
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:179
Wikimedia\Rdbms\FakeResultWrapper
Overloads the relevant methods of the real ResultWrapper so it doesn't go anywhere near an actual dat...
Definition: FakeResultWrapper.php:12
ChangesListFilterGroup
Represents a filter group (used on ChangesListSpecialPage and descendants)
Definition: ChangesListFilterGroup.php:37
RecentChange\SRC_LOG
const SRC_LOG
Definition: RecentChange.php:87
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:39
ChangesListSpecialPage\outputNoResults
outputNoResults()
Add the "no results" message to the output.
Definition: ChangesListSpecialPage.php:982
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:1686
ChangesListSpecialPage\checkStructuredFilterUiEnabled
static checkStructuredFilterUiEnabled( $user)
Static method to check whether StructuredFilter UI is enabled for the given user.
Definition: ChangesListSpecialPage.php:1975
$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:249
$wgExperiencedUserEdits
$wgExperiencedUserEdits
Number of edits the user must have before becoming "experienced".
Definition: DefaultSettings.php:5139
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:316
MWExceptionHandler\logException
static logException(Throwable $e, $catcher=self::CAUGHT_BY_OTHER, $extraData=[])
Log a throwable to the exception log (if enabled).
Definition: MWExceptionHandler.php:700
RC_LOG
const RC_LOG
Definition: Defines.php:117
ChangesListSpecialPage\webOutput
webOutput( $rows, $opts)
Send output to the OutputPage object, only called if not used feeds.
Definition: ChangesListSpecialPage.php:1662
ChangeTags\modifyDisplayQuery
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
Definition: ChangeTags.php:891
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:44
FormatJson\decode
static decode( $value, $assoc=false)
Decodes a JSON string.
Definition: FormatJson.php:146
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1095
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:878
ChangesListSpecialPage\$filterGroupDefinitions
array $filterGroupDefinitions
Definition information for the filters and their groups.
Definition: ChangesListSpecialPage.php:68
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Definition: GlobalFunctions.php:989
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:74
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:26
ChangesListSpecialPage\convertParamsForLink
convertParamsForLink( $params)
Convert parameters values from true/false to 1/0 so they are not omitted by wfArrayToCgi() T38524.
Definition: ChangesListSpecialPage.php:1489
ChangesListSpecialPage\getRcFiltersConfigVars
static getRcFiltersConfigVars(ResourceLoaderContext $context)
Get config vars to export with the mediawiki.rcfilters.filters.ui module.
Definition: ChangesListSpecialPage.php:870
ChangesListSpecialPage\getRows
getRows()
Get the database result for this special page instance.
Definition: ChangesListSpecialPage.php:1008
ChangesListSpecialPage\outputFeedLinks
outputFeedLinks()
Definition: ChangesListSpecialPage.php:1668
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2192
ChangesListSpecialPage\runMainQueryHook
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
Definition: ChangesListSpecialPage.php:1627
ChangesListSpecialPage\isStructuredFilterUiEnabled
isStructuredFilterUiEnabled()
Check whether the structured filter UI is enabled.
Definition: ChangesListSpecialPage.php:1960
ChangesListSpecialPage\getStructuredFilterJsData
getStructuredFilterJsData()
Gets structured filter information needed by JS.
Definition: ChangesListSpecialPage.php:1274
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:1246
$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:618
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:800
RecentChange\SRC_EDIT
const SRC_EDIT
Definition: RecentChange.php:85
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
ResourceLoaderContext\getLanguage
getLanguage()
Definition: ResourceLoaderContext.php:183
RecentChange\SRC_NEW
const SRC_NEW
Definition: RecentChange.php:86
ChangesListSpecialPage\buildQuery
buildQuery(&$tables, &$fields, &$conds, &$query_options, &$join_conds, FormOptions $opts)
Sets appropriate tables, fields, conditions, etc.
Definition: ChangesListSpecialPage.php:1510
ChangesListSpecialPage\getDefaultLimit
getDefaultLimit()
Get the default value of the number of changes to display when loading the result set.
Definition: ChangesListSpecialPage.php:1992
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:764
ResourceLoaderContext\msg
msg( $key,... $params)
Get a Message object with context set.
Definition: ResourceLoaderContext.php:235
RecentChange\PRC_PATROLLED
const PRC_PATROLLED
Definition: RecentChange.php:92
ChangeTags\listExplicitlyDefinedTags
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the change_tag_def table of the database.
Definition: ChangeTags.php:1606
ChangesListSpecialPage\$rcOptions
FormOptions $rcOptions
Definition: ChangesListSpecialPage.php:50
ChangesListSpecialPage\getCollapsedPreferenceName
getCollapsedPreferenceName()
Preference name for collapsing the active filter display.
$s
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s
Definition: mergeMessageFileList.php:206
ChangesListSpecialPage\getLimitPreferenceName
getLimitPreferenceName()
Getting the preference name for 'limit'.
ChangesListSpecialPage\registerFilters
registerFilters()
Register all filters and their groups (including those from hooks), plus handle conflicts and default...
Definition: ChangesListSpecialPage.php:1043
FormOptions\validateBounds
validateBounds( $name, $min, $max)
Constrain a numeric value for a given option to a given range.
Definition: FormOptions.php:270
ChangesListSpecialPage\getDefaultDaysPreferenceName
getDefaultDaysPreferenceName()
Preference name for 'days'.
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:43
ChangesListSpecialPage\setup
setup( $parameters)
Register all the filters, including legacy hook-driven ones.
Definition: ChangesListSpecialPage.php:1179
ChangesListSpecialPage\getChangeTagList
static getChangeTagList(ResourceLoaderContext $context)
Get information about change tags to export to JS via getRcFiltersConfigVars().
Definition: ChangesListSpecialPage.php:952
ChangesListSpecialPage\getFilterGroup
getFilterGroup( $groupName)
Gets a specified ChangesListFilterGroup by name.
Definition: ChangesListSpecialPage.php:1257
ChangesListSpecialPage\outputTimeout
outputTimeout()
Add the "timeout" message to the output.
Definition: ChangesListSpecialPage.php:995
ChangesListSpecialPage\$reviewStatusFilterGroupDefinition
array $reviewStatusFilterGroupDefinition
Single filter group registered conditionally.
Definition: ChangesListSpecialPage.php:77
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:780
ChangesListStringOptionsFilterGroup\NONE
const NONE
Signifies that no options in the group are selected, meaning the group has no effect.
Definition: ChangesListStringOptionsFilterGroup.php:59
ChangesListFilterGroup\getPriority
getPriority()
Definition: ChangesListFilterGroup.php:303
IContextSource\getUser
getUser()
NS_USER
const NS_USER
Definition: Defines.php:66
RecentChange\PRC_AUTOPATROLLED
const PRC_AUTOPATROLLED
Definition: RecentChange.php:93
ChangeTags\listSoftwareActivatedTags
static listSoftwareActivatedTags()
Lists those tags which core or extensions report as being "active".
Definition: ChangeTags.php:1558
$wgLearnerEdits
$wgLearnerEdits
The following variables define 3 user experience levels:
Definition: DefaultSettings.php:5127
ChangesListSpecialPage\addModules
addModules()
Add page-specific modules.
Definition: ChangesListSpecialPage.php:1813
FormOptions\STRING
const STRING
String type, maps guessType() to WebRequest::getText()
Definition: FormOptions.php:43
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:58
ChangesListSpecialPage\getSavedQueriesPreferenceName
getSavedQueriesPreferenceName()
Preference name for saved queries.
ChangesListSpecialPage\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: ChangesListSpecialPage.php:1829
ChangesListSpecialPage\areFiltersInConflict
areFiltersInConflict()
Check if filters are in conflict and guaranteed to return no results.
Definition: ChangesListSpecialPage.php:564
ChangesListSpecialPage\getDefaultOptions
getDefaultOptions()
Get a FormOptions object containing the default options.
Definition: ChangesListSpecialPage.php:1205
ChangesListSpecialPage\transformFilterDefinition
transformFilterDefinition(array $filterDefinition)
Transforms filter definition to prepare it for constructor.
Definition: ChangesListSpecialPage.php:1117
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
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:119
FormOptions\INT
const INT
Integer type, maps guessType() to WebRequest::getInt()
Definition: FormOptions.php:45
ChangesListSpecialPage\$hideCategorizationFilterDefinition
array $hideCategorizationFilterDefinition
Single filter group registered conditionally.
Definition: ChangesListSpecialPage.php:80
ChangesListSpecialPage\getDB
getDB()
Return a IDatabase object for reading.
Definition: ChangesListSpecialPage.php:1639
RecentChange\PRC_UNPATROLLED
const PRC_UNPATROLLED
Definition: RecentChange.php:91
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:88
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:252
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
ChangesListFilter
Represents a filter (used on ChangesListSpecialPage and descendants)
Definition: ChangesListFilter.php:29
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:67
$wgLearnerMemberSince
$wgLearnerMemberSince
Number of days the user must exist before becoming a learner.
Definition: DefaultSettings.php:5133
ChangesListSpecialPage\$rcSubpage
string $rcSubpage
Definition: ChangesListSpecialPage.php:47
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:1692
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:1849
ChangesListSpecialPage\replaceOldOptions
replaceOldOptions(FormOptions $opts)
Replace old options with their structured UI equivalents.
Definition: ChangesListSpecialPage.php:1440
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:1131
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:232
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:1712
ChangeTags\tagLongDescriptionMessage
static tagLongDescriptionMessage( $tag, MessageLocalizer $context)
Get the message object for the tag's long description.
Definition: ChangeTags.php:300
ChangesListSpecialPage\validateOptions
validateOptions(FormOptions $opts)
Validate a FormOptions object generated by getDefaultOptions() with values already populated.
Definition: ChangesListSpecialPage.php:1359
ChangesListSpecialPage\registerFilterGroup
registerFilterGroup(ChangesListFilterGroup $group)
Register a structured changes list filter group.
Definition: ChangesListSpecialPage.php:1235
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:1026
ChangesListSpecialPage\getLinkDays
getLinkDays()
Definition: ChangesListSpecialPage.php:765
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:709
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:266
ChangesListFilter\getConflictingFilters
getConflictingFilters()
Get filters conflicting with this filter.
Definition: ChangesListFilter.php:429
ChangesListSpecialPage\getLegacyShowHideFilters
getLegacyShowHideFilters()
Definition: ChangesListSpecialPage.php:1157
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:330
ChangesListSpecialPage\setTopText
setTopText(FormOptions $opts)
Send the text to be displayed before the options.
Definition: ChangesListSpecialPage.php:1701
ChangesListSpecialPage\getRcFiltersConfigSummary
static getRcFiltersConfigSummary(ResourceLoaderContext $context)
Get essential data about getRcFiltersConfigVars() for change detection.
Definition: ChangesListSpecialPage.php:854