MediaWiki  1.33.0
ChangesListSpecialPage.php
Go to the documentation of this file.
1 <?php
29 
36 abstract class ChangesListSpecialPage extends SpecialPage {
42 
47  protected static $savedQueriesPreferenceName;
48 
53  protected static $daysPreferenceName;
54 
59  protected static $limitPreferenceName;
60 
65  protected static $collapsedPreferenceName;
66 
68  protected $rcSubpage;
69 
71  protected $rcOptions;
72 
73  // Order of both groups and filters is significant; first is top-most priority,
74  // descending from there.
75  // 'showHideSuffix' is a shortcut to and avoid spelling out
76  // details specific to subclasses here.
90 
91  // Same format as filterGroupDefinitions, but for a single group (reviewStatus)
92  // that is registered conditionally.
94 
95  // Single filter group registered conditionally
97 
98  // Single filter group registered conditionally
100 
107  protected $filterGroups = [];
108 
109  public function __construct( $name, $restriction ) {
110  parent::__construct( $name, $restriction );
111 
112  $nonRevisionTypes = [ RC_LOG ];
113  Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
114 
115  $this->filterGroupDefinitions = [
116  [
117  'name' => 'registration',
118  'title' => 'rcfilters-filtergroup-registration',
120  'filters' => [
121  [
122  'name' => 'hideliu',
123  // rcshowhideliu-show, rcshowhideliu-hide,
124  // wlshowhideliu
125  'showHideSuffix' => 'showhideliu',
126  'default' => false,
127  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
128  &$query_options, &$join_conds
129  ) {
130  $actorMigration = ActorMigration::newMigration();
131  $actorQuery = $actorMigration->getJoin( 'rc_user' );
132  $tables += $actorQuery['tables'];
133  $join_conds += $actorQuery['joins'];
134  $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
135  },
136  'isReplacedInStructuredUi' => true,
137 
138  ],
139  [
140  'name' => 'hideanons',
141  // rcshowhideanons-show, rcshowhideanons-hide,
142  // wlshowhideanons
143  'showHideSuffix' => 'showhideanons',
144  'default' => false,
145  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
146  &$query_options, &$join_conds
147  ) {
148  $actorMigration = ActorMigration::newMigration();
149  $actorQuery = $actorMigration->getJoin( 'rc_user' );
150  $tables += $actorQuery['tables'];
151  $join_conds += $actorQuery['joins'];
152  $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
153  },
154  'isReplacedInStructuredUi' => true,
155  ]
156  ],
157  ],
158 
159  [
160  'name' => 'userExpLevel',
161  'title' => 'rcfilters-filtergroup-userExpLevel',
163  'isFullCoverage' => true,
164  'filters' => [
165  [
166  'name' => 'unregistered',
167  'label' => 'rcfilters-filter-user-experience-level-unregistered-label',
168  'description' => 'rcfilters-filter-user-experience-level-unregistered-description',
169  'cssClassSuffix' => 'user-unregistered',
170  'isRowApplicableCallable' => function ( $ctx, $rc ) {
171  return !$rc->getAttribute( 'rc_user' );
172  }
173  ],
174  [
175  'name' => 'registered',
176  'label' => 'rcfilters-filter-user-experience-level-registered-label',
177  'description' => 'rcfilters-filter-user-experience-level-registered-description',
178  'cssClassSuffix' => 'user-registered',
179  'isRowApplicableCallable' => function ( $ctx, $rc ) {
180  return $rc->getAttribute( 'rc_user' );
181  }
182  ],
183  [
184  'name' => 'newcomer',
185  'label' => 'rcfilters-filter-user-experience-level-newcomer-label',
186  'description' => 'rcfilters-filter-user-experience-level-newcomer-description',
187  'cssClassSuffix' => 'user-newcomer',
188  'isRowApplicableCallable' => function ( $ctx, $rc ) {
189  $performer = $rc->getPerformer();
190  return $performer && $performer->isLoggedIn() &&
191  $performer->getExperienceLevel() === 'newcomer';
192  }
193  ],
194  [
195  'name' => 'learner',
196  'label' => 'rcfilters-filter-user-experience-level-learner-label',
197  'description' => 'rcfilters-filter-user-experience-level-learner-description',
198  'cssClassSuffix' => 'user-learner',
199  'isRowApplicableCallable' => function ( $ctx, $rc ) {
200  $performer = $rc->getPerformer();
201  return $performer && $performer->isLoggedIn() &&
202  $performer->getExperienceLevel() === 'learner';
203  },
204  ],
205  [
206  'name' => 'experienced',
207  'label' => 'rcfilters-filter-user-experience-level-experienced-label',
208  'description' => 'rcfilters-filter-user-experience-level-experienced-description',
209  'cssClassSuffix' => 'user-experienced',
210  'isRowApplicableCallable' => function ( $ctx, $rc ) {
211  $performer = $rc->getPerformer();
212  return $performer && $performer->isLoggedIn() &&
213  $performer->getExperienceLevel() === 'experienced';
214  },
215  ]
216  ],
218  'queryCallable' => [ $this, 'filterOnUserExperienceLevel' ],
219  ],
220 
221  [
222  'name' => 'authorship',
223  'title' => 'rcfilters-filtergroup-authorship',
225  'filters' => [
226  [
227  'name' => 'hidemyself',
228  'label' => 'rcfilters-filter-editsbyself-label',
229  'description' => 'rcfilters-filter-editsbyself-description',
230  // rcshowhidemine-show, rcshowhidemine-hide,
231  // wlshowhidemine
232  'showHideSuffix' => 'showhidemine',
233  'default' => false,
234  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
235  &$query_options, &$join_conds
236  ) {
237  $actorQuery = ActorMigration::newMigration()->getWhere( $dbr, 'rc_user', $ctx->getUser() );
238  $tables += $actorQuery['tables'];
239  $join_conds += $actorQuery['joins'];
240  $conds[] = 'NOT(' . $actorQuery['conds'] . ')';
241  },
242  'cssClassSuffix' => 'self',
243  'isRowApplicableCallable' => function ( $ctx, $rc ) {
244  return $ctx->getUser()->equals( $rc->getPerformer() );
245  },
246  ],
247  [
248  'name' => 'hidebyothers',
249  'label' => 'rcfilters-filter-editsbyother-label',
250  'description' => 'rcfilters-filter-editsbyother-description',
251  'default' => false,
252  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
253  &$query_options, &$join_conds
254  ) {
255  $actorQuery = ActorMigration::newMigration()
256  ->getWhere( $dbr, 'rc_user', $ctx->getUser(), false );
257  $tables += $actorQuery['tables'];
258  $join_conds += $actorQuery['joins'];
259  $conds[] = $actorQuery['conds'];
260  },
261  'cssClassSuffix' => 'others',
262  'isRowApplicableCallable' => function ( $ctx, $rc ) {
263  return !$ctx->getUser()->equals( $rc->getPerformer() );
264  },
265  ]
266  ]
267  ],
268 
269  [
270  'name' => 'automated',
271  'title' => 'rcfilters-filtergroup-automated',
273  'filters' => [
274  [
275  'name' => 'hidebots',
276  'label' => 'rcfilters-filter-bots-label',
277  'description' => 'rcfilters-filter-bots-description',
278  // rcshowhidebots-show, rcshowhidebots-hide,
279  // wlshowhidebots
280  'showHideSuffix' => 'showhidebots',
281  'default' => false,
282  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
283  &$query_options, &$join_conds
284  ) {
285  $conds['rc_bot'] = 0;
286  },
287  'cssClassSuffix' => 'bot',
288  'isRowApplicableCallable' => function ( $ctx, $rc ) {
289  return $rc->getAttribute( 'rc_bot' );
290  },
291  ],
292  [
293  'name' => 'hidehumans',
294  'label' => 'rcfilters-filter-humans-label',
295  'description' => 'rcfilters-filter-humans-description',
296  'default' => false,
297  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
298  &$query_options, &$join_conds
299  ) {
300  $conds['rc_bot'] = 1;
301  },
302  'cssClassSuffix' => 'human',
303  'isRowApplicableCallable' => function ( $ctx, $rc ) {
304  return !$rc->getAttribute( 'rc_bot' );
305  },
306  ]
307  ]
308  ],
309 
310  // significance (conditional)
311 
312  [
313  'name' => 'significance',
314  'title' => 'rcfilters-filtergroup-significance',
316  'priority' => -6,
317  'filters' => [
318  [
319  'name' => 'hideminor',
320  'label' => 'rcfilters-filter-minor-label',
321  'description' => 'rcfilters-filter-minor-description',
322  // rcshowhideminor-show, rcshowhideminor-hide,
323  // wlshowhideminor
324  'showHideSuffix' => 'showhideminor',
325  'default' => false,
326  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
327  &$query_options, &$join_conds
328  ) {
329  $conds[] = 'rc_minor = 0';
330  },
331  'cssClassSuffix' => 'minor',
332  'isRowApplicableCallable' => function ( $ctx, $rc ) {
333  return $rc->getAttribute( 'rc_minor' );
334  }
335  ],
336  [
337  'name' => 'hidemajor',
338  'label' => 'rcfilters-filter-major-label',
339  'description' => 'rcfilters-filter-major-description',
340  'default' => false,
341  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
342  &$query_options, &$join_conds
343  ) {
344  $conds[] = 'rc_minor = 1';
345  },
346  'cssClassSuffix' => 'major',
347  'isRowApplicableCallable' => function ( $ctx, $rc ) {
348  return !$rc->getAttribute( 'rc_minor' );
349  }
350  ]
351  ]
352  ],
353 
354  [
355  'name' => 'lastRevision',
356  'title' => 'rcfilters-filtergroup-lastRevision',
358  'priority' => -7,
359  'filters' => [
360  [
361  'name' => 'hidelastrevision',
362  'label' => 'rcfilters-filter-lastrevision-label',
363  'description' => 'rcfilters-filter-lastrevision-description',
364  'default' => false,
365  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
366  &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
367  $conds[] = $dbr->makeList(
368  [
369  'rc_this_oldid <> page_latest',
370  'rc_type' => $nonRevisionTypes,
371  ],
372  LIST_OR
373  );
374  },
375  'cssClassSuffix' => 'last',
376  'isRowApplicableCallable' => function ( $ctx, $rc ) {
377  return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
378  }
379  ],
380  [
381  'name' => 'hidepreviousrevisions',
382  'label' => 'rcfilters-filter-previousrevision-label',
383  'description' => 'rcfilters-filter-previousrevision-description',
384  'default' => false,
385  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
386  &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
387  $conds[] = $dbr->makeList(
388  [
389  'rc_this_oldid = page_latest',
390  'rc_type' => $nonRevisionTypes,
391  ],
392  LIST_OR
393  );
394  },
395  'cssClassSuffix' => 'previous',
396  'isRowApplicableCallable' => function ( $ctx, $rc ) {
397  return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
398  }
399  ]
400  ]
401  ],
402 
403  // With extensions, there can be change types that will not be hidden by any of these.
404  [
405  'name' => 'changeType',
406  'title' => 'rcfilters-filtergroup-changetype',
408  'priority' => -8,
409  'filters' => [
410  [
411  'name' => 'hidepageedits',
412  'label' => 'rcfilters-filter-pageedits-label',
413  'description' => 'rcfilters-filter-pageedits-description',
414  'default' => false,
415  'priority' => -2,
416  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
417  &$query_options, &$join_conds
418  ) {
419  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
420  },
421  'cssClassSuffix' => 'src-mw-edit',
422  'isRowApplicableCallable' => function ( $ctx, $rc ) {
423  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_EDIT;
424  },
425  ],
426  [
427  'name' => 'hidenewpages',
428  'label' => 'rcfilters-filter-newpages-label',
429  'description' => 'rcfilters-filter-newpages-description',
430  'default' => false,
431  'priority' => -3,
432  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
433  &$query_options, &$join_conds
434  ) {
435  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
436  },
437  'cssClassSuffix' => 'src-mw-new',
438  'isRowApplicableCallable' => function ( $ctx, $rc ) {
439  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_NEW;
440  },
441  ],
442 
443  // hidecategorization
444 
445  [
446  'name' => 'hidelog',
447  'label' => 'rcfilters-filter-logactions-label',
448  'description' => 'rcfilters-filter-logactions-description',
449  'default' => false,
450  'priority' => -5,
451  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
452  &$query_options, &$join_conds
453  ) {
454  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
455  },
456  'cssClassSuffix' => 'src-mw-log',
457  'isRowApplicableCallable' => function ( $ctx, $rc ) {
458  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_LOG;
459  }
460  ],
461  ],
462  ],
463 
464  ];
465 
466  $this->legacyReviewStatusFilterGroupDefinition = [
467  [
468  'name' => 'legacyReviewStatus',
469  'title' => 'rcfilters-filtergroup-reviewstatus',
471  'filters' => [
472  [
473  'name' => 'hidepatrolled',
474  // rcshowhidepatr-show, rcshowhidepatr-hide
475  // wlshowhidepatr
476  'showHideSuffix' => 'showhidepatr',
477  'default' => false,
478  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
479  &$query_options, &$join_conds
480  ) {
481  $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
482  },
483  'isReplacedInStructuredUi' => true,
484  ],
485  [
486  'name' => 'hideunpatrolled',
487  'default' => false,
488  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
489  &$query_options, &$join_conds
490  ) {
491  $conds[] = 'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED;
492  },
493  'isReplacedInStructuredUi' => true,
494  ],
495  ],
496  ]
497  ];
498 
499  $this->reviewStatusFilterGroupDefinition = [
500  [
501  'name' => 'reviewStatus',
502  'title' => 'rcfilters-filtergroup-reviewstatus',
504  'isFullCoverage' => true,
505  'priority' => -5,
506  'filters' => [
507  [
508  'name' => 'unpatrolled',
509  'label' => 'rcfilters-filter-reviewstatus-unpatrolled-label',
510  'description' => 'rcfilters-filter-reviewstatus-unpatrolled-description',
511  'cssClassSuffix' => 'reviewstatus-unpatrolled',
512  'isRowApplicableCallable' => function ( $ctx, $rc ) {
513  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED;
514  },
515  ],
516  [
517  'name' => 'manual',
518  'label' => 'rcfilters-filter-reviewstatus-manual-label',
519  'description' => 'rcfilters-filter-reviewstatus-manual-description',
520  'cssClassSuffix' => 'reviewstatus-manual',
521  'isRowApplicableCallable' => function ( $ctx, $rc ) {
522  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_PATROLLED;
523  },
524  ],
525  [
526  'name' => 'auto',
527  'label' => 'rcfilters-filter-reviewstatus-auto-label',
528  'description' => 'rcfilters-filter-reviewstatus-auto-description',
529  'cssClassSuffix' => 'reviewstatus-auto',
530  'isRowApplicableCallable' => function ( $ctx, $rc ) {
531  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_AUTOPATROLLED;
532  },
533  ],
534  ],
536  'queryCallable' => function ( $specialPageClassName, $ctx, $dbr,
537  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selected
538  ) {
539  if ( $selected === [] ) {
540  return;
541  }
542  $rcPatrolledValues = [
543  'unpatrolled' => RecentChange::PRC_UNPATROLLED,
544  'manual' => RecentChange::PRC_PATROLLED,
546  ];
547  // e.g. rc_patrolled IN (0, 2)
548  $conds['rc_patrolled'] = array_map( function ( $s ) use ( $rcPatrolledValues ) {
549  return $rcPatrolledValues[ $s ];
550  }, $selected );
551  }
552  ]
553  ];
554 
555  $this->hideCategorizationFilterDefinition = [
556  'name' => 'hidecategorization',
557  'label' => 'rcfilters-filter-categorization-label',
558  'description' => 'rcfilters-filter-categorization-description',
559  // rcshowhidecategorization-show, rcshowhidecategorization-hide.
560  // wlshowhidecategorization
561  'showHideSuffix' => 'showhidecategorization',
562  'default' => false,
563  'priority' => -4,
564  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
565  &$query_options, &$join_conds
566  ) {
567  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
568  },
569  'cssClassSuffix' => 'src-mw-categorize',
570  'isRowApplicableCallable' => function ( $ctx, $rc ) {
571  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_CATEGORIZE;
572  },
573  ];
574  }
575 
581  protected function areFiltersInConflict() {
582  $opts = $this->getOptions();
584  foreach ( $this->getFilterGroups() as $group ) {
585  if ( $group->getConflictingGroups() ) {
586  wfLogWarning(
587  $group->getName() .
588  " specifies conflicts with other groups but these are not supported yet."
589  );
590  }
591 
593  foreach ( $group->getConflictingFilters() as $conflictingFilter ) {
594  if ( $conflictingFilter->activelyInConflictWithGroup( $group, $opts ) ) {
595  return true;
596  }
597  }
598 
600  foreach ( $group->getFilters() as $filter ) {
602  foreach ( $filter->getConflictingFilters() as $conflictingFilter ) {
603  if (
604  $conflictingFilter->activelyInConflictWithFilter( $filter, $opts ) &&
605  $filter->activelyInConflictWithFilter( $conflictingFilter, $opts )
606  ) {
607  return true;
608  }
609  }
610 
611  }
612 
613  }
614 
615  return false;
616  }
617 
621  public function execute( $subpage ) {
622  $this->rcSubpage = $subpage;
623 
624  $this->considerActionsForDefaultSavedQuery( $subpage );
625 
626  $opts = $this->getOptions();
627  try {
628  $rows = $this->getRows();
629  if ( $rows === false ) {
630  $rows = new FakeResultWrapper( [] );
631  }
632 
633  // Used by Structured UI app to get results without MW chrome
634  if ( $this->getRequest()->getVal( 'action' ) === 'render' ) {
635  $this->getOutput()->setArticleBodyOnly( true );
636  }
637 
638  // Used by "live update" and "view newest" to check
639  // if there's new changes with minimal data transfer
640  if ( $this->getRequest()->getBool( 'peek' ) ) {
641  $code = $rows->numRows() > 0 ? 200 : 204;
642  $this->getOutput()->setStatusCode( $code );
643 
644  if ( $this->getUser()->isAnon() !==
645  $this->getRequest()->getFuzzyBool( 'isAnon' )
646  ) {
647  $this->getOutput()->setStatusCode( 205 );
648  }
649 
650  return;
651  }
652 
653  $batch = new LinkBatch;
654  foreach ( $rows as $row ) {
655  $batch->add( NS_USER, $row->rc_user_text );
656  $batch->add( NS_USER_TALK, $row->rc_user_text );
657  $batch->add( $row->rc_namespace, $row->rc_title );
658  if ( $row->rc_source === RecentChange::SRC_LOG ) {
659  $formatter = LogFormatter::newFromRow( $row );
660  foreach ( $formatter->getPreloadTitles() as $title ) {
661  $batch->addObj( $title );
662  }
663  }
664  }
665  $batch->execute();
666 
667  $this->setHeaders();
668  $this->outputHeader();
669  $this->addModules();
670  $this->webOutput( $rows, $opts );
671 
672  $rows->free();
673  } catch ( DBQueryTimeoutError $timeoutException ) {
674  MWExceptionHandler::logException( $timeoutException );
675 
676  $this->setHeaders();
677  $this->outputHeader();
678  $this->addModules();
679 
680  $this->getOutput()->setStatusCode( 500 );
681  $this->webOutputHeader( 0, $opts );
682  $this->outputTimeout();
683  }
684 
685  if ( $this->getConfig()->get( 'EnableWANCacheReaper' ) ) {
686  // Clean up any bad page entries for titles showing up in RC
688  $this->getDB(),
689  LoggerFactory::getInstance( 'objectcache' )
690  ) );
691  }
692 
693  $this->includeRcFiltersApp();
694  }
695 
703  protected function considerActionsForDefaultSavedQuery( $subpage ) {
704  if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) {
705  return;
706  }
707 
708  $knownParams = $this->getRequest()->getValues(
709  ...array_keys( $this->getOptions()->getAllValues() )
710  );
711 
712  // HACK: Temporarily until we can properly define "sticky" filters and parameters,
713  // we need to exclude several parameters we know should not be counted towards preventing
714  // the loading of defaults.
715  $excludedParams = [ 'limit' => '', 'days' => '', 'enhanced' => '', 'from' => '' ];
716  $knownParams = array_diff_key( $knownParams, $excludedParams );
717 
718  if (
719  // If there are NO known parameters in the URL request
720  // (that are not excluded) then we need to check into loading
721  // the default saved query
722  count( $knownParams ) === 0
723  ) {
724  // Get the saved queries data and parse it
725  $savedQueries = FormatJson::decode(
726  $this->getUser()->getOption( static::$savedQueriesPreferenceName ),
727  true
728  );
729 
730  if ( $savedQueries && isset( $savedQueries[ 'default' ] ) ) {
731  // Only load queries that are 'version' 2, since those
732  // have parameter representation
733  if ( isset( $savedQueries[ 'version' ] ) && $savedQueries[ 'version' ] === '2' ) {
734  $savedQueryDefaultID = $savedQueries[ 'default' ];
735  $defaultQuery = $savedQueries[ 'queries' ][ $savedQueryDefaultID ][ 'data' ];
736 
737  // Build the entire parameter list
738  $query = array_merge(
739  $defaultQuery[ 'params' ],
740  $defaultQuery[ 'highlights' ],
741  [
742  'urlversion' => '2',
743  ]
744  );
745  // Add to the query any parameters that we may have ignored before
746  // but are still valid and requested in the URL
747  $query = array_merge( $this->getRequest()->getValues(), $query );
748  unset( $query[ 'title' ] );
749  $this->getOutput()->redirect( $this->getPageTitle( $subpage )->getCanonicalURL( $query ) );
750  } else {
751  // There's a default, but the version is not 2, and the server can't
752  // actually recognize the query itself. This happens if it is before
753  // the conversion, so we need to tell the UI to reload saved query as
754  // it does the conversion to version 2
755  $this->getOutput()->addJsConfigVars(
756  'wgStructuredChangeFiltersDefaultSavedQueryExists',
757  true
758  );
759 
760  // Add the class that tells the frontend it is still loading
761  // another query
762  $this->getOutput()->addBodyClasses( 'mw-rcfilters-ui-loading' );
763  }
764  }
765  }
766  }
767 
774  protected function includeRcFiltersApp() {
775  $out = $this->getOutput();
776  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
777  $jsData = $this->getStructuredFilterJsData();
778  $messages = [];
779  foreach ( $jsData['messageKeys'] as $key ) {
780  $messages[$key] = $this->msg( $key )->plain();
781  }
782 
783  $out->addBodyClasses( 'mw-rcfilters-enabled' );
784  $collapsed = $this->getUser()->getBoolOption( static::$collapsedPreferenceName );
785  if ( $collapsed ) {
786  $out->addBodyClasses( 'mw-rcfilters-collapsed' );
787  }
788 
789  // These config and message exports should be moved into a ResourceLoader data module (T201574)
790  $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
791  $out->addJsConfigVars( 'wgStructuredChangeFiltersMessages', $messages );
792  $out->addJsConfigVars( 'wgStructuredChangeFiltersCollapsedState', $collapsed );
793 
794  $out->addJsConfigVars(
795  'StructuredChangeFiltersDisplayConfig',
796  [
797  'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
798  'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
799  'limitDefault' => $this->getDefaultLimit(),
800  'daysArray' => $this->getConfig()->get( 'RCLinkDays' ),
801  'daysDefault' => $this->getDefaultDays(),
802  ]
803  );
804 
805  $out->addJsConfigVars(
806  'wgStructuredChangeFiltersSavedQueriesPreferenceName',
807  static::$savedQueriesPreferenceName
808  );
809  $out->addJsConfigVars(
810  'wgStructuredChangeFiltersLimitPreferenceName',
811  static::$limitPreferenceName
812  );
813  $out->addJsConfigVars(
814  'wgStructuredChangeFiltersDaysPreferenceName',
815  static::$daysPreferenceName
816  );
817  $out->addJsConfigVars(
818  'wgStructuredChangeFiltersCollapsedPreferenceName',
819  static::$collapsedPreferenceName
820  );
821  } else {
822  $out->addBodyClasses( 'mw-rcfilters-disabled' );
823  }
824  }
825 
833  return [
834  'RCFiltersChangeTags' => self::getChangeTagList( $context ),
835  'StructuredChangeFiltersEditWatchlistUrl' =>
836  SpecialPage::getTitleFor( 'EditWatchlist' )->getLocalURL()
837  ];
838  }
839 
846  protected static function getChangeTagList( ResourceLoaderContext $context ) {
847  $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
848  return $cache->getWithSetCallback(
849  $cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage() ),
850  $cache::TTL_MINUTE * 10,
851  function () use ( $context ) {
852  $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
853  $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
854 
855  $tagStats = ChangeTags::tagUsageStatistics();
856  $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
857 
858  // Sort by hits (disabled for now)
859  //arsort( $tagHitCounts );
860 
861  // HACK work around ChangeTags::truncateTagDescription() requiring a RequestContext
862  $fakeContext = RequestContext::newExtraneousContext( Title::newFromText( 'Dwimmerlaik' ) );
863  $fakeContext->setLanguage( Language::factory( $context->getLanguage() ) );
864 
865  // Build the list and data
866  $result = [];
867  foreach ( $tagHitCounts as $tagName => $hits ) {
868  if (
869  (
870  // Only get active tags
871  isset( $explicitlyDefinedTags[ $tagName ] ) ||
872  isset( $softwareActivatedTags[ $tagName ] )
873  ) &&
874  // Only get tags with more than 0 hits
875  $hits > 0
876  ) {
877  $result[] = [
878  'name' => $tagName,
879  'label' => Sanitizer::stripAllTags(
881  ),
882  'description' =>
884  $tagName,
885  self::TAG_DESC_CHARACTER_LIMIT,
886  $fakeContext
887  ),
888  'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
889  'hits' => $hits,
890  ];
891  }
892  }
893 
894  // Instead of sorting by hit count (disabled, see above), sort by display name
895  usort( $result, function ( $a, $b ) {
896  return strcasecmp( $a['label'], $b['label'] );
897  } );
898 
899  return $result;
900  },
901  [
902  'lockTSE' => 30
903  ]
904  );
905  }
906 
910  protected function outputNoResults() {
911  $this->getOutput()->addHTML(
912  '<div class="mw-changeslist-empty">' .
913  $this->msg( 'recentchanges-noresult' )->parse() .
914  '</div>'
915  );
916  }
917 
921  protected function outputTimeout() {
922  $this->getOutput()->addHTML(
923  '<div class="mw-changeslist-empty mw-changeslist-timeout">' .
924  $this->msg( 'recentchanges-timeout' )->parse() .
925  '</div>'
926  );
927  }
928 
934  public function getRows() {
935  $opts = $this->getOptions();
936 
937  $tables = [];
938  $fields = [];
939  $conds = [];
940  $query_options = [];
941  $join_conds = [];
942  $this->buildQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
943 
944  return $this->doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
945  }
946 
952  public function getOptions() {
953  if ( $this->rcOptions === null ) {
954  $this->rcOptions = $this->setup( $this->rcSubpage );
955  }
956 
957  return $this->rcOptions;
958  }
959 
969  protected function registerFilters() {
970  $this->registerFiltersFromDefinitions( $this->filterGroupDefinitions );
971 
972  // Make sure this is not being transcluded (we don't want to show this
973  // information to all users just because the user that saves the edit can
974  // patrol or is logged in)
975  if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
976  $this->registerFiltersFromDefinitions( $this->legacyReviewStatusFilterGroupDefinition );
977  $this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition );
978  }
979 
980  $changeTypeGroup = $this->getFilterGroup( 'changeType' );
981 
982  if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
983  $transformedHideCategorizationDef = $this->transformFilterDefinition(
984  $this->hideCategorizationFilterDefinition
985  );
986 
987  $transformedHideCategorizationDef['group'] = $changeTypeGroup;
988 
989  $hideCategorization = new ChangesListBooleanFilter(
990  $transformedHideCategorizationDef
991  );
992  }
993 
994  Hooks::run( 'ChangesListSpecialPageStructuredFilters', [ $this ] );
995 
996  $this->registerFiltersFromDefinitions( [] );
997 
998  $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' );
999  $registered = $userExperienceLevel->getFilter( 'registered' );
1000  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'newcomer' ) );
1001  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'learner' ) );
1002  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'experienced' ) );
1003 
1004  $categoryFilter = $changeTypeGroup->getFilter( 'hidecategorization' );
1005  $logactionsFilter = $changeTypeGroup->getFilter( 'hidelog' );
1006  $pagecreationFilter = $changeTypeGroup->getFilter( 'hidenewpages' );
1007 
1008  $significanceTypeGroup = $this->getFilterGroup( 'significance' );
1009  $hideMinorFilter = $significanceTypeGroup->getFilter( 'hideminor' );
1010 
1011  // categoryFilter is conditional; see registerFilters
1012  if ( $categoryFilter !== null ) {
1013  $hideMinorFilter->conflictsWith(
1014  $categoryFilter,
1015  'rcfilters-hideminor-conflicts-typeofchange-global',
1016  'rcfilters-hideminor-conflicts-typeofchange',
1017  'rcfilters-typeofchange-conflicts-hideminor'
1018  );
1019  }
1020  $hideMinorFilter->conflictsWith(
1021  $logactionsFilter,
1022  'rcfilters-hideminor-conflicts-typeofchange-global',
1023  'rcfilters-hideminor-conflicts-typeofchange',
1024  'rcfilters-typeofchange-conflicts-hideminor'
1025  );
1026  $hideMinorFilter->conflictsWith(
1027  $pagecreationFilter,
1028  'rcfilters-hideminor-conflicts-typeofchange-global',
1029  'rcfilters-hideminor-conflicts-typeofchange',
1030  'rcfilters-typeofchange-conflicts-hideminor'
1031  );
1032  }
1033 
1043  protected function transformFilterDefinition( array $filterDefinition ) {
1044  return $filterDefinition;
1045  }
1046 
1057  protected function registerFiltersFromDefinitions( array $definition ) {
1058  $autoFillPriority = -1;
1059  foreach ( $definition as $groupDefinition ) {
1060  if ( !isset( $groupDefinition['priority'] ) ) {
1061  $groupDefinition['priority'] = $autoFillPriority;
1062  } else {
1063  // If it's explicitly specified, start over the auto-fill
1064  $autoFillPriority = $groupDefinition['priority'];
1065  }
1066 
1067  $autoFillPriority--;
1068 
1069  $className = $groupDefinition['class'];
1070  unset( $groupDefinition['class'] );
1071 
1072  foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
1073  $filterDefinition = $this->transformFilterDefinition( $filterDefinition );
1074  }
1075 
1076  $this->registerFilterGroup( new $className( $groupDefinition ) );
1077  }
1078  }
1079 
1083  protected function getLegacyShowHideFilters() {
1084  $filters = [];
1085  foreach ( $this->filterGroups as $group ) {
1086  if ( $group instanceof ChangesListBooleanFilterGroup ) {
1087  foreach ( $group->getFilters() as $key => $filter ) {
1088  if ( $filter->displaysOnUnstructuredUi( $this ) ) {
1089  $filters[ $key ] = $filter;
1090  }
1091  }
1092  }
1093  }
1094  return $filters;
1095  }
1096 
1105  public function setup( $parameters ) {
1106  $this->registerFilters();
1107 
1108  $opts = $this->getDefaultOptions();
1109 
1110  $opts = $this->fetchOptionsFromRequest( $opts );
1111 
1112  // Give precedence to subpage syntax
1113  if ( $parameters !== null ) {
1114  $this->parseParameters( $parameters, $opts );
1115  }
1116 
1117  $this->validateOptions( $opts );
1118 
1119  return $opts;
1120  }
1121 
1131  public function getDefaultOptions() {
1132  $opts = new FormOptions();
1133  $structuredUI = $this->isStructuredFilterUiEnabled();
1134  // If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
1135  $useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
1136 
1138  foreach ( $this->filterGroups as $filterGroup ) {
1139  $filterGroup->addOptions( $opts, $useDefaults, $structuredUI );
1140  }
1141 
1142  $opts->add( 'namespace', '', FormOptions::STRING );
1143  $opts->add( 'invert', false );
1144  $opts->add( 'associated', false );
1145  $opts->add( 'urlversion', 1 );
1146  $opts->add( 'tagfilter', '' );
1147 
1148  $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT );
1149  $opts->add( 'limit', $this->getDefaultLimit(), FormOptions::INT );
1150 
1151  $opts->add( 'from', '' );
1152 
1153  return $opts;
1154  }
1155 
1161  public function registerFilterGroup( ChangesListFilterGroup $group ) {
1162  $groupName = $group->getName();
1163 
1164  $this->filterGroups[$groupName] = $group;
1165  }
1166 
1172  protected function getFilterGroups() {
1173  return $this->filterGroups;
1174  }
1175 
1183  public function getFilterGroup( $groupName ) {
1184  return $this->filterGroups[$groupName] ?? null;
1185  }
1186 
1187  // Currently, this intentionally only includes filters that display
1188  // in the structured UI. This can be changed easily, though, if we want
1189  // to include data on filters that use the unstructured UI. messageKeys is a
1190  // special top-level value, with the value being an array of the message keys to
1191  // send to the client.
1199  public function getStructuredFilterJsData() {
1200  $output = [
1201  'groups' => [],
1202  'messageKeys' => [],
1203  ];
1204 
1205  usort( $this->filterGroups, function ( $a, $b ) {
1206  return $b->getPriority() <=> $a->getPriority();
1207  } );
1208 
1209  foreach ( $this->filterGroups as $groupName => $group ) {
1210  $groupOutput = $group->getJsData( $this );
1211  if ( $groupOutput !== null ) {
1212  $output['messageKeys'] = array_merge(
1213  $output['messageKeys'],
1214  $groupOutput['messageKeys']
1215  );
1216 
1217  unset( $groupOutput['messageKeys'] );
1218  $output['groups'][] = $groupOutput;
1219  }
1220  }
1221 
1222  return $output;
1223  }
1224 
1233  protected function fetchOptionsFromRequest( $opts ) {
1234  $opts->fetchValuesFromRequest( $this->getRequest() );
1235 
1236  return $opts;
1237  }
1238 
1245  public function parseParameters( $par, FormOptions $opts ) {
1246  $stringParameterNameSet = [];
1247  $hideParameterNameSet = [];
1248 
1249  // URL parameters can be per-group, like 'userExpLevel',
1250  // or per-filter, like 'hideminor'.
1251 
1252  foreach ( $this->filterGroups as $filterGroup ) {
1253  if ( $filterGroup instanceof ChangesListStringOptionsFilterGroup ) {
1254  $stringParameterNameSet[$filterGroup->getName()] = true;
1255  } elseif ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1256  foreach ( $filterGroup->getFilters() as $filter ) {
1257  $hideParameterNameSet[$filter->getName()] = true;
1258  }
1259  }
1260  }
1261 
1262  $bits = preg_split( '/\s*,\s*/', trim( $par ) );
1263  foreach ( $bits as $bit ) {
1264  $m = [];
1265  if ( isset( $hideParameterNameSet[$bit] ) ) {
1266  // hidefoo => hidefoo=true
1267  $opts[$bit] = true;
1268  } elseif ( isset( $hideParameterNameSet["hide$bit"] ) ) {
1269  // foo => hidefoo=false
1270  $opts["hide$bit"] = false;
1271  } elseif ( preg_match( '/^(.*)=(.*)$/', $bit, $m ) ) {
1272  if ( isset( $stringParameterNameSet[$m[1]] ) ) {
1273  $opts[$m[1]] = $m[2];
1274  }
1275  }
1276  }
1277  }
1278 
1284  public function validateOptions( FormOptions $opts ) {
1285  $isContradictory = $this->fixContradictoryOptions( $opts );
1286  $isReplaced = $this->replaceOldOptions( $opts );
1287 
1288  if ( $isContradictory || $isReplaced ) {
1289  $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
1290  $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
1291  }
1292 
1293  $opts->validateIntBounds( 'limit', 0, 5000 );
1294  $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
1295  }
1296 
1303  private function fixContradictoryOptions( FormOptions $opts ) {
1304  $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
1305 
1306  foreach ( $this->filterGroups as $filterGroup ) {
1307  if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1308  $filters = $filterGroup->getFilters();
1309 
1310  if ( count( $filters ) === 1 ) {
1311  // legacy boolean filters should not be considered
1312  continue;
1313  }
1314 
1315  $allInGroupEnabled = array_reduce(
1316  $filters,
1317  function ( $carry, $filter ) use ( $opts ) {
1318  return $carry && $opts[ $filter->getName() ];
1319  },
1320  /* initialValue */ count( $filters ) > 0
1321  );
1322 
1323  if ( $allInGroupEnabled ) {
1324  foreach ( $filters as $filter ) {
1325  $opts[ $filter->getName() ] = false;
1326  }
1327 
1328  $fixed = true;
1329  }
1330  }
1331  }
1332 
1333  return $fixed;
1334  }
1335 
1345  private function fixBackwardsCompatibilityOptions( FormOptions $opts ) {
1346  if ( $opts['hideanons'] && $opts['hideliu'] ) {
1347  $opts->reset( 'hideanons' );
1348  if ( !$opts['hidebots'] ) {
1349  $opts->reset( 'hideliu' );
1350  $opts['hidehumans'] = 1;
1351  }
1352 
1353  return true;
1354  }
1355 
1356  return false;
1357  }
1358 
1365  public function replaceOldOptions( FormOptions $opts ) {
1366  if ( !$this->isStructuredFilterUiEnabled() ) {
1367  return false;
1368  }
1369 
1370  $changed = false;
1371 
1372  // At this point 'hideanons' and 'hideliu' cannot be both true,
1373  // because fixBackwardsCompatibilityOptions resets (at least) 'hideanons' in such case
1374  if ( $opts[ 'hideanons' ] ) {
1375  $opts->reset( 'hideanons' );
1376  $opts[ 'userExpLevel' ] = 'registered';
1377  $changed = true;
1378  }
1379 
1380  if ( $opts[ 'hideliu' ] ) {
1381  $opts->reset( 'hideliu' );
1382  $opts[ 'userExpLevel' ] = 'unregistered';
1383  $changed = true;
1384  }
1385 
1386  if ( $this->getFilterGroup( 'legacyReviewStatus' ) ) {
1387  if ( $opts[ 'hidepatrolled' ] ) {
1388  $opts->reset( 'hidepatrolled' );
1389  $opts[ 'reviewStatus' ] = 'unpatrolled';
1390  $changed = true;
1391  }
1392 
1393  if ( $opts[ 'hideunpatrolled' ] ) {
1394  $opts->reset( 'hideunpatrolled' );
1395  $opts[ 'reviewStatus' ] = implode(
1397  [ 'manual', 'auto' ]
1398  );
1399  $changed = true;
1400  }
1401  }
1402 
1403  return $changed;
1404  }
1405 
1414  protected function convertParamsForLink( $params ) {
1415  foreach ( $params as &$value ) {
1416  if ( $value === false ) {
1417  $value = '0';
1418  }
1419  }
1420  unset( $value );
1421  return $params;
1422  }
1423 
1435  protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
1436  &$join_conds, FormOptions $opts
1437  ) {
1438  $dbr = $this->getDB();
1439  $isStructuredUI = $this->isStructuredFilterUiEnabled();
1440 
1442  foreach ( $this->filterGroups as $filterGroup ) {
1443  $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1444  $query_options, $join_conds, $opts, $isStructuredUI );
1445  }
1446 
1447  // Namespace filtering
1448  if ( $opts[ 'namespace' ] !== '' ) {
1449  $namespaces = explode( ';', $opts[ 'namespace' ] );
1450 
1451  if ( $opts[ 'associated' ] ) {
1452  $associatedNamespaces = array_map(
1453  function ( $ns ) {
1454  return MWNamespace::getAssociated( $ns );
1455  },
1456  $namespaces
1457  );
1458  $namespaces = array_unique( array_merge( $namespaces, $associatedNamespaces ) );
1459  }
1460 
1461  if ( count( $namespaces ) === 1 ) {
1462  $operator = $opts[ 'invert' ] ? '!=' : '=';
1463  $value = $dbr->addQuotes( reset( $namespaces ) );
1464  } else {
1465  $operator = $opts[ 'invert' ] ? 'NOT IN' : 'IN';
1466  sort( $namespaces );
1467  $value = '(' . $dbr->makeList( $namespaces ) . ')';
1468  }
1469  $conds[] = "rc_namespace $operator $value";
1470  }
1471 
1472  // Calculate cutoff
1473  $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
1474  $cutoff = $dbr->timestamp( $cutoff_unixtime );
1475 
1476  $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
1477  if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
1478  $cutoff = $dbr->timestamp( $opts['from'] );
1479  } else {
1480  $opts->reset( 'from' );
1481  }
1482 
1483  $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
1484  }
1485 
1497  protected function doMainQuery( $tables, $fields, $conds,
1498  $query_options, $join_conds, FormOptions $opts
1499  ) {
1500  $rcQuery = RecentChange::getQueryInfo();
1501  $tables = array_merge( $tables, $rcQuery['tables'] );
1502  $fields = array_merge( $rcQuery['fields'], $fields );
1503  $join_conds = array_merge( $join_conds, $rcQuery['joins'] );
1504 
1506  $tables,
1507  $fields,
1508  $conds,
1509  $join_conds,
1510  $query_options,
1511  ''
1512  );
1513 
1514  if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
1515  $opts )
1516  ) {
1517  return false;
1518  }
1519 
1520  $dbr = $this->getDB();
1521 
1522  return $dbr->select(
1523  $tables,
1524  $fields,
1525  $conds,
1526  __METHOD__,
1527  $query_options,
1528  $join_conds
1529  );
1530  }
1531 
1532  protected function runMainQueryHook( &$tables, &$fields, &$conds,
1533  &$query_options, &$join_conds, $opts
1534  ) {
1535  return Hooks::run(
1536  'ChangesListSpecialPageQuery',
1537  [ $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ]
1538  );
1539  }
1540 
1546  protected function getDB() {
1547  return wfGetDB( DB_REPLICA );
1548  }
1549 
1556  private function webOutputHeader( $rowCount, $opts ) {
1557  if ( !$this->including() ) {
1558  $this->outputFeedLinks();
1559  $this->doHeader( $opts, $rowCount );
1560  }
1561  }
1562 
1569  public function webOutput( $rows, $opts ) {
1570  $this->webOutputHeader( $rows->numRows(), $opts );
1571 
1572  $this->outputChangesList( $rows, $opts );
1573  }
1574 
1578  public function outputFeedLinks() {
1579  // nothing by default
1580  }
1581 
1588  abstract public function outputChangesList( $rows, $opts );
1589 
1596  public function doHeader( $opts, $numRows ) {
1597  $this->setTopText( $opts );
1598 
1599  // @todo Lots of stuff should be done here.
1600 
1601  $this->setBottomText( $opts );
1602  }
1603 
1611  public function setTopText( FormOptions $opts ) {
1612  // nothing by default
1613  }
1614 
1622  public function setBottomText( FormOptions $opts ) {
1623  // nothing by default
1624  }
1625 
1635  public function getExtraOptions( $opts ) {
1636  return [];
1637  }
1638 
1644  public function makeLegend() {
1645  $context = $this->getContext();
1646  $user = $context->getUser();
1647  # The legend showing what the letters and stuff mean
1648  $legend = Html::openElement( 'dl' ) . "\n";
1649  # Iterates through them and gets the messages for both letter and tooltip
1650  $legendItems = $context->getConfig()->get( 'RecentChangesFlags' );
1651  if ( !( $user->useRCPatrol() || $user->useNPPatrol() ) ) {
1652  unset( $legendItems['unpatrolled'] );
1653  }
1654  foreach ( $legendItems as $key => $item ) { # generate items of the legend
1655  $label = $item['legend'] ?? $item['title'];
1656  $letter = $item['letter'];
1657  $cssClass = $item['class'] ?? $key;
1658 
1659  $legend .= Html::element( 'dt',
1660  [ 'class' => $cssClass ], $context->msg( $letter )->text()
1661  ) . "\n" .
1662  Html::rawElement( 'dd',
1663  [ 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ],
1664  $context->msg( $label )->parse()
1665  ) . "\n";
1666  }
1667  # (+-123)
1668  $legend .= Html::rawElement( 'dt',
1669  [ 'class' => 'mw-plusminus-pos' ],
1670  $context->msg( 'recentchanges-legend-plusminus' )->parse()
1671  ) . "\n";
1672  $legend .= Html::element(
1673  'dd',
1674  [ 'class' => 'mw-changeslist-legend-plusminus' ],
1675  $context->msg( 'recentchanges-label-plusminus' )->text()
1676  ) . "\n";
1677  $legend .= Html::closeElement( 'dl' ) . "\n";
1678 
1679  $legendHeading = $this->isStructuredFilterUiEnabled() ?
1680  $context->msg( 'rcfilters-legend-heading' )->parse() :
1681  $context->msg( 'recentchanges-legend-heading' )->parse();
1682 
1683  # Collapsible
1684  $collapsedState = $this->getRequest()->getCookie( 'changeslist-state' );
1685  $collapsedClass = $collapsedState === 'collapsed' ? ' mw-collapsed' : '';
1686 
1687  $legend =
1688  '<div class="mw-changeslist-legend mw-collapsible' . $collapsedClass . '">' .
1689  $legendHeading .
1690  '<div class="mw-collapsible-content">' . $legend . '</div>' .
1691  '</div>';
1692 
1693  return $legend;
1694  }
1695 
1699  protected function addModules() {
1700  $out = $this->getOutput();
1701  // Styles and behavior for the legend box (see makeLegend())
1702  $out->addModuleStyles( [
1703  'mediawiki.interface.helpers.styles',
1704  'mediawiki.special.changeslist.legend',
1705  'mediawiki.special.changeslist',
1706  ] );
1707  $out->addModules( 'mediawiki.special.changeslist.legend.js' );
1708 
1709  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
1710  $out->addModules( 'mediawiki.rcfilters.filters.ui' );
1711  $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
1712  }
1713  }
1714 
1715  protected function getGroupName() {
1716  return 'changes';
1717  }
1718 
1735  public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
1736  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
1737  ) {
1738  global $wgLearnerEdits,
1742 
1743  $LEVEL_COUNT = 5;
1744 
1745  // If all levels are selected, don't filter
1746  if ( count( $selectedExpLevels ) === $LEVEL_COUNT ) {
1747  return;
1748  }
1749 
1750  // both 'registered' and 'unregistered', experience levels, if any, are included in 'registered'
1751  if (
1752  in_array( 'registered', $selectedExpLevels ) &&
1753  in_array( 'unregistered', $selectedExpLevels )
1754  ) {
1755  return;
1756  }
1757 
1758  $actorMigration = ActorMigration::newMigration();
1759  $actorQuery = $actorMigration->getJoin( 'rc_user' );
1760  $tables += $actorQuery['tables'];
1761  $join_conds += $actorQuery['joins'];
1762 
1763  // 'registered' but not 'unregistered', experience levels, if any, are included in 'registered'
1764  if (
1765  in_array( 'registered', $selectedExpLevels ) &&
1766  !in_array( 'unregistered', $selectedExpLevels )
1767  ) {
1768  $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1769  return;
1770  }
1771 
1772  if ( $selectedExpLevels === [ 'unregistered' ] ) {
1773  $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1774  return;
1775  }
1776 
1777  $tables[] = 'user';
1778  $join_conds['user'] = [ 'LEFT JOIN', $actorQuery['fields']['rc_user'] . ' = user_id' ];
1779 
1780  if ( $now === 0 ) {
1781  $now = time();
1782  }
1783  $secondsPerDay = 86400;
1784  $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
1785  $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
1786 
1787  $aboveNewcomer = $dbr->makeList(
1788  [
1789  'user_editcount >= ' . intval( $wgLearnerEdits ),
1790  'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ),
1791  ],
1793  );
1794 
1795  $aboveLearner = $dbr->makeList(
1796  [
1797  'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
1798  'user_registration <= ' .
1799  $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ),
1800  ],
1802  );
1803 
1804  $conditions = [];
1805 
1806  if ( in_array( 'unregistered', $selectedExpLevels ) ) {
1807  $selectedExpLevels = array_diff( $selectedExpLevels, [ 'unregistered' ] );
1808  $conditions[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1809  }
1810 
1811  if ( $selectedExpLevels === [ 'newcomer' ] ) {
1812  $conditions[] = "NOT ( $aboveNewcomer )";
1813  } elseif ( $selectedExpLevels === [ 'learner' ] ) {
1814  $conditions[] = $dbr->makeList(
1815  [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
1817  );
1818  } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
1819  $conditions[] = $aboveLearner;
1820  } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
1821  $conditions[] = "NOT ( $aboveLearner )";
1822  } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
1823  $conditions[] = $dbr->makeList(
1824  [ "NOT ( $aboveNewcomer )", $aboveLearner ],
1826  );
1827  } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
1828  $conditions[] = $aboveNewcomer;
1829  } elseif ( $selectedExpLevels === [ 'experienced', 'learner', 'newcomer' ] ) {
1830  $conditions[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1831  }
1832 
1833  if ( count( $conditions ) > 1 ) {
1834  $conds[] = $dbr->makeList( $conditions, IDatabase::LIST_OR );
1835  } elseif ( count( $conditions ) === 1 ) {
1836  $conds[] = reset( $conditions );
1837  }
1838  }
1839 
1845  public function isStructuredFilterUiEnabled() {
1846  if ( $this->getRequest()->getBool( 'rcfilters' ) ) {
1847  return true;
1848  }
1849 
1850  return static::checkStructuredFilterUiEnabled(
1851  $this->getConfig(),
1852  $this->getUser()
1853  );
1854  }
1855 
1864  public static function checkStructuredFilterUiEnabled( Config $config, User $user ) {
1865  return !$user->getOption( 'rcenhancedfilters-disable' );
1866  }
1867 
1875  public function getDefaultLimit() {
1876  return $this->getUser()->getIntOption( static::$limitPreferenceName );
1877  }
1878 
1887  public function getDefaultDays() {
1888  return floatval( $this->getUser()->getOption( static::$daysPreferenceName ) );
1889  }
1890 }
$filter
$filter
Definition: profileinfo.php:341
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:678
ResourceLoaderContext
Object passed around to modules which contains information about the state of a specific loader reque...
Definition: ResourceLoaderContext.php:32
RecentChange\getQueryInfo
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new recentchanges object.
Definition: RecentChange.php:280
$user
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1476
ChangesListFilterGroup\getName
getName()
Definition: ChangesListFilterGroup.php:281
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:306
ChangesListSpecialPage\getExtraOptions
getExtraOptions( $opts)
Get options to be displayed in a form.
Definition: ChangesListSpecialPage.php:1635
ChangesListSpecialPage\checkStructuredFilterUiEnabled
static checkStructuredFilterUiEnabled(Config $config, User $user)
Static method to check whether StructuredFilter UI is enabled for the given user.
Definition: ChangesListSpecialPage.php:1864
ChangesListSpecialPage\__construct
__construct( $name, $restriction)
Definition: ChangesListSpecialPage.php:109
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:796
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:703
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
$context
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2636
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
FormOptions\FLOAT
const FLOAT
Float type, maps guessType() to WebRequest::getFloat()
Definition: FormOptions.php:48
ChangesListSpecialPage\includeRcFiltersApp
includeRcFiltersApp()
Include the modules and configuration for the RCFilters app.
Definition: ChangesListSpecialPage.php:774
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:725
$wgExperiencedUserMemberSince
$wgExperiencedUserMemberSince
Name of the external diff engine to use.
Definition: DefaultSettings.php:8915
captcha-old.count
count
Definition: captcha-old.py:249
ChangesListSpecialPage\makeLegend
makeLegend()
Return the legend displayed within the fieldset.
Definition: ChangesListSpecialPage.php:1644
ChangesListSpecialPage\execute
execute( $subpage)
Definition: ChangesListSpecialPage.php:621
ChangesListSpecialPage\webOutputHeader
webOutputHeader( $rowCount, $opts)
Send header output to the OutputPage object, only called if not using feeds.
Definition: ChangesListSpecialPage.php:1556
ChangesListSpecialPage\fixContradictoryOptions
fixContradictoryOptions(FormOptions $opts)
Fix invalid options by resetting pairs that should never appear together.
Definition: ChangesListSpecialPage.php:1303
ChangesListSpecialPage\parseParameters
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
Definition: ChangesListSpecialPage.php:1245
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1983
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1912
ChangesListSpecialPage\doMainQuery
doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.
Definition: ChangesListSpecialPage.php:1497
$namespaces
namespace and then decline to actually register it & $namespaces
Definition: hooks.txt:925
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:780
RC_LOG
const RC_LOG
Definition: Defines.php:144
ChangesListSpecialPage\fixBackwardsCompatibilityOptions
fixBackwardsCompatibilityOptions(FormOptions $opts)
Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards compatibility.
Definition: ChangesListSpecialPage.php:1345
ChangesListSpecialPage
Special page which uses a ChangesList to show query results.
Definition: ChangesListSpecialPage.php:36
$tables
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:979
DeferredUpdates\addUpdate
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
Definition: DeferredUpdates.php:79
ChangesListBooleanFilter
Represents a hide-based boolean filter (used on ChangesListSpecialPage and descendants)
Definition: ChangesListBooleanFilter.php:31
$params
$params
Definition: styleTest.css.php:44
RC_EDIT
const RC_EDIT
Definition: Defines.php:142
WANCacheReapUpdate
Class for fixing stale WANObjectCache keys using a purge event source.
Definition: WANCacheReapUpdate.php:26
RequestContext\newExtraneousContext
static newExtraneousContext(Title $title, $request=[])
Create a new extraneous context.
Definition: RequestContext.php:600
ChangesListSpecialPage\getDefaultDays
getDefaultDays()
Get the default value of the number of days to display when loading the result set.
Definition: ChangesListSpecialPage.php:1887
$s
$s
Definition: mergeMessageFileList.php:186
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:82
FormOptions\reset
reset( $name)
Delete the option value.
Definition: FormOptions.php:205
ChangesListSpecialPage\fetchOptionsFromRequest
fetchOptionsFromRequest( $opts)
Fetch values for a FormOptions object from the WebRequest associated with this instance.
Definition: ChangesListSpecialPage.php:1233
wfLogWarning
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
Definition: GlobalFunctions.php:1105
FormOptions\validateIntBounds
validateIntBounds( $name, $min, $max)
Definition: FormOptions.php:253
RecentChange\SRC_CATEGORIZE
const SRC_CATEGORIZE
Definition: RecentChange.php:76
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:152
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
$messages
$messages
Definition: LogTests.i18n.php:8
ChangesListFilterGroup
Represents a filter group (used on ChangesListSpecialPage and descendants)
Definition: ChangesListFilterGroup.php:36
RecentChange\SRC_LOG
const SRC_LOG
Definition: RecentChange.php:74
ActorMigration\newMigration
static newMigration()
Static constructor.
Definition: ActorMigration.php:111
ChangesListSpecialPage\$filterGroups
$filterGroups
Filter groups, and their contained filters This is an associative array (with group name as key) of C...
Definition: ChangesListSpecialPage.php:107
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
LIST_AND
const LIST_AND
Definition: Defines.php:43
ChangesListSpecialPage\outputNoResults
outputNoResults()
Add the "no results" message to the output.
Definition: ChangesListSpecialPage.php:910
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:1596
$dbr
$dbr
Definition: testCompression.php:50
ChangeTags\truncateTagDescription
static truncateTagDescription( $tag, $length, IContextSource $context)
Get truncated message for the tag's long description.
Definition: ChangeTags.php:198
$wgExperiencedUserEdits
$wgExperiencedUserEdits
Name of the external diff engine to use.
Definition: DefaultSettings.php:8914
ChangesListSpecialPage\webOutput
webOutput( $rows, $opts)
Send output to the OutputPage object, only called if not used feeds.
Definition: ChangesListSpecialPage.php:1569
ChangeTags\modifyDisplayQuery
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
Definition: ChangeTags.php:728
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1588
Config
Interface for configuration instances.
Definition: Config.php:28
ChangesListSpecialPage\TAG_DESC_CHARACTER_LIMIT
const TAG_DESC_CHARACTER_LIMIT
Maximum length of a tag description in UTF-8 characters.
Definition: ChangesListSpecialPage.php:41
FormatJson\decode
static decode( $value, $assoc=false)
Decodes a JSON string.
Definition: FormatJson.php:174
LIST_OR
const LIST_OR
Definition: Defines.php:46
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:764
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
ChangesListSpecialPage\$filterGroupDefinitions
$filterGroupDefinitions
Definition information for the filters and their groups.
Definition: ChangesListSpecialPage.php:89
ChangesListSpecialPage\$reviewStatusFilterGroupDefinition
$reviewStatusFilterGroupDefinition
Definition: ChangesListSpecialPage.php:96
LogFormatter\newFromRow
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
Definition: LogFormatter.php:70
Wikimedia\Rdbms\DBQueryTimeoutError
Error thrown when a query times out.
Definition: DBQueryTimeoutError.php:29
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
ChangesListSpecialPage\convertParamsForLink
convertParamsForLink( $params)
Convert parameters values from true/false to 1/0 so they are not omitted by wfArrayToCgi() T38524.
Definition: ChangesListSpecialPage.php:1414
ChangesListSpecialPage\getRcFiltersConfigVars
static getRcFiltersConfigVars(ResourceLoaderContext $context)
Get config vars to export with the mediawiki.rcfilters.filters.ui module.
Definition: ChangesListSpecialPage.php:832
ChangesListSpecialPage\getRows
getRows()
Get the database result for this special page instance.
Definition: ChangesListSpecialPage.php:934
ChangesListSpecialPage\outputFeedLinks
outputFeedLinks()
Output feed links.
Definition: ChangesListSpecialPage.php:1578
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2636
ChangesListSpecialPage\runMainQueryHook
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
Definition: ChangesListSpecialPage.php:1532
ChangesListSpecialPage\isStructuredFilterUiEnabled
isStructuredFilterUiEnabled()
Check whether the structured filter UI is enabled.
Definition: ChangesListSpecialPage.php:1845
ChangesListSpecialPage\$daysPreferenceName
static string $daysPreferenceName
Preference name for 'days'.
Definition: ChangesListSpecialPage.php:53
ChangesListSpecialPage\$hideCategorizationFilterDefinition
$hideCategorizationFilterDefinition
Definition: ChangesListSpecialPage.php:99
ChangesListSpecialPage\getStructuredFilterJsData
getStructuredFilterJsData()
Gets structured filter information needed by JS.
Definition: ChangesListSpecialPage.php:1199
ChangesListStringOptionsFilterGroup\SEPARATOR
const SEPARATOR
Delimiter.
Definition: ChangesListStringOptionsFilterGroup.php:46
ChangesListSpecialPage\outputChangesList
outputChangesList( $rows, $opts)
Build and output the actual changes list.
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$code
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition: hooks.txt:780
ChangesListSpecialPage\getFilterGroups
getFilterGroups()
Gets the currently registered filters groups.
Definition: ChangesListSpecialPage.php:1172
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:531
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:735
RecentChange\SRC_EDIT
const SRC_EDIT
Definition: RecentChange.php:72
$output
$output
Definition: SyntaxHighlight.php:334
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
RecentChange\SRC_NEW
const SRC_NEW
Definition: RecentChange.php:73
ChangesListSpecialPage\buildQuery
buildQuery(&$tables, &$fields, &$conds, &$query_options, &$join_conds, FormOptions $opts)
Sets appropriate tables, fields, conditions, etc.
Definition: ChangesListSpecialPage.php:1435
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
ChangesListSpecialPage\getDefaultLimit
getDefaultLimit()
Get the default value of the number of changes to display when loading the result set.
Definition: ChangesListSpecialPage.php:1875
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:698
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
RecentChange\PRC_PATROLLED
const PRC_PATROLLED
Definition: RecentChange.php:79
ChangeTags\listExplicitlyDefinedTags
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the change_tag_def table of the database.
Definition: ChangeTags.php:1386
ChangesListSpecialPage\$rcOptions
FormOptions $rcOptions
Definition: ChangesListSpecialPage.php:71
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:67
$value
$value
Definition: styleTest.css.php:49
ChangesListSpecialPage\registerFilters
registerFilters()
Register all filters and their groups (including those from hooks), plus handle conflicts and default...
Definition: ChangesListSpecialPage.php:969
ChangesListSpecialPage\$savedQueriesPreferenceName
static string $savedQueriesPreferenceName
Preference name for saved queries.
Definition: ChangesListSpecialPage.php:47
FormOptions\validateBounds
validateBounds( $name, $min, $max)
Constrain a numeric value for a given option to a given range.
Definition: FormOptions.php:268
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
ChangesListSpecialPage\setup
setup( $parameters)
Register all the filters, including legacy hook-driven ones.
Definition: ChangesListSpecialPage.php:1105
ChangesListSpecialPage\getChangeTagList
static getChangeTagList(ResourceLoaderContext $context)
Fetch the change tags list for the front end.
Definition: ChangesListSpecialPage.php:846
ChangesListSpecialPage\getFilterGroup
getFilterGroup( $groupName)
Gets a specified ChangesListFilterGroup by name.
Definition: ChangesListSpecialPage.php:1183
ChangesListSpecialPage\outputTimeout
outputTimeout()
Add the "timeout" message to the output.
Definition: ChangesListSpecialPage.php:921
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:715
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:143
RecentChange\PRC_AUTOPATROLLED
const PRC_AUTOPATROLLED
Definition: RecentChange.php:80
ChangeTags\listSoftwareActivatedTags
static listSoftwareActivatedTags()
Lists those tags which core or extensions report as being "active".
Definition: ChangeTags.php:1341
$wgLearnerEdits
$wgLearnerEdits
The following variables define 3 user experience levels:
Definition: DefaultSettings.php:8912
ChangesListSpecialPage\addModules
addModules()
Add page-specific modules.
Definition: ChangesListSpecialPage.php:1699
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:1715
ChangesListSpecialPage\areFiltersInConflict
areFiltersInConflict()
Check if filters are in conflict and guaranteed to return no results.
Definition: ChangesListSpecialPage.php:581
ChangesListSpecialPage\getDefaultOptions
getDefaultOptions()
Get a FormOptions object containing the default options.
Definition: ChangesListSpecialPage.php:1131
ChangesListSpecialPage\transformFilterDefinition
transformFilterDefinition(array $filterDefinition)
Transforms filter definition to prepare it for constructor.
Definition: ChangesListSpecialPage.php:1043
ChangesListBooleanFilterGroup
If the group is active, any unchecked filters will translate to hide parameters in the URL.
Definition: ChangesListBooleanFilterGroup.php:12
$cache
$cache
Definition: mcc.php:33
$rows
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
Definition: hooks.txt:2636
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:1546
RecentChange\PRC_UNPATROLLED
const PRC_UNPATROLLED
Definition: RecentChange.php:78
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
ChangesListSpecialPage\$collapsedPreferenceName
static string $collapsedPreferenceName
Preference name for collapsing the active filter display.
Definition: ChangesListSpecialPage.php:65
NS_USER
const NS_USER
Definition: Defines.php:66
$wgLearnerMemberSince
$wgLearnerMemberSince
Name of the external diff engine to use.
Definition: DefaultSettings.php:8913
LoggerFactory
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
Definition: logger.txt:5
ChangesListSpecialPage\$rcSubpage
string $rcSubpage
Definition: ChangesListSpecialPage.php:68
$batch
$batch
Definition: linkcache.txt:23
of
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
Definition: globals.txt:10
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:1478
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:215
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:1735
ChangesListSpecialPage\replaceOldOptions
replaceOldOptions(FormOptions $opts)
Replace old options with their structured UI equivalents.
Definition: ChangesListSpecialPage.php:1365
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
RC_CATEGORIZE
const RC_CATEGORIZE
Definition: Defines.php:146
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:1057
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
FormOptions\getChangedValues
getChangedValues()
Return options modified as an array ( name => value )
Definition: FormOptions.php:306
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:48
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
ChangesListSpecialPage\setBottomText
setBottomText(FormOptions $opts)
Send the text to be displayed after the options.
Definition: ChangesListSpecialPage.php:1622
ChangesListSpecialPage\validateOptions
validateOptions(FormOptions $opts)
Validate a FormOptions object generated by getDefaultOptions() with values already populated.
Definition: ChangesListSpecialPage.php:1284
ChangesListSpecialPage\registerFilterGroup
registerFilterGroup(ChangesListFilterGroup $group)
Register a structured changes list filter group.
Definition: ChangesListSpecialPage.php:1161
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:952
MWNamespace\getAssociated
static getAssociated( $index)
Get the associated namespace.
Definition: MWNamespace.php:163
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:633
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:228
ChangeTags\tagDescription
static tagDescription( $tag, MessageLocalizer $context)
Get a short description for a tag.
Definition: ChangeTags.php:148
ChangesListSpecialPage\$limitPreferenceName
static string $limitPreferenceName
Preference name for 'limit'.
Definition: ChangesListSpecialPage.php:59
ChangesListSpecialPage\getLegacyShowHideFilters
getLegacyShowHideFilters()
Definition: ChangesListSpecialPage.php:1083
MWExceptionHandler\logException
static logException( $e, $catcher=self::CAUGHT_BY_OTHER)
Log an exception to the exception log (if enabled).
Definition: MWExceptionHandler.php:667
ChangesListSpecialPage\$legacyReviewStatusFilterGroupDefinition
$legacyReviewStatusFilterGroupDefinition
Definition: ChangesListSpecialPage.php:93
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:371
ChangesListSpecialPage\setTopText
setTopText(FormOptions $opts)
Send the text to be displayed before the options.
Definition: ChangesListSpecialPage.php:1611