3 * Special page which uses a ChangesList to show query results.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
23 use MediaWiki\Logger\LoggerFactory
;
24 use Wikimedia\Rdbms\ResultWrapper
;
25 use Wikimedia\Rdbms\FakeResultWrapper
;
26 use Wikimedia\Rdbms\IDatabase
;
29 * Special page which uses a ChangesList to show query results.
30 * @todo Way too many public functions, most of them should be protected
32 * @ingroup SpecialPage
34 abstract class ChangesListSpecialPage
extends SpecialPage
{
36 * Preference name for saved queries. Subclasses that use saved queries should override this.
39 protected static $savedQueriesPreferenceName;
44 /** @var FormOptions */
48 protected $customFilters;
50 // Order of both groups and filters is significant; first is top-most priority,
51 // descending from there.
52 // 'showHideSuffix' is a shortcut to and avoid spelling out
53 // details specific to subclasses here.
55 * Definition information for the filters and their groups
57 * The value is $groupDefinition, a parameter to the ChangesListFilterGroup constructor.
58 * However, priority is dynamically added for the core groups, to ease maintenance.
60 * Groups are displayed to the user in the structured UI. However, if necessary,
61 * all of the filters in a group can be configured to only display on the
62 * unstuctured UI, in which case you don't need a group title. This is done in
63 * getFilterGroupDefinitionFromLegacyCustomFilters, for example.
65 * @var array $filterGroupDefinitions
67 private $filterGroupDefinitions;
69 // Same format as filterGroupDefinitions, but for a single group (reviewStatus)
70 // that is registered conditionally.
71 private $reviewStatusFilterGroupDefinition;
73 // Single filter registered conditionally
74 private $hideCategorizationFilterDefinition;
77 * Filter groups, and their contained filters
78 * This is an associative array (with group name as key) of ChangesListFilterGroup objects.
80 * @var array $filterGroups
82 protected $filterGroups = [];
84 public function __construct( $name, $restriction ) {
85 parent
::__construct( $name, $restriction );
87 $nonRevisionTypes = [ RC_LOG
];
88 Hooks
::run( 'SpecialWatchlistGetNonRevisionTypes', [ &$nonRevisionTypes ] );
90 $this->filterGroupDefinitions
= [
92 'name' => 'registration',
93 'title' => 'rcfilters-filtergroup-registration',
94 'class' => ChangesListBooleanFilterGroup
::class,
98 // rcshowhideliu-show, rcshowhideliu-hide,
100 'showHideSuffix' => 'showhideliu',
102 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
103 &$query_options, &$join_conds
105 $conds[] = 'rc_user = 0';
107 'isReplacedInStructuredUi' => true,
111 'name' => 'hideanons',
112 // rcshowhideanons-show, rcshowhideanons-hide,
114 'showHideSuffix' => 'showhideanons',
116 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
117 &$query_options, &$join_conds
119 $conds[] = 'rc_user != 0';
121 'isReplacedInStructuredUi' => true,
127 'name' => 'userExpLevel',
128 'title' => 'rcfilters-filtergroup-userExpLevel',
129 'class' => ChangesListStringOptionsFilterGroup
::class,
130 'isFullCoverage' => true,
133 'name' => 'unregistered',
134 'label' => 'rcfilters-filter-user-experience-level-unregistered-label',
135 'description' => 'rcfilters-filter-user-experience-level-unregistered-description',
136 'cssClassSuffix' => 'user-unregistered',
137 'isRowApplicableCallable' => function ( $ctx, $rc ) {
138 return !$rc->getAttribute( 'rc_user' );
142 'name' => 'registered',
143 'label' => 'rcfilters-filter-user-experience-level-registered-label',
144 'description' => 'rcfilters-filter-user-experience-level-registered-description',
145 'cssClassSuffix' => 'user-registered',
146 'isRowApplicableCallable' => function ( $ctx, $rc ) {
147 return $rc->getAttribute( 'rc_user' );
151 'name' => 'newcomer',
152 'label' => 'rcfilters-filter-user-experience-level-newcomer-label',
153 'description' => 'rcfilters-filter-user-experience-level-newcomer-description',
154 'cssClassSuffix' => 'user-newcomer',
155 'isRowApplicableCallable' => function ( $ctx, $rc ) {
156 $performer = $rc->getPerformer();
157 return $performer && $performer->isLoggedIn() &&
158 $performer->getExperienceLevel() === 'newcomer';
163 'label' => 'rcfilters-filter-user-experience-level-learner-label',
164 'description' => 'rcfilters-filter-user-experience-level-learner-description',
165 'cssClassSuffix' => 'user-learner',
166 'isRowApplicableCallable' => function ( $ctx, $rc ) {
167 $performer = $rc->getPerformer();
168 return $performer && $performer->isLoggedIn() &&
169 $performer->getExperienceLevel() === 'learner';
173 'name' => 'experienced',
174 'label' => 'rcfilters-filter-user-experience-level-experienced-label',
175 'description' => 'rcfilters-filter-user-experience-level-experienced-description',
176 'cssClassSuffix' => 'user-experienced',
177 'isRowApplicableCallable' => function ( $ctx, $rc ) {
178 $performer = $rc->getPerformer();
179 return $performer && $performer->isLoggedIn() &&
180 $performer->getExperienceLevel() === 'experienced';
184 'default' => ChangesListStringOptionsFilterGroup
::NONE
,
185 'queryCallable' => [ $this, 'filterOnUserExperienceLevel' ],
189 'name' => 'authorship',
190 'title' => 'rcfilters-filtergroup-authorship',
191 'class' => ChangesListBooleanFilterGroup
::class,
194 'name' => 'hidemyself',
195 'label' => 'rcfilters-filter-editsbyself-label',
196 'description' => 'rcfilters-filter-editsbyself-description',
197 // rcshowhidemine-show, rcshowhidemine-hide,
199 'showHideSuffix' => 'showhidemine',
201 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
202 &$query_options, &$join_conds
204 $user = $ctx->getUser();
205 $conds[] = 'rc_user_text != ' . $dbr->addQuotes( $user->getName() );
207 'cssClassSuffix' => 'self',
208 'isRowApplicableCallable' => function ( $ctx, $rc ) {
209 return $ctx->getUser()->equals( $rc->getPerformer() );
213 'name' => 'hidebyothers',
214 'label' => 'rcfilters-filter-editsbyother-label',
215 'description' => 'rcfilters-filter-editsbyother-description',
217 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
218 &$query_options, &$join_conds
220 $user = $ctx->getUser();
221 $conds[] = 'rc_user_text = ' . $dbr->addQuotes( $user->getName() );
223 'cssClassSuffix' => 'others',
224 'isRowApplicableCallable' => function ( $ctx, $rc ) {
225 return !$ctx->getUser()->equals( $rc->getPerformer() );
232 'name' => 'automated',
233 'title' => 'rcfilters-filtergroup-automated',
234 'class' => ChangesListBooleanFilterGroup
::class,
237 'name' => 'hidebots',
238 'label' => 'rcfilters-filter-bots-label',
239 'description' => 'rcfilters-filter-bots-description',
240 // rcshowhidebots-show, rcshowhidebots-hide,
242 'showHideSuffix' => 'showhidebots',
244 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
245 &$query_options, &$join_conds
247 $conds[] = 'rc_bot = 0';
249 'cssClassSuffix' => 'bot',
250 'isRowApplicableCallable' => function ( $ctx, $rc ) {
251 return $rc->getAttribute( 'rc_bot' );
255 'name' => 'hidehumans',
256 'label' => 'rcfilters-filter-humans-label',
257 'description' => 'rcfilters-filter-humans-description',
259 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
260 &$query_options, &$join_conds
262 $conds[] = 'rc_bot = 1';
264 'cssClassSuffix' => 'human',
265 'isRowApplicableCallable' => function ( $ctx, $rc ) {
266 return !$rc->getAttribute( 'rc_bot' );
272 // reviewStatus (conditional)
275 'name' => 'significance',
276 'title' => 'rcfilters-filtergroup-significance',
277 'class' => ChangesListBooleanFilterGroup
::class,
281 'name' => 'hideminor',
282 'label' => 'rcfilters-filter-minor-label',
283 'description' => 'rcfilters-filter-minor-description',
284 // rcshowhideminor-show, rcshowhideminor-hide,
286 'showHideSuffix' => 'showhideminor',
288 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
289 &$query_options, &$join_conds
291 $conds[] = 'rc_minor = 0';
293 'cssClassSuffix' => 'minor',
294 'isRowApplicableCallable' => function ( $ctx, $rc ) {
295 return $rc->getAttribute( 'rc_minor' );
299 'name' => 'hidemajor',
300 'label' => 'rcfilters-filter-major-label',
301 'description' => 'rcfilters-filter-major-description',
303 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
304 &$query_options, &$join_conds
306 $conds[] = 'rc_minor = 1';
308 'cssClassSuffix' => 'major',
309 'isRowApplicableCallable' => function ( $ctx, $rc ) {
310 return !$rc->getAttribute( 'rc_minor' );
317 'name' => 'lastRevision',
318 'title' => 'rcfilters-filtergroup-lastRevision',
319 'class' => ChangesListBooleanFilterGroup
::class,
323 'name' => 'hidelastrevision',
324 'label' => 'rcfilters-filter-lastrevision-label',
325 'description' => 'rcfilters-filter-lastrevision-description',
327 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
328 &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
329 $conds[] = $dbr->makeList(
331 'rc_this_oldid <> page_latest',
332 'rc_type' => $nonRevisionTypes,
337 'cssClassSuffix' => 'last',
338 'isRowApplicableCallable' => function ( $ctx, $rc ) {
339 return $rc->getAttribute( 'rc_this_oldid' ) === $rc->getAttribute( 'page_latest' );
343 'name' => 'hidepreviousrevisions',
344 'label' => 'rcfilters-filter-previousrevision-label',
345 'description' => 'rcfilters-filter-previousrevision-description',
347 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
348 &$query_options, &$join_conds ) use ( $nonRevisionTypes ) {
349 $conds[] = $dbr->makeList(
351 'rc_this_oldid = page_latest',
352 'rc_type' => $nonRevisionTypes,
357 'cssClassSuffix' => 'previous',
358 'isRowApplicableCallable' => function ( $ctx, $rc ) {
359 return $rc->getAttribute( 'rc_this_oldid' ) !== $rc->getAttribute( 'page_latest' );
365 // With extensions, there can be change types that will not be hidden by any of these.
367 'name' => 'changeType',
368 'title' => 'rcfilters-filtergroup-changetype',
369 'class' => ChangesListBooleanFilterGroup
::class,
373 'name' => 'hidepageedits',
374 'label' => 'rcfilters-filter-pageedits-label',
375 'description' => 'rcfilters-filter-pageedits-description',
378 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
379 &$query_options, &$join_conds
381 $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_EDIT
);
383 'cssClassSuffix' => 'src-mw-edit',
384 'isRowApplicableCallable' => function ( $ctx, $rc ) {
385 return $rc->getAttribute( 'rc_source' ) === RecentChange
::SRC_EDIT
;
389 'name' => 'hidenewpages',
390 'label' => 'rcfilters-filter-newpages-label',
391 'description' => 'rcfilters-filter-newpages-description',
394 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
395 &$query_options, &$join_conds
397 $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_NEW
);
399 'cssClassSuffix' => 'src-mw-new',
400 'isRowApplicableCallable' => function ( $ctx, $rc ) {
401 return $rc->getAttribute( 'rc_source' ) === RecentChange
::SRC_NEW
;
405 // hidecategorization
409 'label' => 'rcfilters-filter-logactions-label',
410 'description' => 'rcfilters-filter-logactions-description',
413 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
414 &$query_options, &$join_conds
416 $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_LOG
);
418 'cssClassSuffix' => 'src-mw-log',
419 'isRowApplicableCallable' => function ( $ctx, $rc ) {
420 return $rc->getAttribute( 'rc_source' ) === RecentChange
::SRC_LOG
;
428 $this->reviewStatusFilterGroupDefinition
= [
430 'name' => 'reviewStatus',
431 'title' => 'rcfilters-filtergroup-reviewstatus',
432 'class' => ChangesListBooleanFilterGroup
::class,
436 'name' => 'hidepatrolled',
437 'label' => 'rcfilters-filter-patrolled-label',
438 'description' => 'rcfilters-filter-patrolled-description',
439 // rcshowhidepatr-show, rcshowhidepatr-hide
441 'showHideSuffix' => 'showhidepatr',
443 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
444 &$query_options, &$join_conds
446 $conds[] = 'rc_patrolled = 0';
448 'cssClassSuffix' => 'patrolled',
449 'isRowApplicableCallable' => function ( $ctx, $rc ) {
450 return $rc->getAttribute( 'rc_patrolled' );
454 'name' => 'hideunpatrolled',
455 'label' => 'rcfilters-filter-unpatrolled-label',
456 'description' => 'rcfilters-filter-unpatrolled-description',
458 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
459 &$query_options, &$join_conds
461 $conds[] = 'rc_patrolled = 1';
463 'cssClassSuffix' => 'unpatrolled',
464 'isRowApplicableCallable' => function ( $ctx, $rc ) {
465 return !$rc->getAttribute( 'rc_patrolled' );
472 $this->hideCategorizationFilterDefinition
= [
473 'name' => 'hidecategorization',
474 'label' => 'rcfilters-filter-categorization-label',
475 'description' => 'rcfilters-filter-categorization-description',
476 // rcshowhidecategorization-show, rcshowhidecategorization-hide.
477 // wlshowhidecategorization
478 'showHideSuffix' => 'showhidecategorization',
481 'queryCallable' => function ( $specialClassName, $ctx, $dbr, &$tables, &$fields, &$conds,
482 &$query_options, &$join_conds
484 $conds[] = 'rc_type != ' . $dbr->addQuotes( RC_CATEGORIZE
);
486 'cssClassSuffix' => 'src-mw-categorize',
487 'isRowApplicableCallable' => function ( $ctx, $rc ) {
488 return $rc->getAttribute( 'rc_source' ) === RecentChange
::SRC_CATEGORIZE
;
494 * Check if filters are in conflict and guaranteed to return no results.
498 protected function areFiltersInConflict() {
499 $opts = $this->getOptions();
500 /** @var ChangesListFilterGroup $group */
501 foreach ( $this->getFilterGroups() as $group ) {
502 if ( $group->getConflictingGroups() ) {
505 " specifies conflicts with other groups but these are not supported yet."
509 /** @var ChangesListFilter $conflictingFilter */
510 foreach ( $group->getConflictingFilters() as $conflictingFilter ) {
511 if ( $conflictingFilter->activelyInConflictWithGroup( $group, $opts ) ) {
516 /** @var ChangesListFilter $filter */
517 foreach ( $group->getFilters() as $filter ) {
518 /** @var ChangesListFilter $conflictingFilter */
519 foreach ( $filter->getConflictingFilters() as $conflictingFilter ) {
521 $conflictingFilter->activelyInConflictWithFilter( $filter, $opts ) &&
522 $filter->activelyInConflictWithFilter( $conflictingFilter, $opts )
536 * Main execution point
538 * @param string $subpage
540 public function execute( $subpage ) {
541 $this->rcSubpage
= $subpage;
543 $rows = $this->getRows();
544 $opts = $this->getOptions();
545 if ( $rows === false ) {
546 $rows = new FakeResultWrapper( [] );
549 // Used by Structured UI app to get results without MW chrome
550 if ( $this->getRequest()->getVal( 'action' ) === 'render' ) {
551 $this->getOutput()->setArticleBodyOnly( true );
554 // Used by "live update" and "view newest" to check
555 // if there's new changes with minimal data transfer
556 if ( $this->getRequest()->getBool( 'peek' ) ) {
557 $code = $rows->numRows() > 0 ?
200 : 204;
558 $this->getOutput()->setStatusCode( $code );
562 $batch = new LinkBatch
;
563 foreach ( $rows as $row ) {
564 $batch->add( NS_USER
, $row->rc_user_text
);
565 $batch->add( NS_USER_TALK
, $row->rc_user_text
);
566 $batch->add( $row->rc_namespace
, $row->rc_title
);
567 if ( $row->rc_source
=== RecentChange
::SRC_LOG
) {
568 $formatter = LogFormatter
::newFromRow( $row );
569 foreach ( $formatter->getPreloadTitles() as $title ) {
570 $batch->addObj( $title );
577 $this->outputHeader();
579 $this->webOutput( $rows, $opts );
583 if ( $this->getConfig()->get( 'EnableWANCacheReaper' ) ) {
584 // Clean up any bad page entries for titles showing up in RC
585 DeferredUpdates
::addUpdate( new WANCacheReapUpdate(
587 LoggerFactory
::getInstance( 'objectcache' )
591 $this->includeRcFiltersApp();
595 * Include the modules and configuration for the RCFilters app.
596 * Conditional on the user having the feature enabled.
598 * If it is disabled, add a <body> class marking that
600 protected function includeRcFiltersApp() {
601 $out = $this->getOutput();
602 if ( $this->isStructuredFilterUiEnabled() ) {
603 $jsData = $this->getStructuredFilterJsData();
606 foreach ( $jsData['messageKeys'] as $key ) {
607 $messages[$key] = $this->msg( $key )->plain();
610 $out->addBodyClasses( 'mw-rcfilters-enabled' );
613 ResourceLoader
::makeInlineScript(
614 ResourceLoader
::makeMessageSetScript( $messages )
618 $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
620 $out->addJsConfigVars(
621 'wgRCFiltersChangeTags',
622 $this->getChangeTagList()
624 $out->addJsConfigVars(
625 'StructuredChangeFiltersDisplayConfig',
627 'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
628 'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
629 'limitDefault' => $this->getDefaultLimit(),
630 'daysArray' => $this->getConfig()->get( 'RCLinkDays' ),
631 'daysDefault' => $this->getDefaultDays(),
635 $out->addJsConfigVars(
636 'StructuredChangeFiltersLiveUpdatePollingRate',
637 $this->getConfig()->get( 'StructuredChangeFiltersLiveUpdatePollingRate' )
640 if ( static::$savedQueriesPreferenceName ) {
641 $savedQueries = FormatJson
::decode(
642 $this->getUser()->getOption( static::$savedQueriesPreferenceName )
644 if ( $savedQueries && isset( $savedQueries->default ) ) {
645 // If there is a default saved query, show a loading spinner,
646 // since the frontend is going to reload the results
647 $out->addBodyClasses( 'mw-rcfilters-ui-loading' );
649 $out->addJsConfigVars(
650 'wgStructuredChangeFiltersSavedQueriesPreferenceName',
651 static::$savedQueriesPreferenceName
655 $out->addBodyClasses( 'mw-rcfilters-disabled' );
660 * Fetch the change tags list for the front end
662 * @return Array Tag data
664 protected function getChangeTagList() {
665 $cache = ObjectCache
::getMainWANInstance();
666 $context = $this->getContext();
667 return $cache->getWithSetCallback(
668 $cache->makeKey( 'changeslistspecialpage-changetags', $context->getLanguage()->getCode() ),
669 $cache::TTL_MINUTE
* 10,
670 function () use ( $context ) {
671 $explicitlyDefinedTags = array_fill_keys( ChangeTags
::listExplicitlyDefinedTags(), 0 );
672 $softwareActivatedTags = array_fill_keys( ChangeTags
::listSoftwareActivatedTags(), 0 );
674 // Hit counts disabled for perf reasons, see T169997
676 $tagStats = ChangeTags::tagUsageStatistics();
677 $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
680 arsort( $tagHitCounts );
682 $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags );
684 // Build the list and data
686 foreach ( $tagHitCounts as $tagName => $hits ) {
688 // Only get active tags
689 isset( $explicitlyDefinedTags[ $tagName ] ) ||
690 isset( $softwareActivatedTags[ $tagName ] )
693 $desc = ChangeTags
::tagLongDescriptionMessage( $tagName, $context );
697 'label' => Sanitizer
::stripAllTags(
698 ChangeTags
::tagDescription( $tagName, $context )
700 'description' => $desc ? Sanitizer
::stripAllTags( $desc->parse() ) : '',
701 'cssClass' => Sanitizer
::escapeClass( 'mw-tag-' . $tagName ),
707 // Instead of sorting by hit count (disabled, see above), sort by display name
708 usort( $result, function ( $a, $b ) {
709 return strcasecmp( $a['label'], $b['label'] );
721 * Add the "no results" message to the output
723 protected function outputNoResults() {
724 $this->getOutput()->addHTML(
725 '<div class="mw-changeslist-empty">' .
726 $this->msg( 'recentchanges-noresult' )->parse() .
732 * Get the database result for this special page instance. Used by ApiFeedRecentChanges.
734 * @return bool|ResultWrapper Result or false
736 public function getRows() {
737 $opts = $this->getOptions();
744 $this->buildQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
746 return $this->doMainQuery( $tables, $fields, $conds, $query_options, $join_conds, $opts );
750 * Get the current FormOptions for this request
752 * @return FormOptions
754 public function getOptions() {
755 if ( $this->rcOptions
=== null ) {
756 $this->rcOptions
= $this->setup( $this->rcSubpage
);
759 return $this->rcOptions
;
763 * Register all filters and their groups (including those from hooks), plus handle
764 * conflicts and defaults.
766 * You might want to customize these in the same method, in subclasses. You can
767 * call getFilterGroup to access a group, and (on the group) getFilter to access a
768 * filter, then make necessary modfications to the filter or group (e.g. with
771 protected function registerFilters() {
772 $this->registerFiltersFromDefinitions( $this->filterGroupDefinitions
);
774 // Make sure this is not being transcluded (we don't want to show this
775 // information to all users just because the user that saves the edit can
776 // patrol or is logged in)
777 if ( !$this->including() && $this->getUser()->useRCPatrol() ) {
778 $this->registerFiltersFromDefinitions( $this->reviewStatusFilterGroupDefinition
);
781 $changeTypeGroup = $this->getFilterGroup( 'changeType' );
783 if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
784 $transformedHideCategorizationDef = $this->transformFilterDefinition(
785 $this->hideCategorizationFilterDefinition
788 $transformedHideCategorizationDef['group'] = $changeTypeGroup;
790 $hideCategorization = new ChangesListBooleanFilter(
791 $transformedHideCategorizationDef
795 Hooks
::run( 'ChangesListSpecialPageStructuredFilters', [ $this ] );
797 $unstructuredGroupDefinition =
798 $this->getFilterGroupDefinitionFromLegacyCustomFilters(
799 $this->getCustomFilters()
801 $this->registerFiltersFromDefinitions( [ $unstructuredGroupDefinition ] );
803 $userExperienceLevel = $this->getFilterGroup( 'userExpLevel' );
804 $registered = $userExperienceLevel->getFilter( 'registered' );
805 $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'newcomer' ) );
806 $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'learner' ) );
807 $registered->setAsSupersetOf( $userExperienceLevel->getFilter( 'experienced' ) );
809 $categoryFilter = $changeTypeGroup->getFilter( 'hidecategorization' );
810 $logactionsFilter = $changeTypeGroup->getFilter( 'hidelog' );
811 $pagecreationFilter = $changeTypeGroup->getFilter( 'hidenewpages' );
813 $significanceTypeGroup = $this->getFilterGroup( 'significance' );
814 $hideMinorFilter = $significanceTypeGroup->getFilter( 'hideminor' );
816 // categoryFilter is conditional; see registerFilters
817 if ( $categoryFilter !== null ) {
818 $hideMinorFilter->conflictsWith(
820 'rcfilters-hideminor-conflicts-typeofchange-global',
821 'rcfilters-hideminor-conflicts-typeofchange',
822 'rcfilters-typeofchange-conflicts-hideminor'
825 $hideMinorFilter->conflictsWith(
827 'rcfilters-hideminor-conflicts-typeofchange-global',
828 'rcfilters-hideminor-conflicts-typeofchange',
829 'rcfilters-typeofchange-conflicts-hideminor'
831 $hideMinorFilter->conflictsWith(
833 'rcfilters-hideminor-conflicts-typeofchange-global',
834 'rcfilters-hideminor-conflicts-typeofchange',
835 'rcfilters-typeofchange-conflicts-hideminor'
840 * Transforms filter definition to prepare it for constructor.
842 * See overrides of this method as well.
844 * @param array $filterDefinition Original filter definition
846 * @return array Transformed definition
848 protected function transformFilterDefinition( array $filterDefinition ) {
849 return $filterDefinition;
853 * Register filters from a definition object
855 * Array specifying groups and their filters; see Filter and
856 * ChangesListFilterGroup constructors.
858 * There is light processing to simplify core maintenance.
859 * @param array $definition
861 protected function registerFiltersFromDefinitions( array $definition ) {
862 $autoFillPriority = -1;
863 foreach ( $definition as $groupDefinition ) {
864 if ( !isset( $groupDefinition['priority'] ) ) {
865 $groupDefinition['priority'] = $autoFillPriority;
867 // If it's explicitly specified, start over the auto-fill
868 $autoFillPriority = $groupDefinition['priority'];
873 $className = $groupDefinition['class'];
874 unset( $groupDefinition['class'] );
876 foreach ( $groupDefinition['filters'] as &$filterDefinition ) {
877 $filterDefinition = $this->transformFilterDefinition( $filterDefinition );
880 $this->registerFilterGroup( new $className( $groupDefinition ) );
885 * Get filter group definition from legacy custom filters
887 * @param array $customFilters Custom filters from legacy hooks
888 * @return array Group definition
890 protected function getFilterGroupDefinitionFromLegacyCustomFilters( array $customFilters ) {
891 // Special internal unstructured group
892 $unstructuredGroupDefinition = [
893 'name' => 'unstructured',
894 'class' => ChangesListBooleanFilterGroup
::class,
895 'priority' => -1, // Won't display in structured
899 foreach ( $customFilters as $name => $params ) {
900 $unstructuredGroupDefinition['filters'][] = [
902 'showHide' => $params['msg'],
903 'default' => $params['default'],
907 return $unstructuredGroupDefinition;
911 * Register all the filters, including legacy hook-driven ones.
912 * Then create a FormOptions object with options as specified by the user
914 * @param array $parameters
916 * @return FormOptions
918 public function setup( $parameters ) {
919 $this->registerFilters();
921 $opts = $this->getDefaultOptions();
923 $opts = $this->fetchOptionsFromRequest( $opts );
925 // Give precedence to subpage syntax
926 if ( $parameters !== null ) {
927 $this->parseParameters( $parameters, $opts );
930 $this->validateOptions( $opts );
936 * Get a FormOptions object containing the default options. By default, returns
937 * some basic options. The filters listed explicitly here are overriden in this
938 * method, in subclasses, but most filters (e.g. hideminor, userExpLevel filters,
939 * and more) are structured. Structured filters are overriden in registerFilters.
942 * @return FormOptions
944 public function getDefaultOptions() {
945 $opts = new FormOptions();
946 $structuredUI = $this->isStructuredFilterUiEnabled();
947 // If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
948 $useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
951 /** @var ChangesListFilterGroup $filterGroup */
952 foreach ( $this->filterGroups
as $filterGroup ) {
953 // URL parameters can be per-group, like 'userExpLevel',
954 // or per-filter, like 'hideminor'.
955 if ( $filterGroup->isPerGroupRequestParameter() ) {
956 $opts->add( $filterGroup->getName(), $useDefaults ?
$filterGroup->getDefault() : '' );
958 /** @var ChangesListBooleanFilter $filter */
959 foreach ( $filterGroup->getFilters() as $filter ) {
960 $opts->add( $filter->getName(), $useDefaults ?
$filter->getDefault( $structuredUI ) : false );
965 $opts->add( 'namespace', '', FormOptions
::STRING );
966 $opts->add( 'invert', false );
967 $opts->add( 'associated', false );
968 $opts->add( 'urlversion', 1 );
969 $opts->add( 'tagfilter', '' );
971 $opts->add( 'days', $this->getDefaultDays(), FormOptions
::FLOAT );
972 $opts->add( 'limit', $this->getDefaultLimit(), FormOptions
::INT );
974 $opts->add( 'from', '' );
980 * Register a structured changes list filter group
982 * @param ChangesListFilterGroup $group
984 public function registerFilterGroup( ChangesListFilterGroup
$group ) {
985 $groupName = $group->getName();
987 $this->filterGroups
[$groupName] = $group;
991 * Gets the currently registered filters groups
993 * @return array Associative array of ChangesListFilterGroup objects, with group name as key
995 protected function getFilterGroups() {
996 return $this->filterGroups
;
1000 * Gets a specified ChangesListFilterGroup by name
1002 * @param string $groupName Name of group
1004 * @return ChangesListFilterGroup|null Group, or null if not registered
1006 public function getFilterGroup( $groupName ) {
1007 return isset( $this->filterGroups
[$groupName] ) ?
1008 $this->filterGroups
[$groupName] :
1012 // Currently, this intentionally only includes filters that display
1013 // in the structured UI. This can be changed easily, though, if we want
1014 // to include data on filters that use the unstructured UI. messageKeys is a
1015 // special top-level value, with the value being an array of the message keys to
1016 // send to the client.
1018 * Gets structured filter information needed by JS
1020 * @return array Associative array
1021 * * array $return['groups'] Group data
1022 * * array $return['messageKeys'] Array of message keys
1024 public function getStructuredFilterJsData() {
1027 'messageKeys' => [],
1030 usort( $this->filterGroups
, function ( $a, $b ) {
1031 return $b->getPriority() - $a->getPriority();
1034 foreach ( $this->filterGroups
as $groupName => $group ) {
1035 $groupOutput = $group->getJsData( $this );
1036 if ( $groupOutput !== null ) {
1037 $output['messageKeys'] = array_merge(
1038 $output['messageKeys'],
1039 $groupOutput['messageKeys']
1042 unset( $groupOutput['messageKeys'] );
1043 $output['groups'][] = $groupOutput;
1051 * Get custom show/hide filters using deprecated ChangesListSpecialPageFilters
1054 * @return array Map of filter URL param names to properties (msg/default)
1056 protected function getCustomFilters() {
1057 if ( $this->customFilters
=== null ) {
1058 $this->customFilters
= [];
1059 Hooks
::run( 'ChangesListSpecialPageFilters', [ $this, &$this->customFilters
], '1.29' );
1062 return $this->customFilters
;
1066 * Fetch values for a FormOptions object from the WebRequest associated with this instance.
1068 * Intended for subclassing, e.g. to add a backwards-compatibility layer.
1070 * @param FormOptions $opts
1071 * @return FormOptions
1073 protected function fetchOptionsFromRequest( $opts ) {
1074 $opts->fetchValuesFromRequest( $this->getRequest() );
1080 * Process $par and put options found in $opts. Used when including the page.
1082 * @param string $par
1083 * @param FormOptions $opts
1085 public function parseParameters( $par, FormOptions
$opts ) {
1086 $stringParameterNameSet = [];
1087 $hideParameterNameSet = [];
1089 // URL parameters can be per-group, like 'userExpLevel',
1090 // or per-filter, like 'hideminor'.
1092 foreach ( $this->filterGroups
as $filterGroup ) {
1093 if ( $filterGroup->isPerGroupRequestParameter() ) {
1094 $stringParameterNameSet[$filterGroup->getName()] = true;
1095 } elseif ( $filterGroup->getType() === ChangesListBooleanFilterGroup
::TYPE
) {
1096 foreach ( $filterGroup->getFilters() as $filter ) {
1097 $hideParameterNameSet[$filter->getName()] = true;
1102 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
1103 foreach ( $bits as $bit ) {
1105 if ( isset( $hideParameterNameSet[$bit] ) ) {
1106 // hidefoo => hidefoo=true
1108 } elseif ( isset( $hideParameterNameSet["hide$bit"] ) ) {
1109 // foo => hidefoo=false
1110 $opts["hide$bit"] = false;
1111 } elseif ( preg_match( '/^(.*)=(.*)$/', $bit, $m ) ) {
1112 if ( isset( $stringParameterNameSet[$m[1]] ) ) {
1113 $opts[$m[1]] = $m[2];
1120 * Validate a FormOptions object generated by getDefaultOptions() with values already populated.
1122 * @param FormOptions $opts
1124 public function validateOptions( FormOptions
$opts ) {
1125 if ( $this->fixContradictoryOptions( $opts ) ) {
1126 $query = wfArrayToCgi( $this->convertParamsForLink( $opts->getChangedValues() ) );
1127 $this->getOutput()->redirect( $this->getPageTitle()->getCanonicalURL( $query ) );
1130 $opts->validateIntBounds( 'limit', 0, 5000 );
1131 $opts->validateBounds( 'days', 0, $this->getConfig()->get( 'RCMaxAge' ) / ( 3600 * 24 ) );
1135 * Fix invalid options by resetting pairs that should never appear together.
1137 * @param FormOptions $opts
1138 * @return bool True if any option was reset
1140 private function fixContradictoryOptions( FormOptions
$opts ) {
1141 $fixed = $this->fixBackwardsCompatibilityOptions( $opts );
1143 foreach ( $this->filterGroups
as $filterGroup ) {
1144 if ( $filterGroup instanceof ChangesListBooleanFilterGroup
) {
1145 $filters = $filterGroup->getFilters();
1147 if ( count( $filters ) === 1 ) {
1148 // legacy boolean filters should not be considered
1152 $allInGroupEnabled = array_reduce(
1154 function ( $carry, $filter ) use ( $opts ) {
1155 return $carry && $opts[ $filter->getName() ];
1157 /* initialValue */ count( $filters ) > 0
1160 if ( $allInGroupEnabled ) {
1161 foreach ( $filters as $filter ) {
1162 $opts[ $filter->getName() ] = false;
1174 * Fix a special case (hideanons=1 and hideliu=1) in a special way, for backwards
1177 * This is deprecated and may be removed.
1179 * @param FormOptions $opts
1180 * @return bool True if this change was mode
1182 private function fixBackwardsCompatibilityOptions( FormOptions
$opts ) {
1183 if ( $opts['hideanons'] && $opts['hideliu'] ) {
1184 $opts->reset( 'hideanons' );
1185 if ( !$opts['hidebots'] ) {
1186 $opts->reset( 'hideliu' );
1187 $opts['hidehumans'] = 1;
1197 * Convert parameters values from true/false to 1/0
1198 * so they are not omitted by wfArrayToCgi()
1201 * @param array $params
1204 protected function convertParamsForLink( $params ) {
1205 foreach ( $params as &$value ) {
1206 if ( $value === false ) {
1215 * Sets appropriate tables, fields, conditions, etc. depending on which filters
1216 * the user requested.
1218 * @param array &$tables Array of tables; see IDatabase::select $table
1219 * @param array &$fields Array of fields; see IDatabase::select $vars
1220 * @param array &$conds Array of conditions; see IDatabase::select $conds
1221 * @param array &$query_options Array of query options; see IDatabase::select $options
1222 * @param array &$join_conds Array of join conditions; see IDatabase::select $join_conds
1223 * @param FormOptions $opts
1225 protected function buildQuery( &$tables, &$fields, &$conds, &$query_options,
1226 &$join_conds, FormOptions
$opts
1228 $dbr = $this->getDB();
1229 $isStructuredUI = $this->isStructuredFilterUiEnabled();
1231 foreach ( $this->filterGroups
as $filterGroup ) {
1232 // URL parameters can be per-group, like 'userExpLevel',
1233 // or per-filter, like 'hideminor'.
1234 if ( $filterGroup->isPerGroupRequestParameter() ) {
1235 $filterGroup->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1236 $query_options, $join_conds, $opts[$filterGroup->getName()] );
1238 foreach ( $filterGroup->getFilters() as $filter ) {
1239 if ( $filter->isActive( $opts, $isStructuredUI ) ) {
1240 $filter->modifyQuery( $dbr, $this, $tables, $fields, $conds,
1241 $query_options, $join_conds );
1247 // Namespace filtering
1248 if ( $opts[ 'namespace' ] !== '' ) {
1249 $namespaces = explode( ';', $opts[ 'namespace' ] );
1251 if ( $opts[ 'associated' ] ) {
1252 $associatedNamespaces = array_map(
1254 return MWNamespace
::getAssociated( $ns );
1258 $namespaces = array_unique( array_merge( $namespaces, $associatedNamespaces ) );
1261 if ( count( $namespaces ) === 1 ) {
1262 $operator = $opts[ 'invert' ] ?
'!=' : '=';
1263 $value = $dbr->addQuotes( reset( $namespaces ) );
1265 $operator = $opts[ 'invert' ] ?
'NOT IN' : 'IN';
1266 sort( $namespaces );
1267 $value = '(' . $dbr->makeList( $namespaces ) . ')';
1269 $conds[] = "rc_namespace $operator $value";
1273 $cutoff_unixtime = time() - $opts['days'] * 3600 * 24;
1274 $cutoff = $dbr->timestamp( $cutoff_unixtime );
1276 $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
1277 if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW
, $cutoff ) ) {
1278 $cutoff = $dbr->timestamp( $opts['from'] );
1280 $opts->reset( 'from' );
1283 $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
1289 * @param array $tables Array of tables; see IDatabase::select $table
1290 * @param array $fields Array of fields; see IDatabase::select $vars
1291 * @param array $conds Array of conditions; see IDatabase::select $conds
1292 * @param array $query_options Array of query options; see IDatabase::select $options
1293 * @param array $join_conds Array of join conditions; see IDatabase::select $join_conds
1294 * @param FormOptions $opts
1295 * @return bool|ResultWrapper Result or false
1297 protected function doMainQuery( $tables, $fields, $conds,
1298 $query_options, $join_conds, FormOptions
$opts
1300 $tables[] = 'recentchanges';
1301 $fields = array_merge( RecentChange
::selectFields(), $fields );
1303 ChangeTags
::modifyDisplayQuery(
1312 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
1318 $dbr = $this->getDB();
1320 return $dbr->select(
1330 protected function runMainQueryHook( &$tables, &$fields, &$conds,
1331 &$query_options, &$join_conds, $opts
1334 'ChangesListSpecialPageQuery',
1335 [ $this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ]
1340 * Return a IDatabase object for reading
1344 protected function getDB() {
1345 return wfGetDB( DB_REPLICA
);
1349 * Send output to the OutputPage object, only called if not used feeds
1351 * @param ResultWrapper $rows Database rows
1352 * @param FormOptions $opts
1354 public function webOutput( $rows, $opts ) {
1355 if ( !$this->including() ) {
1356 $this->outputFeedLinks();
1357 $this->doHeader( $opts, $rows->numRows() );
1360 $this->outputChangesList( $rows, $opts );
1364 * Output feed links.
1366 public function outputFeedLinks() {
1367 // nothing by default
1371 * Build and output the actual changes list.
1373 * @param ResultWrapper $rows Database rows
1374 * @param FormOptions $opts
1376 abstract public function outputChangesList( $rows, $opts );
1379 * Set the text to be displayed above the changes
1381 * @param FormOptions $opts
1382 * @param int $numRows Number of rows in the result to show after this header
1384 public function doHeader( $opts, $numRows ) {
1385 $this->setTopText( $opts );
1387 // @todo Lots of stuff should be done here.
1389 $this->setBottomText( $opts );
1393 * Send the text to be displayed before the options. Should use $this->getOutput()->addWikiText()
1394 * or similar methods to print the text.
1396 * @param FormOptions $opts
1398 public function setTopText( FormOptions
$opts ) {
1399 // nothing by default
1403 * Send the text to be displayed after the options. Should use $this->getOutput()->addWikiText()
1404 * or similar methods to print the text.
1406 * @param FormOptions $opts
1408 public function setBottomText( FormOptions
$opts ) {
1409 // nothing by default
1413 * Get options to be displayed in a form
1414 * @todo This should handle options returned by getDefaultOptions().
1415 * @todo Not called by anything in this class (but is in subclasses), should be
1416 * called by something… doHeader() maybe?
1418 * @param FormOptions $opts
1421 public function getExtraOptions( $opts ) {
1426 * Return the legend displayed within the fieldset
1430 public function makeLegend() {
1431 $context = $this->getContext();
1432 $user = $context->getUser();
1433 # The legend showing what the letters and stuff mean
1434 $legend = Html
::openElement( 'dl' ) . "\n";
1435 # Iterates through them and gets the messages for both letter and tooltip
1436 $legendItems = $context->getConfig()->get( 'RecentChangesFlags' );
1437 if ( !( $user->useRCPatrol() ||
$user->useNPPatrol() ) ) {
1438 unset( $legendItems['unpatrolled'] );
1440 foreach ( $legendItems as $key => $item ) { # generate items of the legend
1441 $label = isset( $item['legend'] ) ?
$item['legend'] : $item['title'];
1442 $letter = $item['letter'];
1443 $cssClass = isset( $item['class'] ) ?
$item['class'] : $key;
1445 $legend .= Html
::element( 'dt',
1446 [ 'class' => $cssClass ], $context->msg( $letter )->text()
1448 Html
::rawElement( 'dd',
1449 [ 'class' => Sanitizer
::escapeClass( 'mw-changeslist-legend-' . $key ) ],
1450 $context->msg( $label )->parse()
1454 $legend .= Html
::rawElement( 'dt',
1455 [ 'class' => 'mw-plusminus-pos' ],
1456 $context->msg( 'recentchanges-legend-plusminus' )->parse()
1458 $legend .= Html
::element(
1460 [ 'class' => 'mw-changeslist-legend-plusminus' ],
1461 $context->msg( 'recentchanges-label-plusminus' )->text()
1463 $legend .= Html
::closeElement( 'dl' ) . "\n";
1465 $legendHeading = $this->isStructuredFilterUiEnabled() ?
1466 $context->msg( 'rcfilters-legend-heading' )->parse() :
1467 $context->msg( 'recentchanges-legend-heading' )->parse();
1471 '<div class="mw-changeslist-legend">' .
1473 '<div class="mw-collapsible-content">' . $legend . '</div>' .
1480 * Add page-specific modules.
1482 protected function addModules() {
1483 $out = $this->getOutput();
1484 // Styles and behavior for the legend box (see makeLegend())
1485 $out->addModuleStyles( [
1486 'mediawiki.special.changeslist.legend',
1487 'mediawiki.special.changeslist',
1489 $out->addModules( 'mediawiki.special.changeslist.legend.js' );
1491 if ( $this->isStructuredFilterUiEnabled() ) {
1492 $out->addModules( 'mediawiki.rcfilters.filters.ui' );
1493 $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
1497 protected function getGroupName() {
1502 * Filter on users' experience levels; this will not be called if nothing is
1505 * @param string $specialPageClassName Class name of current special page
1506 * @param IContextSource $context Context, for e.g. user
1507 * @param IDatabase $dbr Database, for addQuotes, makeList, and similar
1508 * @param array &$tables Array of tables; see IDatabase::select $table
1509 * @param array &$fields Array of fields; see IDatabase::select $vars
1510 * @param array &$conds Array of conditions; see IDatabase::select $conds
1511 * @param array &$query_options Array of query options; see IDatabase::select $options
1512 * @param array &$join_conds Array of join conditions; see IDatabase::select $join_conds
1513 * @param array $selectedExpLevels The allowed active values, sorted
1514 * @param int $now Number of seconds since the UNIX epoch, or 0 if not given
1517 public function filterOnUserExperienceLevel( $specialPageClassName, $context, $dbr,
1518 &$tables, &$fields, &$conds, &$query_options, &$join_conds, $selectedExpLevels, $now = 0
1520 global $wgLearnerEdits,
1521 $wgExperiencedUserEdits,
1522 $wgLearnerMemberSince,
1523 $wgExperiencedUserMemberSince;
1527 // If all levels are selected, don't filter
1528 if ( count( $selectedExpLevels ) === $LEVEL_COUNT ) {
1532 // both 'registered' and 'unregistered', experience levels, if any, are included in 'registered'
1534 in_array( 'registered', $selectedExpLevels ) &&
1535 in_array( 'unregistered', $selectedExpLevels )
1540 // 'registered' but not 'unregistered', experience levels, if any, are included in 'registered'
1542 in_array( 'registered', $selectedExpLevels ) &&
1543 !in_array( 'unregistered', $selectedExpLevels )
1545 $conds[] = 'rc_user != 0';
1549 if ( $selectedExpLevels === [ 'unregistered' ] ) {
1550 $conds[] = 'rc_user = 0';
1555 $join_conds['user'] = [ 'LEFT JOIN', 'rc_user = user_id' ];
1560 $secondsPerDay = 86400;
1561 $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
1562 $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
1564 $aboveNewcomer = $dbr->makeList(
1566 'user_editcount >= ' . intval( $wgLearnerEdits ),
1567 'user_registration <= ' . $dbr->addQuotes( $dbr->timestamp( $learnerCutoff ) ),
1572 $aboveLearner = $dbr->makeList(
1574 'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
1575 'user_registration <= ' .
1576 $dbr->addQuotes( $dbr->timestamp( $experiencedUserCutoff ) ),
1583 if ( in_array( 'unregistered', $selectedExpLevels ) ) {
1584 $selectedExpLevels = array_diff( $selectedExpLevels, [ 'unregistered' ] );
1585 $conditions[] = 'rc_user = 0';
1588 if ( $selectedExpLevels === [ 'newcomer' ] ) {
1589 $conditions[] = "NOT ( $aboveNewcomer )";
1590 } elseif ( $selectedExpLevels === [ 'learner' ] ) {
1591 $conditions[] = $dbr->makeList(
1592 [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
1595 } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
1596 $conditions[] = $aboveLearner;
1597 } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
1598 $conditions[] = "NOT ( $aboveLearner )";
1599 } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
1600 $conditions[] = $dbr->makeList(
1601 [ "NOT ( $aboveNewcomer )", $aboveLearner ],
1604 } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
1605 $conditions[] = $aboveNewcomer;
1606 } elseif ( $selectedExpLevels === [ 'experienced', 'learner', 'newcomer' ] ) {
1607 $conditions[] = 'rc_user != 0';
1610 if ( count( $conditions ) > 1 ) {
1611 $conds[] = $dbr->makeList( $conditions, IDatabase
::LIST_OR
);
1612 } elseif ( count( $conditions ) === 1 ) {
1613 $conds[] = reset( $conditions );
1618 * Check whether the structured filter UI is enabled
1622 public function isStructuredFilterUiEnabled() {
1623 if ( $this->getRequest()->getBool( 'rcfilters' ) ) {
1627 if ( $this->getConfig()->get( 'StructuredChangeFiltersShowPreference' ) ) {
1628 return !$this->getUser()->getOption( 'rcenhancedfilters-disable' );
1630 return $this->getUser()->getOption( 'rcenhancedfilters' );
1635 * Check whether the structured filter UI is enabled by default (regardless of
1636 * this particular user's setting)
1640 public function isStructuredFilterUiEnabledByDefault() {
1641 if ( $this->getConfig()->get( 'StructuredChangeFiltersShowPreference' ) ) {
1642 return !$this->getUser()->getDefaultOption( 'rcenhancedfilters-disable' );
1644 return $this->getUser()->getDefaultOption( 'rcenhancedfilters' );
1648 abstract function getDefaultLimit();
1651 * Get the default value of the number of days to display when loading
1653 * Supports fractional values, and should be cast to a float.
1657 abstract function getDefaultDays();