MediaWiki  master
ChangesListSpecialPage.php
Go to the documentation of this file.
1 <?php
28 
35 abstract class ChangesListSpecialPage extends SpecialPage {
41 
46  protected static $savedQueriesPreferenceName;
47 
52  protected static $daysPreferenceName;
53 
58  protected static $limitPreferenceName;
59 
64  protected static $collapsedPreferenceName;
65 
67  protected $rcSubpage;
68 
70  protected $rcOptions;
71 
72  // Order of both groups and filters is significant; first is top-most priority,
73  // descending from there.
74  // 'showHideSuffix' is a shortcut to and avoid spelling out
75  // details specific to subclasses here.
89 
90  // Same format as filterGroupDefinitions, but for a single group (reviewStatus)
91  // that is registered conditionally.
93 
94  // Single filter group registered conditionally
96 
97  // Single filter group registered conditionally
99 
106  protected $filterGroups = [];
107 
108  public function __construct( $name, $restriction ) {
109  parent::__construct( $name, $restriction );
110 
111  $nonRevisionTypes = [ RC_LOG ];
112  Hooks::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
113 
114  $this->filterGroupDefinitions = [
115  [
116  'name' => 'registration',
117  'title' => 'rcfilters-filtergroup-registration',
119  'filters' => [
120  [
121  'name' => 'hideliu',
122  // rcshowhideliu-show, rcshowhideliu-hide,
123  // wlshowhideliu
124  'showHideSuffix' => 'showhideliu',
125  'default' => false,
126  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
127  &$query_options, &$join_conds
128  ) {
129  $actorMigration = ActorMigration::newMigration();
130  $actorQuery = $actorMigration->getJoin( 'rc_user' );
131  $tables += $actorQuery['tables'];
132  $join_conds += $actorQuery['joins'];
133  $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
134  },
135  'isReplacedInStructuredUi' => true,
136 
137  ],
138  [
139  'name' => 'hideanons',
140  // rcshowhideanons-show, rcshowhideanons-hide,
141  // wlshowhideanons
142  'showHideSuffix' => 'showhideanons',
143  'default' => false,
144  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
145  &$query_options, &$join_conds
146  ) {
147  $actorMigration = ActorMigration::newMigration();
148  $actorQuery = $actorMigration->getJoin( 'rc_user' );
149  $tables += $actorQuery['tables'];
150  $join_conds += $actorQuery['joins'];
151  $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
152  },
153  'isReplacedInStructuredUi' => true,
154  ]
155  ],
156  ],
157 
158  [
159  'name' => 'userExpLevel',
160  'title' => 'rcfilters-filtergroup-userExpLevel',
162  'isFullCoverage' => true,
163  'filters' => [
164  [
165  'name' => 'unregistered',
166  'label' => 'rcfilters-filter-user-experience-level-unregistered-label',
167  'description' => 'rcfilters-filter-user-experience-level-unregistered-description',
168  'cssClassSuffix' => 'user-unregistered',
169  'isRowApplicableCallable' => function ( $ctx, $rc ) {
170  return !$rc->getAttribute( 'rc_user' );
171  }
172  ],
173  [
174  'name' => 'registered',
175  'label' => 'rcfilters-filter-user-experience-level-registered-label',
176  'description' => 'rcfilters-filter-user-experience-level-registered-description',
177  'cssClassSuffix' => 'user-registered',
178  'isRowApplicableCallable' => function ( $ctx, $rc ) {
179  return $rc->getAttribute( 'rc_user' );
180  }
181  ],
182  [
183  'name' => 'newcomer',
184  'label' => 'rcfilters-filter-user-experience-level-newcomer-label',
185  'description' => 'rcfilters-filter-user-experience-level-newcomer-description',
186  'cssClassSuffix' => 'user-newcomer',
187  'isRowApplicableCallable' => function ( $ctx, $rc ) {
188  $performer = $rc->getPerformer();
189  return $performer && $performer->isLoggedIn() &&
190  $performer->getExperienceLevel() === 'newcomer';
191  }
192  ],
193  [
194  'name' => 'learner',
195  'label' => 'rcfilters-filter-user-experience-level-learner-label',
196  'description' => 'rcfilters-filter-user-experience-level-learner-description',
197  'cssClassSuffix' => 'user-learner',
198  'isRowApplicableCallable' => function ( $ctx, $rc ) {
199  $performer = $rc->getPerformer();
200  return $performer && $performer->isLoggedIn() &&
201  $performer->getExperienceLevel() === 'learner';
202  },
203  ],
204  [
205  'name' => 'experienced',
206  'label' => 'rcfilters-filter-user-experience-level-experienced-label',
207  'description' => 'rcfilters-filter-user-experience-level-experienced-description',
208  'cssClassSuffix' => 'user-experienced',
209  'isRowApplicableCallable' => function ( $ctx, $rc ) {
210  $performer = $rc->getPerformer();
211  return $performer && $performer->isLoggedIn() &&
212  $performer->getExperienceLevel() === 'experienced';
213  },
214  ]
215  ],
217  'queryCallable' => [ $this, 'filterOnUserExperienceLevel' ],
218  ],
219 
220  [
221  'name' => 'authorship',
222  'title' => 'rcfilters-filtergroup-authorship',
224  'filters' => [
225  [
226  'name' => 'hidemyself',
227  'label' => 'rcfilters-filter-editsbyself-label',
228  'description' => 'rcfilters-filter-editsbyself-description',
229  // rcshowhidemine-show, rcshowhidemine-hide,
230  // wlshowhidemine
231  'showHideSuffix' => 'showhidemine',
232  'default' => false,
233  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
234  &$query_options, &$join_conds
235  ) {
236  $actorQuery = ActorMigration::newMigration()->getWhere( $dbr, 'rc_user', $ctx->getUser() );
237  $tables += $actorQuery['tables'];
238  $join_conds += $actorQuery['joins'];
239  $conds[] = 'NOT(' . $actorQuery['conds'] . ')';
240  },
241  'cssClassSuffix' => 'self',
242  'isRowApplicableCallable' => function ( $ctx, $rc ) {
243  return $ctx->getUser()->equals( $rc->getPerformer() );
244  },
245  ],
246  [
247  'name' => 'hidebyothers',
248  'label' => 'rcfilters-filter-editsbyother-label',
249  'description' => 'rcfilters-filter-editsbyother-description',
250  'default' => false,
251  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
252  &$query_options, &$join_conds
253  ) {
254  $actorQuery = ActorMigration::newMigration()
255  ->getWhere( $dbr, 'rc_user', $ctx->getUser(), false );
256  $tables += $actorQuery['tables'];
257  $join_conds += $actorQuery['joins'];
258  $conds[] = $actorQuery['conds'];
259  },
260  'cssClassSuffix' => 'others',
261  'isRowApplicableCallable' => function ( $ctx, $rc ) {
262  return !$ctx->getUser()->equals( $rc->getPerformer() );
263  },
264  ]
265  ]
266  ],
267 
268  [
269  'name' => 'automated',
270  'title' => 'rcfilters-filtergroup-automated',
272  'filters' => [
273  [
274  'name' => 'hidebots',
275  'label' => 'rcfilters-filter-bots-label',
276  'description' => 'rcfilters-filter-bots-description',
277  // rcshowhidebots-show, rcshowhidebots-hide,
278  // wlshowhidebots
279  'showHideSuffix' => 'showhidebots',
280  'default' => false,
281  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
282  &$query_options, &$join_conds
283  ) {
284  $conds['rc_bot'] = 0;
285  },
286  'cssClassSuffix' => 'bot',
287  'isRowApplicableCallable' => function ( $ctx, $rc ) {
288  return $rc->getAttribute( 'rc_bot' );
289  },
290  ],
291  [
292  'name' => 'hidehumans',
293  'label' => 'rcfilters-filter-humans-label',
294  'description' => 'rcfilters-filter-humans-description',
295  'default' => false,
296  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
297  &$query_options, &$join_conds
298  ) {
299  $conds['rc_bot'] = 1;
300  },
301  'cssClassSuffix' => 'human',
302  'isRowApplicableCallable' => function ( $ctx, $rc ) {
303  return !$rc->getAttribute( 'rc_bot' );
304  },
305  ]
306  ]
307  ],
308 
309  // significance (conditional)
310 
311  [
312  'name' => 'significance',
313  'title' => 'rcfilters-filtergroup-significance',
315  'priority' => -6,
316  'filters' => [
317  [
318  'name' => 'hideminor',
319  'label' => 'rcfilters-filter-minor-label',
320  'description' => 'rcfilters-filter-minor-description',
321  // rcshowhideminor-show, rcshowhideminor-hide,
322  // wlshowhideminor
323  'showHideSuffix' => 'showhideminor',
324  'default' => false,
325  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
326  &$query_options, &$join_conds
327  ) {
328  $conds[] = 'rc_minor = 0';
329  },
330  'cssClassSuffix' => 'minor',
331  'isRowApplicableCallable' => function ( $ctx, $rc ) {
332  return $rc->getAttribute( 'rc_minor' );
333  }
334  ],
335  [
336  'name' => 'hidemajor',
337  'label' => 'rcfilters-filter-major-label',
338  'description' => 'rcfilters-filter-major-description',
339  'default' => false,
340  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
341  &$query_options, &$join_conds
342  ) {
343  $conds[] = 'rc_minor = 1';
344  },
345  'cssClassSuffix' => 'major',
346  'isRowApplicableCallable' => function ( $ctx, $rc ) {
347  return !$rc->getAttribute( 'rc_minor' );
348  }
349  ]
350  ]
351  ],
352 
353  [
354  'name' => 'lastRevision',
355  'title' => 'rcfilters-filtergroup-lastRevision',
357  'priority' => -7,
358  'filters' => [
359  [
360  'name' => 'hidelastrevision',
361  'label' => 'rcfilters-filter-lastrevision-label',
362  'description' => 'rcfilters-filter-lastrevision-description',
363  'default' => false,
364  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
365  &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
366  $conds[] = $dbr->makeList(
367  [
368  'rc_this_oldid <> page_latest',
369  'rc_type' => $nonRevisionTypes,
370  ],
371  LIST_OR
372  );
373  },
374  'cssClassSuffix' => 'last',
375  'isRowApplicableCallable' => function ( $ctx, $rc ) {
376  return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
377  }
378  ],
379  [
380  'name' => 'hidepreviousrevisions',
381  'label' => 'rcfilters-filter-previousrevision-label',
382  'description' => 'rcfilters-filter-previousrevision-description',
383  'default' => false,
384  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
385  &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
386  $conds[] = $dbr->makeList(
387  [
388  'rc_this_oldid = page_latest',
389  'rc_type' => $nonRevisionTypes,
390  ],
391  LIST_OR
392  );
393  },
394  'cssClassSuffix' => 'previous',
395  'isRowApplicableCallable' => function ( $ctx, $rc ) {
396  return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
397  }
398  ]
399  ]
400  ],
401 
402  // With extensions, there can be change types that will not be hidden by any of these.
403  [
404  'name' => 'changeType',
405  'title' => 'rcfilters-filtergroup-changetype',
407  'priority' => -8,
408  'filters' => [
409  [
410  'name' => 'hidepageedits',
411  'label' => 'rcfilters-filter-pageedits-label',
412  'description' => 'rcfilters-filter-pageedits-description',
413  'default' => false,
414  'priority' => -2,
415  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
416  &$query_options, &$join_conds
417  ) {
418  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT );
419  },
420  'cssClassSuffix' => 'src-mw-edit',
421  'isRowApplicableCallable' => function ( $ctx, $rc ) {
422  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_EDIT;
423  },
424  ],
425  [
426  'name' => 'hidenewpages',
427  'label' => 'rcfilters-filter-newpages-label',
428  'description' => 'rcfilters-filter-newpages-description',
429  'default' => false,
430  'priority' => -3,
431  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
432  &$query_options, &$join_conds
433  ) {
434  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW );
435  },
436  'cssClassSuffix' => 'src-mw-new',
437  'isRowApplicableCallable' => function ( $ctx, $rc ) {
438  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_NEW;
439  },
440  ],
441 
442  // hidecategorization
443 
444  [
445  'name' => 'hidelog',
446  'label' => 'rcfilters-filter-logactions-label',
447  'description' => 'rcfilters-filter-logactions-description',
448  'default' => false,
449  'priority' => -5,
450  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
451  &$query_options, &$join_conds
452  ) {
453  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG );
454  },
455  'cssClassSuffix' => 'src-mw-log',
456  'isRowApplicableCallable' => function ( $ctx, $rc ) {
457  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_LOG;
458  }
459  ],
460  ],
461  ],
462 
463  ];
464 
465  $this->legacyReviewStatusFilterGroupDefinition = [
466  [
467  'name' => 'legacyReviewStatus',
468  'title' => 'rcfilters-filtergroup-reviewstatus',
470  'filters' => [
471  [
472  'name' => 'hidepatrolled',
473  // rcshowhidepatr-show, rcshowhidepatr-hide
474  // wlshowhidepatr
475  'showHideSuffix' => 'showhidepatr',
476  'default' => false,
477  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
478  &$query_options, &$join_conds
479  ) {
480  $conds['rc_patrolled'] = RecentChange::PRC_UNPATROLLED;
481  },
482  'isReplacedInStructuredUi' => true,
483  ],
484  [
485  'name' => 'hideunpatrolled',
486  'default' => false,
487  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
488  &$query_options, &$join_conds
489  ) {
490  $conds[] = 'rc_patrolled != ' . RecentChange::PRC_UNPATROLLED;
491  },
492  'isReplacedInStructuredUi' => true,
493  ],
494  ],
495  ]
496  ];
497 
498  $this->reviewStatusFilterGroupDefinition = [
499  [
500  'name' => 'reviewStatus',
501  'title' => 'rcfilters-filtergroup-reviewstatus',
503  'isFullCoverage' => true,
504  'priority' => -5,
505  'filters' => [
506  [
507  'name' => 'unpatrolled',
508  'label' => 'rcfilters-filter-reviewstatus-unpatrolled-label',
509  'description' => 'rcfilters-filter-reviewstatus-unpatrolled-description',
510  'cssClassSuffix' => 'reviewstatus-unpatrolled',
511  'isRowApplicableCallable' => function ( $ctx, $rc ) {
512  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_UNPATROLLED;
513  },
514  ],
515  [
516  'name' => 'manual',
517  'label' => 'rcfilters-filter-reviewstatus-manual-label',
518  'description' => 'rcfilters-filter-reviewstatus-manual-description',
519  'cssClassSuffix' => 'reviewstatus-manual',
520  'isRowApplicableCallable' => function ( $ctx, $rc ) {
521  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_PATROLLED;
522  },
523  ],
524  [
525  'name' => 'auto',
526  'label' => 'rcfilters-filter-reviewstatus-auto-label',
527  'description' => 'rcfilters-filter-reviewstatus-auto-description',
528  'cssClassSuffix' => 'reviewstatus-auto',
529  'isRowApplicableCallable' => function ( $ctx, $rc ) {
530  return $rc->getAttribute( 'rc_patrolled' ) == RecentChange::PRC_AUTOPATROLLED;
531  },
532  ],
533  ],
535  'queryCallable' => function ( $specialPageClassName, $ctx, $dbr,
536  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selected
537  ) {
538  if ( $selected === [] ) {
539  return;
540  }
541  $rcPatrolledValues = [
542  'unpatrolled' => RecentChange::PRC_UNPATROLLED,
543  'manual' => RecentChange::PRC_PATROLLED,
545  ];
546  // e.g. rc_patrolled IN (0, 2)
547  $conds['rc_patrolled'] = array_map( function ( $s ) use ( $rcPatrolledValues ) {
548  return $rcPatrolledValues[ $s ];
549  }, $selected );
550  }
551  ]
552  ];
553 
554  $this->hideCategorizationFilterDefinition = [
555  'name' => 'hidecategorization',
556  'label' => 'rcfilters-filter-categorization-label',
557  'description' => 'rcfilters-filter-categorization-description',
558  // rcshowhidecategorization-show, rcshowhidecategorization-hide.
559  // wlshowhidecategorization
560  'showHideSuffix' => 'showhidecategorization',
561  'default' => false,
562  'priority' => -4,
563  'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
564  &$query_options, &$join_conds
565  ) {
566  $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE );
567  },
568  'cssClassSuffix' => 'src-mw-categorize',
569  'isRowApplicableCallable' => function ( $ctx, $rc ) {
570  return $rc->getAttribute( 'rc_source' ) === RecentChange::SRC_CATEGORIZE;
571  },
572  ];
573  }
574 
580  protected function areFiltersInConflict() {
581  $opts = $this->getOptions();
583  foreach ( $this->getFilterGroups() as $group ) {
584  if ( $group->getConflictingGroups() ) {
585  wfLogWarning(
586  $group->getName() .
587  " specifies conflicts with other groups but these are not supported yet."
588  );
589  }
590 
592  foreach ( $group->getConflictingFilters() as $conflictingFilter ) {
593  if ( $conflictingFilter->activelyInConflictWithGroup( $group, $opts ) ) {
594  return true;
595  }
596  }
597 
599  foreach ( $group->getFilters() as $filter ) {
601  foreach ( $filter->getConflictingFilters() as $conflictingFilter ) {
602  if (
603  $conflictingFilter->activelyInConflictWithFilter( $filter, $opts ) &&
604  $filter->activelyInConflictWithFilter( $conflictingFilter, $opts )
605  ) {
606  return true;
607  }
608  }
609 
610  }
611 
612  }
613 
614  return false;
615  }
616 
622  public function execute( $subpage ) {
623  $this->rcSubpage = $subpage;
624 
625  $this->considerActionsForDefaultSavedQuery( $subpage );
626 
627  $opts = $this->getOptions();
628  try {
629  $rows = $this->getRows();
630  if ( $rows === false ) {
631  $rows = new FakeResultWrapper( [] );
632  }
633 
634  // Used by Structured UI app to get results without MW chrome
635  if ( $this->getRequest()->getVal( 'action' ) === 'render' ) {
636  $this->getOutput()->setArticleBodyOnly( true );
637  }
638 
639  // Used by "live update" and "view newest" to check
640  // if there's new changes with minimal data transfer
641  if ( $this->getRequest()->getBool( 'peek' ) ) {
642  $code = $rows->numRows() > 0 ? 200 : 204;
643  $this->getOutput()->setStatusCode( $code );
644 
645  if ( $this->getUser()->isAnon() !==
646  $this->getRequest()->getFuzzyBool( 'isAnon' )
647  ) {
648  $this->getOutput()->setStatusCode( 205 );
649  }
650 
651  return;
652  }
653 
654  $batch = new LinkBatch;
655  foreach ( $rows as $row ) {
656  $batch->add( NS_USER, $row->rc_user_text );
657  $batch->add( NS_USER_TALK, $row->rc_user_text );
658  $batch->add( $row->rc_namespace, $row->rc_title );
659  if ( $row->rc_source === RecentChange::SRC_LOG ) {
660  $formatter = LogFormatter::newFromRow( $row );
661  foreach ( $formatter->getPreloadTitles() as $title ) {
662  $batch->addObj( $title );
663  }
664  }
665  }
666  $batch->execute();
667 
668  $this->setHeaders();
669  $this->outputHeader();
670  $this->addModules();
671  $this->webOutput( $rows, $opts );
672 
673  $rows->free();
674  } catch ( DBQueryTimeoutError $timeoutException ) {
675  MWExceptionHandler::logException( $timeoutException );
676 
677  $this->setHeaders();
678  $this->outputHeader();
679  $this->addModules();
680 
681  $this->getOutput()->setStatusCode( 500 );
682  $this->webOutputHeader( 0, $opts );
683  $this->outputTimeout();
684  }
685 
686  if ( $this->getConfig()->get( 'EnableWANCacheReaper' ) ) {
687  // Clean up any bad page entries for titles showing up in RC
689  $this->getDB(),
690  LoggerFactory::getInstance( 'objectcache' )
691  ) );
692  }
693 
694  $this->includeRcFiltersApp();
695  }
696 
704  protected function considerActionsForDefaultSavedQuery( $subpage ) {
705  if ( !$this->isStructuredFilterUiEnabled() || $this->including() ) {
706  return;
707  }
708 
709  $knownParams = $this->getRequest()->getValues(
710  ...array_keys( $this->getOptions()->getAllValues() )
711  );
712 
713  // HACK: Temporarily until we can properly define "sticky" filters and parameters,
714  // we need to exclude several parameters we know should not be counted towards preventing
715  // the loading of defaults.
716  $excludedParams = [ 'limit' => '', 'days' => '', 'enhanced' => '', 'from' => '' ];
717  $knownParams = array_diff_key( $knownParams, $excludedParams );
718 
719  if (
720  // If there are NO known parameters in the URL request
721  // (that are not excluded) then we need to check into loading
722  // the default saved query
723  count( $knownParams ) === 0
724  ) {
725  // Get the saved queries data and parse it
726  $savedQueries = FormatJson::decode(
727  $this->getUser()->getOption( static::$savedQueriesPreferenceName ),
728  true
729  );
730 
731  if ( $savedQueries && isset( $savedQueries[ 'default' ] ) ) {
732  // Only load queries that are 'version' 2, since those
733  // have parameter representation
734  if ( isset( $savedQueries[ 'version' ] ) && $savedQueries[ 'version' ] === '2' ) {
735  $savedQueryDefaultID = $savedQueries[ 'default' ];
736  $defaultQuery = $savedQueries[ 'queries' ][ $savedQueryDefaultID ][ 'data' ];
737 
738  // Build the entire parameter list
739  $query = array_merge(
740  $defaultQuery[ 'params' ],
741  $defaultQuery[ 'highlights' ],
742  [
743  'urlversion' => '2',
744  ]
745  );
746  // Add to the query any parameters that we may have ignored before
747  // but are still valid and requested in the URL
748  $query = array_merge( $this->getRequest()->getValues(), $query );
749  unset( $query[ 'title' ] );
750  $this->getOutput()->redirect( $this->getPageTitle( $subpage )->getCanonicalURL( $query ) );
751  } else {
752  // There's a default, but the version is not 2, and the server can't
753  // actually recognize the query itself. This happens if it is before
754  // the conversion, so we need to tell the UI to reload saved query as
755  // it does the conversion to version 2
756  $this->getOutput()->addJsConfigVars(
757  'wgStructuredChangeFiltersDefaultSavedQueryExists',
758  true
759  );
760 
761  // Add the class that tells the frontend it is still loading
762  // another query
763  $this->getOutput()->addBodyClasses( 'mw-rcfilters-ui-loading' );
764  }
765  }
766  }
767  }
768 
775  protected function includeRcFiltersApp() {
776  $out = $this->getOutput();
777  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
778  $jsData = $this->getStructuredFilterJsData();
779  $messages = [];
780  foreach ( $jsData['messageKeys'] as $key ) {
781  $messages[$key] = $this->msg( $key )->plain();
782  }
783 
784  $out->addBodyClasses( 'mw-rcfilters-enabled' );
785  $collapsed = $this->getUser()->getBoolOption( static::$collapsedPreferenceName );
786  if ( $collapsed ) {
787  $out->addBodyClasses( 'mw-rcfilters-collapsed' );
788  }
789 
790  // These config and message exports should be moved into a ResourceLoader data module (T201574)
791  $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
792  $out->addJsConfigVars( 'wgStructuredChangeFiltersMessages', $messages );
793  $out->addJsConfigVars( 'wgStructuredChangeFiltersCollapsedState', $collapsed );
794 
795  $out->addJsConfigVars(
796  'wgRCFiltersChangeTags',
797  $this->getChangeTagList()
798  );
799  $out->addJsConfigVars(
800  'StructuredChangeFiltersDisplayConfig',
801  [
802  'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
803  'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
804  'limitDefault' => $this->getDefaultLimit(),
805  'daysArray' => $this->getConfig()->get( 'RCLinkDays' ),
806  'daysDefault' => $this->getDefaultDays(),
807  ]
808  );
809 
810  $out->addJsConfigVars(
811  'wgStructuredChangeFiltersSavedQueriesPreferenceName',
812  static::$savedQueriesPreferenceName
813  );
814  $out->addJsConfigVars(
815  'wgStructuredChangeFiltersLimitPreferenceName',
816  static::$limitPreferenceName
817  );
818  $out->addJsConfigVars(
819  'wgStructuredChangeFiltersDaysPreferenceName',
820  static::$daysPreferenceName
821  );
822  $out->addJsConfigVars(
823  'wgStructuredChangeFiltersCollapsedPreferenceName',
824  static::$collapsedPreferenceName
825  );
826 
827  $out->addJsConfigVars(
828  'StructuredChangeFiltersLiveUpdatePollingRate',
829  $this->getConfig()->get( 'StructuredChangeFiltersLiveUpdatePollingRate' )
830  );
831  } else {
832  $out->addBodyClasses( 'mw-rcfilters-disabled' );
833  }
834  }
835 
841  protected function getChangeTagList() {
843  $context = $this->getContext();
844  return $cache->getWithSetCallback(
845  $cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage()->getCode() ),
846  $cache::TTL_MINUTE * 10,
847  function () use ( $context ) {
848  $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
849  $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
850 
851  // Hit counts disabled for perf reasons, see T169997
852  /*
853  $tagStats = ChangeTags::tagUsageStatistics();
854  $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
855 
856  // Sort by hits
857  arsort( $tagHitCounts );
858  */
859  $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags );
860 
861  // Build the list and data
862  $result = [];
863  foreach ( $tagHitCounts as $tagName => $hits ) {
864  if (
865  // Only get active tags
866  isset( $explicitlyDefinedTags[ $tagName ] ) ||
867  isset( $softwareActivatedTags[ $tagName ] )
868  ) {
869  $result[] = [
870  'name' => $tagName,
871  'label' => Sanitizer::stripAllTags(
873  ),
874  'description' =>
876  $tagName, self::TAG_DESC_CHARACTER_LIMIT, $context
877  ),
878  'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
879  'hits' => $hits,
880  ];
881  }
882  }
883 
884  // Instead of sorting by hit count (disabled, see above), sort by display name
885  usort( $result, function ( $a, $b ) {
886  return strcasecmp( $a['label'], $b['label'] );
887  } );
888 
889  return $result;
890  },
891  [
892  'lockTSE' => 30
893  ]
894  );
895  }
896 
900  protected function outputNoResults() {
901  $this->getOutput()->addHTML(
902  '<div class="mw-changeslist-empty">' .
903  $this->msg( 'recentchanges-noresult' )->parse() .
904  '</div>'
905  );
906  }
907 
911  protected function outputTimeout() {
912  $this->getOutput()->addHTML(
913  '<div class="mw-changeslist-empty mw-changeslist-timeout">' .
914  $this->msg( 'recentchanges-timeout' )->parse() .
915  '</div>'
916  );
917  }
918 
924  public function getRows() {
925  $opts = $this->getOptions();
926 
927  $tables = [];
928  $fields = [];
929  $conds = [];
930  $query_options = [];
931  $join_conds = [];
932  $this->buildQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
933 
934  return $this->doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
935  }
936 
942  public function getOptions() {
943  if ( $this->rcOptions === null ) {
944  $this->rcOptions = $this->setup( $this->rcSubpage );
945  }
946 
947  return $this->rcOptions;
948  }
949 
959  protected function registerFilters() {
960  $this->registerFiltersFromDefinitions( $this->filterGroupDefinitions );
961 
962  // Make sure this is not being transcluded (we don't want to show this
963  // information to all users just because the user that saves the edit can
964  // patrol or is logged in)
965  if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
966  $this->registerFiltersFromDefinitions( $this->legacyReviewStatusFilterGroupDefinition );
967  $this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition );
968  }
969 
970  $changeTypeGroup = $this->getFilterGroup( 'changeType' );
971 
972  if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
973  $transformedHideCategorizationDef = $this->transformFilterDefinition(
974  $this->hideCategorizationFilterDefinition
975  );
976 
977  $transformedHideCategorizationDef['group'] = $changeTypeGroup;
978 
979  $hideCategorization = new ChangesListBooleanFilter(
980  $transformedHideCategorizationDef
981  );
982  }
983 
984  Hooks::run( 'ChangesListSpecialPageStructuredFilters', [ $this ] );
985 
986  $this->registerFiltersFromDefinitions( [] );
987 
988  $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' );
989  $registered = $userExperienceLevel->getFilter( 'registered' );
990  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'newcomer' ) );
991  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'learner' ) );
992  $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'experienced' ) );
993 
994  $categoryFilter = $changeTypeGroup->getFilter( 'hidecategorization' );
995  $logactionsFilter = $changeTypeGroup->getFilter( 'hidelog' );
996  $pagecreationFilter = $changeTypeGroup->getFilter( 'hidenewpages' );
997 
998  $significanceTypeGroup = $this->getFilterGroup( 'significance' );
999  $hideMinorFilter = $significanceTypeGroup->getFilter( 'hideminor' );
1000 
1001  // categoryFilter is conditional; see registerFilters
1002  if ( $categoryFilter !== null ) {
1003  $hideMinorFilter->conflictsWith(
1004  $categoryFilter,
1005  'rcfilters-hideminor-conflicts-typeofchange-global',
1006  'rcfilters-hideminor-conflicts-typeofchange',
1007  'rcfilters-typeofchange-conflicts-hideminor'
1008  );
1009  }
1010  $hideMinorFilter->conflictsWith(
1011  $logactionsFilter,
1012  'rcfilters-hideminor-conflicts-typeofchange-global',
1013  'rcfilters-hideminor-conflicts-typeofchange',
1014  'rcfilters-typeofchange-conflicts-hideminor'
1015  );
1016  $hideMinorFilter->conflictsWith(
1017  $pagecreationFilter,
1018  'rcfilters-hideminor-conflicts-typeofchange-global',
1019  'rcfilters-hideminor-conflicts-typeofchange',
1020  'rcfilters-typeofchange-conflicts-hideminor'
1021  );
1022  }
1023 
1033  protected function transformFilterDefinition( array $filterDefinition ) {
1034  return $filterDefinition;
1035  }
1036 
1046  protected function registerFiltersFromDefinitions( array $definition ) {
1047  $autoFillPriority = -1;
1048  foreach ( $definition as $groupDefinition ) {
1049  if ( !isset( $groupDefinition['priority'] ) ) {
1050  $groupDefinition['priority'] = $autoFillPriority;
1051  } else {
1052  // If it's explicitly specified, start over the auto-fill
1053  $autoFillPriority = $groupDefinition['priority'];
1054  }
1055 
1056  $autoFillPriority--;
1057 
1058  $className = $groupDefinition['class'];
1059  unset( $groupDefinition['class'] );
1060 
1061  foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
1062  $filterDefinition = $this->transformFilterDefinition( $filterDefinition );
1063  }
1064 
1065  $this->registerFilterGroup( new $className( $groupDefinition ) );
1066  }
1067  }
1068 
1072  protected function getLegacyShowHideFilters() {
1073  $filters = [];
1074  foreach ( $this->filterGroups as $group ) {
1075  if ( $group instanceof ChangesListBooleanFilterGroup ) {
1076  foreach ( $group->getFilters() as $key => $filter ) {
1077  if ( $filter->displaysOnUnstructuredUi( $this ) ) {
1078  $filters[ $key ] = $filter;
1079  }
1080  }
1081  }
1082  }
1083  return $filters;
1084  }
1085 
1094  public function setup( $parameters ) {
1095  $this->registerFilters();
1096 
1097  $opts = $this->getDefaultOptions();
1098 
1099  $opts = $this->fetchOptionsFromRequest( $opts );
1100 
1101  // Give precedence to subpage syntax
1102  if ( $parameters !== null ) {
1103  $this->parseParameters( $parameters, $opts );
1104  }
1105 
1106  $this->validateOptions( $opts );
1107 
1108  return $opts;
1109  }
1110 
1120  public function getDefaultOptions() {
1121  $opts = new FormOptions();
1122  $structuredUI = $this->isStructuredFilterUiEnabled();
1123  // If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
1124  $useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
1125 
1127  foreach ( $this->filterGroups as $filterGroup ) {
1128  $filterGroup->addOptions( $opts, $useDefaults, $structuredUI );
1129  }
1130 
1131  $opts->add( 'namespace', '', FormOptions::STRING );
1132  $opts->add( 'invert', false );
1133  $opts->add( 'associated', false );
1134  $opts->add( 'urlversion', 1 );
1135  $opts->add( 'tagfilter', '' );
1136 
1137  $opts->add( 'days', $this->getDefaultDays(), FormOptions::FLOAT );
1138  $opts->add( 'limit', $this->getDefaultLimit(), FormOptions::INT );
1139 
1140  $opts->add( 'from', '' );
1141 
1142  return $opts;
1143  }
1144 
1150  public function registerFilterGroup( ChangesListFilterGroup $group ) {
1151  $groupName = $group->getName();
1152 
1153  $this->filterGroups[$groupName] = $group;
1154  }
1155 
1161  protected function getFilterGroups() {
1162  return $this->filterGroups;
1163  }
1164 
1172  public function getFilterGroup( $groupName ) {
1173  return $this->filterGroups[$groupName] ?? null;
1174  }
1175 
1176  // Currently, this intentionally only includes filters that display
1177  // in the structured UI. This can be changed easily, though, if we want
1178  // to include data on filters that use the unstructured UI. messageKeys is a
1179  // special top-level value, with the value being an array of the message keys to
1180  // send to the client.
1188  public function getStructuredFilterJsData() {
1189  $output = [
1190  'groups' => [],
1191  'messageKeys' => [],
1192  ];
1193 
1194  usort( $this->filterGroups, function ( $a, $b ) {
1195  return $b->getPriority() <=> $a->getPriority();
1196  } );
1197 
1198  foreach ( $this->filterGroups as $groupName => $group ) {
1199  $groupOutput = $group->getJsData( $this );
1200  if ( $groupOutput !== null ) {
1201  $output['messageKeys'] = array_merge(
1202  $output['messageKeys'],
1203  $groupOutput['messageKeys']
1204  );
1205 
1206  unset( $groupOutput['messageKeys'] );
1207  $output['groups'][] = $groupOutput;
1208  }
1209  }
1210 
1211  return $output;
1212  }
1213 
1222  protected function fetchOptionsFromRequest( $opts ) {
1223  $opts->fetchValuesFromRequest( $this->getRequest() );
1224 
1225  return $opts;
1226  }
1227 
1234  public function parseParameters( $par, FormOptions $opts ) {
1235  $stringParameterNameSet = [];
1236  $hideParameterNameSet = [];
1237 
1238  // URL parameters can be per-group, like 'userExpLevel',
1239  // or per-filter, like 'hideminor'.
1240 
1241  foreach ( $this->filterGroups as $filterGroup ) {
1242  if ( $filterGroup instanceof ChangesListStringOptionsFilterGroup ) {
1243  $stringParameterNameSet[$filterGroup->getName()] = true;
1244  } elseif ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1245  foreach ( $filterGroup->getFilters() as $filter ) {
1246  $hideParameterNameSet[$filter->getName()] = true;
1247  }
1248  }
1249  }
1250 
1251  $bits = preg_split( '/\s*,\s*/', trim( $par ) );
1252  foreach ( $bits as $bit ) {
1253  $m = [];
1254  if ( isset( $hideParameterNameSet[$bit] ) ) {
1255  // hidefoo => hidefoo=true
1256  $opts[$bit] = true;
1257  } elseif ( isset( $hideParameterNameSet["hide$bit"] ) ) {
1258  // foo => hidefoo=false
1259  $opts["hide$bit"] = false;
1260  } elseif ( preg_match( '/^(.*)=(.*)$/', $bit, $m ) ) {
1261  if ( isset( $stringParameterNameSet[$m[1]] ) ) {
1262  $opts[$m[1]] = $m[2];
1263  }
1264  }
1265  }
1266  }
1267 
1273  public function validateOptions( FormOptions $opts ) {
1274  $isContradictory = $this->fixContradictoryOptions( $opts );
1275  $isReplaced = $this->replaceOldOptions( $opts );
1276 
1277  if ( $isContradictory || $isReplaced ) {
1278  $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
1279  $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
1280  }
1281 
1282  $opts->validateIntBounds( 'limit', 0, 1000 );
1283  $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
1284  }
1285 
1292  private function fixContradictoryOptions( FormOptions $opts ) {
1293  $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
1294 
1295  foreach ( $this->filterGroups as $filterGroup ) {
1296  if ( $filterGroup instanceof ChangesListBooleanFilterGroup ) {
1297  $filters = $filterGroup->getFilters();
1298 
1299  if ( count( $filters ) === 1 ) {
1300  // legacy boolean filters should not be considered
1301  continue;
1302  }
1303 
1304  $allInGroupEnabled = array_reduce(
1305  $filters,
1306  function ( $carry, $filter ) use ( $opts ) {
1307  return $carry && $opts[ $filter->getName() ];
1308  },
1309  /* initialValue */ count( $filters ) > 0
1310  );
1311 
1312  if ( $allInGroupEnabled ) {
1313  foreach ( $filters as $filter ) {
1314  $opts[ $filter->getName() ] = false;
1315  }
1316 
1317  $fixed = true;
1318  }
1319  }
1320  }
1321 
1322  return $fixed;
1323  }
1324 
1334  private function fixBackwardsCompatibilityOptions( FormOptions $opts ) {
1335  if ( $opts['hideanons'] && $opts['hideliu'] ) {
1336  $opts->reset( 'hideanons' );
1337  if ( !$opts['hidebots'] ) {
1338  $opts->reset( 'hideliu' );
1339  $opts['hidehumans'] = 1;
1340  }
1341 
1342  return true;
1343  }
1344 
1345  return false;
1346  }
1347 
1354  public function replaceOldOptions( FormOptions $opts ) {
1355  if ( !$this->isStructuredFilterUiEnabled() ) {
1356  return false;
1357  }
1358 
1359  $changed = false;
1360 
1361  // At this point 'hideanons' and 'hideliu' cannot be both true,
1362  // because fixBackwardsCompatibilityOptions resets (at least) 'hideanons' in such case
1363  if ( $opts[ 'hideanons' ] ) {
1364  $opts->reset( 'hideanons' );
1365  $opts[ 'userExpLevel' ] = 'registered';
1366  $changed = true;
1367  }
1368 
1369  if ( $opts[ 'hideliu' ] ) {
1370  $opts->reset( 'hideliu' );
1371  $opts[ 'userExpLevel' ] = 'unregistered';
1372  $changed = true;
1373  }
1374 
1375  if ( $this->getFilterGroup( 'legacyReviewStatus' ) ) {
1376  if ( $opts[ 'hidepatrolled' ] ) {
1377  $opts->reset( 'hidepatrolled' );
1378  $opts[ 'reviewStatus' ] = 'unpatrolled';
1379  $changed = true;
1380  }
1381 
1382  if ( $opts[ 'hideunpatrolled' ] ) {
1383  $opts->reset( 'hideunpatrolled' );
1384  $opts[ 'reviewStatus' ] = implode(
1386  [ 'manual', 'auto' ]
1387  );
1388  $changed = true;
1389  }
1390  }
1391 
1392  return $changed;
1393  }
1394 
1403  protected function convertParamsForLink( $params ) {
1404  foreach ( $params as &$value ) {
1405  if ( $value === false ) {
1406  $value = '0';
1407  }
1408  }
1409  unset( $value );
1410  return $params;
1411  }
1412 
1424  protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
1425  &$join_conds, FormOptions $opts
1426  ) {
1427  $dbr = $this->getDB();
1428  $isStructuredUI = $this->isStructuredFilterUiEnabled();
1429 
1431  foreach ( $this->filterGroups as $filterGroup ) {
1432  $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1433  $query_options, $join_conds, $opts, $isStructuredUI );
1434  }
1435 
1436  // Namespace filtering
1437  if ( $opts[ 'namespace' ] !== '' ) {
1438  $namespaces = explode( ';', $opts[ 'namespace' ] );
1439 
1440  if ( $opts[ 'associated' ] ) {
1441  $associatedNamespaces = array_map(
1442  function ( $ns ) {
1443  return MWNamespace::getAssociated( $ns );
1444  },
1445  $namespaces
1446  );
1447  $namespaces = array_unique( array_merge( $namespaces, $associatedNamespaces ) );
1448  }
1449 
1450  if ( count( $namespaces ) === 1 ) {
1451  $operator = $opts[ 'invert' ] ? '!=' : '=';
1452  $value = $dbr->addQuotes( reset( $namespaces ) );
1453  } else {
1454  $operator = $opts[ 'invert' ] ? 'NOT IN' : 'IN';
1455  sort( $namespaces );
1456  $value = '(' . $dbr->makeList( $namespaces ) . ')';
1457  }
1458  $conds[] = "rc_namespace $operator $value";
1459  }
1460 
1461  // Calculate cutoff
1462  $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
1463  $cutoff = $dbr->timestamp( $cutoff_unixtime );
1464 
1465  $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
1466  if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW, $cutoff ) ) {
1467  $cutoff = $dbr->timestamp( $opts['from'] );
1468  } else {
1469  $opts->reset( 'from' );
1470  }
1471 
1472  $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
1473  }
1474 
1486  protected function doMainQuery( $tables, $fields, $conds,
1487  $query_options, $join_conds, FormOptions $opts
1488  ) {
1489  $rcQuery = RecentChange::getQueryInfo();
1490  $tables = array_merge( $tables, $rcQuery['tables'] );
1491  $fields = array_merge( $rcQuery['fields'], $fields );
1492  $join_conds = array_merge( $join_conds, $rcQuery['joins'] );
1493 
1495  $tables,
1496  $fields,
1497  $conds,
1498  $join_conds,
1499  $query_options,
1500  ''
1501  );
1502 
1503  if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
1504  $opts )
1505  ) {
1506  return false;
1507  }
1508 
1509  $dbr = $this->getDB();
1510 
1511  return $dbr->select(
1512  $tables,
1513  $fields,
1514  $conds,
1515  __METHOD__,
1516  $query_options,
1517  $join_conds
1518  );
1519  }
1520 
1521  protected function runMainQueryHook( &$tables, &$fields, &$conds,
1522  &$query_options, &$join_conds, $opts
1523  ) {
1524  return Hooks::run(
1525  'ChangesListSpecialPageQuery',
1526  [ $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ]
1527  );
1528  }
1529 
1535  protected function getDB() {
1536  return wfGetDB( DB_REPLICA );
1537  }
1538 
1545  private function webOutputHeader( $rowCount, $opts ) {
1546  if ( !$this->including() ) {
1547  $this->outputFeedLinks();
1548  $this->doHeader( $opts, $rowCount );
1549  }
1550  }
1551 
1558  public function webOutput( $rows, $opts ) {
1559  $this->webOutputHeader( $rows->numRows(), $opts );
1560 
1561  $this->outputChangesList( $rows, $opts );
1562  }
1563 
1567  public function outputFeedLinks() {
1568  // nothing by default
1569  }
1570 
1577  abstract public function outputChangesList( $rows, $opts );
1578 
1585  public function doHeader( $opts, $numRows ) {
1586  $this->setTopText( $opts );
1587 
1588  // @todo Lots of stuff should be done here.
1589 
1590  $this->setBottomText( $opts );
1591  }
1592 
1600  public function setTopText( FormOptions $opts ) {
1601  // nothing by default
1602  }
1603 
1611  public function setBottomText( FormOptions $opts ) {
1612  // nothing by default
1613  }
1614 
1624  public function getExtraOptions( $opts ) {
1625  return [];
1626  }
1627 
1633  public function makeLegend() {
1634  $context = $this->getContext();
1635  $user = $context->getUser();
1636  # The legend showing what the letters and stuff mean
1637  $legend = Html::openElement( 'dl' ) . "\n";
1638  # Iterates through them and gets the messages for both letter and tooltip
1639  $legendItems = $context->getConfig()->get( 'RecentChangesFlags' );
1640  if ( !( $user->useRCPatrol() || $user->useNPPatrol() ) ) {
1641  unset( $legendItems['unpatrolled'] );
1642  }
1643  foreach ( $legendItems as $key => $item ) { # generate items of the legend
1644  $label = $item['legend'] ?? $item['title'];
1645  $letter = $item['letter'];
1646  $cssClass = $item['class'] ?? $key;
1647 
1648  $legend .= Html::element( 'dt',
1649  [ 'class' => $cssClass ], $context->msg( $letter )->text()
1650  ) . "\n" .
1651  Html::rawElement( 'dd',
1652  [ 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ],
1653  $context->msg( $label )->parse()
1654  ) . "\n";
1655  }
1656  # (+-123)
1657  $legend .= Html::rawElement( 'dt',
1658  [ 'class' => 'mw-plusminus-pos' ],
1659  $context->msg( 'recentchanges-legend-plusminus' )->parse()
1660  ) . "\n";
1661  $legend .= Html::element(
1662  'dd',
1663  [ 'class' => 'mw-changeslist-legend-plusminus' ],
1664  $context->msg( 'recentchanges-label-plusminus' )->text()
1665  ) . "\n";
1666  $legend .= Html::closeElement( 'dl' ) . "\n";
1667 
1668  $legendHeading = $this->isStructuredFilterUiEnabled() ?
1669  $context->msg( 'rcfilters-legend-heading' )->parse() :
1670  $context->msg( 'recentchanges-legend-heading' )->parse();
1671 
1672  # Collapsible
1673  $collapsedState = $this->getRequest()->getCookie( 'changeslist-state' );
1674  $collapsedClass = $collapsedState === 'collapsed' ? ' mw-collapsed' : '';
1675 
1676  $legend =
1677  '<div class="mw-changeslist-legend mw-collapsible' . $collapsedClass . '">' .
1678  $legendHeading .
1679  '<div class="mw-collapsible-content">' . $legend . '</div>' .
1680  '</div>';
1681 
1682  return $legend;
1683  }
1684 
1688  protected function addModules() {
1689  $out = $this->getOutput();
1690  // Styles and behavior for the legend box (see makeLegend())
1691  $out->addModuleStyles( [
1692  'mediawiki.special.changeslist.legend',
1693  'mediawiki.special.changeslist',
1694  ] );
1695  $out->addModules( 'mediawiki.special.changeslist.legend.js' );
1696 
1697  if ( $this->isStructuredFilterUiEnabled() && !$this->including() ) {
1698  $out->addModules( 'mediawiki.rcfilters.filters.ui' );
1699  $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
1700  }
1701  }
1702 
1703  protected function getGroupName() {
1704  return 'changes';
1705  }
1706 
1723  public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
1724  &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
1725  ) {
1726  global $wgLearnerEdits,
1730 
1731  $LEVEL_COUNT = 5;
1732 
1733  // If all levels are selected, don't filter
1734  if ( count( $selectedExpLevels ) === $LEVEL_COUNT ) {
1735  return;
1736  }
1737 
1738  // both 'registered' and 'unregistered', experience levels, if any, are included in 'registered'
1739  if (
1740  in_array( 'registered', $selectedExpLevels ) &&
1741  in_array( 'unregistered', $selectedExpLevels )
1742  ) {
1743  return;
1744  }
1745 
1746  $actorMigration = ActorMigration::newMigration();
1747  $actorQuery = $actorMigration->getJoin( 'rc_user' );
1748  $tables += $actorQuery['tables'];
1749  $join_conds += $actorQuery['joins'];
1750 
1751  // 'registered' but not 'unregistered', experience levels, if any, are included in 'registered'
1752  if (
1753  in_array( 'registered', $selectedExpLevels ) &&
1754  !in_array( 'unregistered', $selectedExpLevels )
1755  ) {
1756  $conds[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1757  return;
1758  }
1759 
1760  if ( $selectedExpLevels === [ 'unregistered' ] ) {
1761  $conds[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1762  return;
1763  }
1764 
1765  $tables[] = 'user';
1766  $join_conds['user'] = [ 'LEFT JOIN', $actorQuery['fields']['rc_user'] . ' = user_id' ];
1767 
1768  if ( $now === 0 ) {
1769  $now = time();
1770  }
1771  $secondsPerDay = 86400;
1772  $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
1773  $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
1774 
1775  $aboveNewcomer = $dbr->makeList(
1776  [
1777  'user_editcount >= ' . intval( $wgLearnerEdits ),
1778  'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ),
1779  ],
1781  );
1782 
1783  $aboveLearner = $dbr->makeList(
1784  [
1785  'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
1786  'user_registration <= ' .
1787  $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ),
1788  ],
1790  );
1791 
1792  $conditions = [];
1793 
1794  if ( in_array( 'unregistered', $selectedExpLevels ) ) {
1795  $selectedExpLevels = array_diff( $selectedExpLevels, [ 'unregistered' ] );
1796  $conditions[] = $actorMigration->isAnon( $actorQuery['fields']['rc_user'] );
1797  }
1798 
1799  if ( $selectedExpLevels === [ 'newcomer' ] ) {
1800  $conditions[] = "NOT ( $aboveNewcomer )";
1801  } elseif ( $selectedExpLevels === [ 'learner' ] ) {
1802  $conditions[] = $dbr->makeList(
1803  [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
1805  );
1806  } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
1807  $conditions[] = $aboveLearner;
1808  } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
1809  $conditions[] = "NOT ( $aboveLearner )";
1810  } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
1811  $conditions[] = $dbr->makeList(
1812  [ "NOT ( $aboveNewcomer )", $aboveLearner ],
1814  );
1815  } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
1816  $conditions[] = $aboveNewcomer;
1817  } elseif ( $selectedExpLevels === [ 'experienced', 'learner', 'newcomer' ] ) {
1818  $conditions[] = $actorMigration->isNotAnon( $actorQuery['fields']['rc_user'] );
1819  }
1820 
1821  if ( count( $conditions ) > 1 ) {
1822  $conds[] = $dbr->makeList( $conditions, IDatabase::LIST_OR );
1823  } elseif ( count( $conditions ) === 1 ) {
1824  $conds[] = reset( $conditions );
1825  }
1826  }
1827 
1833  public function isStructuredFilterUiEnabled() {
1834  if ( $this->getRequest()->getBool( 'rcfilters' ) ) {
1835  return true;
1836  }
1837 
1838  return static::checkStructuredFilterUiEnabled(
1839  $this->getConfig(),
1840  $this->getUser()
1841  );
1842  }
1843 
1852  public static function checkStructuredFilterUiEnabled( Config $config, User $user ) {
1853  return !$user->getOption( 'rcenhancedfilters-disable' );
1854  }
1855 
1863  public function getDefaultLimit() {
1864  return $this->getUser()->getIntOption( static::$limitPreferenceName );
1865  }
1866 
1875  public function getDefaultDays() {
1876  return floatval( $this->getUser()->getOption( static::$daysPreferenceName ) );
1877  }
1878 }
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
static modifyDisplayQuery(&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='')
Applies all tags-related changes to a query.
Definition: ChangeTags.php:772
getFilterGroup( $groupName)
Gets a specified ChangesListFilterGroup by name.
Helper class to keep track of options when mixing links and form elements.
Definition: FormOptions.php:35
const RC_CATEGORIZE
Definition: Defines.php:146
static getMainWANInstance()
Get the main WAN cache object.
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:2626
const FLOAT
Float type, maps guessType() to WebRequest::getFloat()
Definition: FormOptions.php:48
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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:785
doHeader( $opts, $numRows)
Set the text to be displayed above the changes.
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1599
const SRC_CATEGORIZE
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:232
getContext()
Gets the context this SpecialPage is executed in.
webOutput( $rows, $opts)
Send output to the OutputPage object, only called if not used feeds.
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
areFiltersInConflict()
Check if filters are in conflict and guaranteed to return no results.
const TAG_DESC_CHARACTER_LIMIT
Maximum length of a tag description in UTF-8 characters.
including( $x=null)
Whether the special page is being evaluated via transclusion.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static truncateTagDescription( $tag, $length, IContextSource $context)
Get truncated message for the tag&#39;s long description.
Definition: ChangeTags.php:198
outputChangesList( $rows, $opts)
Build and output the actual changes list.
replaceOldOptions(FormOptions $opts)
Replace old options with their structured UI equivalents.
$filterGroupDefinitions
Definition information for the filters and their groups.
getChangeTagList()
Fetch the change tags list for the front end.
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
database rows
Definition: globals.txt:10
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing &#39;/&#39;...
Definition: Html.php:252
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
getOption( $oname, $defaultOverride=null, $ignoreHidden=false)
Get the user&#39;s current setting for a given option.
Definition: User.php:3183
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
outputFeedLinks()
Output feed links.
static getAssociated( $index)
Get the associated namespace.
getDefaultLimit()
Get the default value of the number of changes to display when loading the result set...
$value
static string $daysPreferenceName
Preference name for &#39;days&#39;.
reset( $name)
Delete the option value.
static string $limitPreferenceName
Preference name for &#39;limit&#39;.
registerFiltersFromDefinitions(array $definition)
Register filters from a definition object.
wfLogWarning( $msg, $callerOffset=1, $level=E_USER_WARNING)
Send a warning as a PHP error and the debug log.
static listExplicitlyDefinedTags()
Lists tags explicitly defined in the change_tag_def table of the database.
getOutput()
Get the OutputPage being used for this instance.
setTopText(FormOptions $opts)
Send the text to be displayed before the options.
static string $savedQueriesPreferenceName
Preference name for saved queries.
getOptions()
Get the current FormOptions for this request.
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:990
validateIntBounds( $name, $min, $max)
static checkStructuredFilterUiEnabled(Config $config, User $user)
Static method to check whether StructuredFilter UI is enabled for the given user. ...
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2221
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:1994
$batch
Definition: linkcache.txt:23
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
Definition: User.php:47
wfArrayToCgi( $array1, $array2=null, $prefix='')
This function takes one or two arrays as input, and returns a CGI-style string, e.g.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const PRC_PATROLLED
Class for fixing stale WANObjectCache keys using a purge event source.
execute( $subpage)
Main execution point.
static stripAllTags( $html)
Take a fragment of (potentially invalid) HTML and return a version with any tags removed, encoded as plain text.
Definition: Sanitizer.php:2000
__construct( $name, $restriction)
transformFilterDefinition(array $filterDefinition)
Transforms filter definition to prepare it for constructor.
static newMigration()
Static constructor.
Interface for configuration instances.
Definition: Config.php:28
const LIST_AND
Definition: Defines.php:43
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
$wgExperiencedUserEdits
Name of the external diff engine to use.
fixBackwardsCompatibilityOptions(FormOptions $opts)
Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards compatibility.
includeRcFiltersApp()
Include the modules and configuration for the RCFilters app.
Represents a filter group (used on ChangesListSpecialPage and descendants)
validateBounds( $name, $min, $max)
Constrain a numeric value for a given option to a given range.
static decode( $value, $assoc=false)
Decodes a JSON string.
Definition: FormatJson.php:174
static listSoftwareActivatedTags()
Lists those tags which core or extensions report as being "active".
getDefaultOptions()
Get a FormOptions object containing the default options.
webOutputHeader( $rowCount, $opts)
Send header output to the OutputPage object, only called if not using feeds.
$cache
Definition: mcc.php:33
static logException( $e, $catcher=self::CAUGHT_BY_OTHER)
Log an exception to the exception log (if enabled).
$params
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:310
getDB()
Return a IDatabase object for reading.
doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.
array $wgLearnerEdits
The following variables define 3 user experience levels:
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
static tagDescription( $tag, IContextSource $context)
Get a short description for a tag.
Definition: ChangeTags.php:148
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:936
static escapeClass( $class)
Given a value, escape it so that it can be used as a CSS class and return it.
Definition: Sanitizer.php:1418
static string $collapsedPreferenceName
Preference name for collapsing the active filter display.
$filter
setBottomText(FormOptions $opts)
Send the text to be displayed after the options.
$wgExperiencedUserMemberSince
Name of the external diff engine to use.
static newFromRow( $row)
Handy shortcut for constructing a formatter directly from database row.
filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr, &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now=0)
Filter on users&#39; experience levels; this will not be called if nothing is selected.
namespace and then decline to actually register it & $namespaces
Definition: hooks.txt:936
Represents a filter group with multiple string options.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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:785
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$wgLearnerMemberSince
Name of the external diff engine to use.
const INT
Integer type, maps guessType() to WebRequest::getInt()
Definition: FormOptions.php:45
const LIST_OR
Definition: Defines.php:46
const PRC_UNPATROLLED
$filterGroups
Filter groups, and their contained filters This is an associative array (with group name as key) of C...
validateOptions(FormOptions $opts)
Validate a FormOptions object generated by getDefaultOptions() with values already populated...
registerFilterGroup(ChangesListFilterGroup $group)
Register a structured changes list filter group.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
outputNoResults()
Add the "no results" message to the output.
Represents a hide-based boolean filter (used on ChangesListSpecialPage and descendants) ...
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
getRows()
Get the database result for this special page instance.
convertParamsForLink( $params)
Convert parameters values from true/false to 1/0 so they are not omitted by wfArrayToCgi() T38524...
isStructuredFilterUiEnabled()
Check whether the structured filter UI is enabled.
getName()
Get the name of this Special Page.
const NONE
Signifies that no options in the group are selected, meaning the group has no effect.
Special page which uses a ChangesList to show query results.
getStructuredFilterJsData()
Gets structured filter information needed by JS.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
Overloads the relevant methods of the real ResultsWrapper so it doesn&#39;t go anywhere near an actual da...
getUser()
Shortcut to get the User executing this instance.
const STRING
String type, maps guessType() to WebRequest::getText()
Definition: FormOptions.php:43
getConfig()
Shortcut to get main config object.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
getExtraOptions( $opts)
Get options to be displayed in a form.
msg( $key)
Wrapper around wfMessage that sets the current context.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2626
buildQuery(&$tables, &$fields, &$conds, &$query_options, &$join_conds, FormOptions $opts)
Sets appropriate tables, fields, conditions, etc.
considerActionsForDefaultSavedQuery( $subpage)
Check whether or not the page should load defaults, and if so, whether a default saved query is relev...
MediaWiki Logger LoggerFactory implements a PSR [0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
Definition: logger.txt:5
Error thrown when a query times out.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new recentchanges object...
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:276
$messages
const RC_NEW
Definition: Defines.php:143
getChangedValues()
Return options modified as an array ( name => value )
const DB_REPLICA
Definition: defines.php:25
getFilterGroups()
Gets the currently registered filters groups.
getRequest()
Get the WebRequest being used for this instance.
registerFilters()
Register all filters and their groups (including those from hooks), plus handle conflicts and default...
fixContradictoryOptions(FormOptions $opts)
Fix invalid options by resetting pairs that should never appear together.
makeLegend()
Return the legend displayed within the fieldset.
getDefaultDays()
Get the default value of the number of days to display when loading the result set.
If the group is active, any unchecked filters will translate to hide parameters in the URL...
const PRC_AUTOPATROLLED
const NS_USER_TALK
Definition: Defines.php:67
setup( $parameters)
Register all the filters, including legacy hook-driven ones.
outputTimeout()
Add the "timeout" message to the output.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getPageTitle( $subpage=false)
Get a self-referential title object.
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1487
const RC_EDIT
Definition: Defines.php:142
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
addModules()
Add page-specific modules.
const RC_LOG
Definition: Defines.php:144
fetchOptionsFromRequest( $opts)
Fetch values for a FormOptions object from the WebRequest associated with this instance.