3 * Implements Special:Recentchanges
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
24 use MediaWiki\MediaWikiServices
;
27 * A special page that lists last changes made to the wiki
29 * @ingroup SpecialPage
31 class SpecialRecentChanges
extends ChangesListSpecialPage
{
32 // @codingStandardsIgnoreStart Needed "useless" override to change parameters.
33 public function __construct( $name = 'Recentchanges', $restriction = '' ) {
34 parent
::__construct( $name, $restriction );
36 // @codingStandardsIgnoreEnd
39 * Main execution point
41 * @param string $subpage
43 public function execute( $subpage ) {
44 // Backwards-compatibility: redirect to new feed URLs
45 $feedFormat = $this->getRequest()->getVal( 'feed' );
46 if ( !$this->including() && $feedFormat ) {
47 $query = $this->getFeedQuery();
48 $query['feedformat'] = $feedFormat === 'atom' ?
'atom' : 'rss';
49 $this->getOutput()->redirect( wfAppendQuery( wfScript( 'api' ), $query ) );
54 // 10 seconds server-side caching max
55 $this->getOutput()->setCdnMaxage( 10 );
56 // Check if the client has a cached version
57 $lastmod = $this->checkLastModified();
58 if ( $lastmod === false ) {
63 '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Recent_changes',
66 parent
::execute( $subpage );
70 * Get a FormOptions object containing the default options
74 public function getDefaultOptions() {
75 $opts = parent
::getDefaultOptions();
76 $user = $this->getUser();
78 $opts->add( 'days', $user->getIntOption( 'rcdays' ) );
79 $opts->add( 'limit', $user->getIntOption( 'rclimit' ) );
80 $opts->add( 'from', '' );
82 $opts->add( 'hideminor', $user->getBoolOption( 'hideminor' ) );
83 $opts->add( 'hidebots', true );
84 $opts->add( 'hideanons', false );
85 $opts->add( 'hideliu', false );
86 $opts->add( 'hidepatrolled', $user->getBoolOption( 'hidepatrolled' ) );
87 $opts->add( 'hidemyself', false );
88 $opts->add( 'hidecategorization', $user->getBoolOption( 'hidecategorization' ) );
90 $opts->add( 'categories', '' );
91 $opts->add( 'categories_any', false );
92 $opts->add( 'tagfilter', '' );
94 $opts->add( 'userExpLevel', 'all' );
100 * Get all custom filters
102 * @return array Map of filter URL param names to properties (msg/default)
104 protected function getCustomFilters() {
105 if ( $this->customFilters
=== null ) {
106 $this->customFilters
= parent
::getCustomFilters();
107 Hooks
::run( 'SpecialRecentChangesFilters', [ $this, &$this->customFilters
], '1.23' );
110 return $this->customFilters
;
114 * Process $par and put options found in $opts. Used when including the page.
117 * @param FormOptions $opts
119 public function parseParameters( $par, FormOptions
$opts ) {
120 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
121 foreach ( $bits as $bit ) {
122 if ( 'hidebots' === $bit ) {
123 $opts['hidebots'] = true;
125 if ( 'bots' === $bit ) {
126 $opts['hidebots'] = false;
128 if ( 'hideminor' === $bit ) {
129 $opts['hideminor'] = true;
131 if ( 'minor' === $bit ) {
132 $opts['hideminor'] = false;
134 if ( 'hideliu' === $bit ) {
135 $opts['hideliu'] = true;
137 if ( 'hidepatrolled' === $bit ) {
138 $opts['hidepatrolled'] = true;
140 if ( 'hideanons' === $bit ) {
141 $opts['hideanons'] = true;
143 if ( 'hidemyself' === $bit ) {
144 $opts['hidemyself'] = true;
146 if ( 'hidecategorization' === $bit ) {
147 $opts['hidecategorization'] = true;
150 if ( is_numeric( $bit ) ) {
151 $opts['limit'] = $bit;
155 if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
156 $opts['limit'] = $m[1];
158 if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
159 $opts['days'] = $m[1];
161 if ( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
162 $opts['namespace'] = $m[1];
164 if ( preg_match( '/^tagfilter=(.*)$/', $bit, $m ) ) {
165 $opts['tagfilter'] = $m[1];
170 public function validateOptions( FormOptions
$opts ) {
171 $opts->validateIntBounds( 'limit', 0, 5000 );
172 parent
::validateOptions( $opts );
176 * Return an array of conditions depending of options set in $opts
178 * @param FormOptions $opts
181 public function buildMainQueryConds( FormOptions
$opts ) {
182 $dbr = $this->getDB();
183 $conds = parent
::buildMainQueryConds( $opts );
186 $cutoff_unixtime = time() - ( $opts['days'] * 86400 );
187 $cutoff_unixtime = $cutoff_unixtime - ( $cutoff_unixtime %
86400 );
188 $cutoff = $dbr->timestamp( $cutoff_unixtime );
190 $fromValid = preg_match( '/^[0-9]{14}$/', $opts['from'] );
191 if ( $fromValid && $opts['from'] > wfTimestamp( TS_MW
, $cutoff ) ) {
192 $cutoff = $dbr->timestamp( $opts['from'] );
194 $opts->reset( 'from' );
197 $conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
205 * @param array $conds
206 * @param FormOptions $opts
207 * @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
209 public function doMainQuery( $conds, $opts ) {
210 $dbr = $this->getDB();
211 $user = $this->getUser();
213 $tables = [ 'recentchanges' ];
214 $fields = RecentChange
::selectFields();
218 // JOIN on watchlist for users
219 if ( $user->getId() && $user->isAllowed( 'viewmywatchlist' ) ) {
220 $tables[] = 'watchlist';
221 $fields[] = 'wl_user';
222 $fields[] = 'wl_notificationtimestamp';
223 $join_conds['watchlist'] = [ 'LEFT JOIN', [
224 'wl_user' => $user->getId(),
226 'wl_namespace=rc_namespace'
230 if ( $user->isAllowed( 'rollback' ) ) {
232 $fields[] = 'page_latest';
233 $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
236 ChangeTags
::modifyDisplayQuery(
245 $this->filterOnUserExperienceLevel( $tables, $conds, $join_conds, $opts );
247 if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
253 // array_merge() is used intentionally here so that hooks can, should
254 // they so desire, override the ORDER BY / LIMIT condition(s); prior to
255 // MediaWiki 1.26 this used to use the plus operator instead, which meant
256 // that extensions weren't able to change these conditions
257 $query_options = array_merge( [
258 'ORDER BY' => 'rc_timestamp DESC',
259 'LIMIT' => $opts['limit'] ], $query_options );
260 $rows = $dbr->select(
263 // rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
264 // knowledge to use an index merge if it wants (it may use some other index though).
265 $conds +
[ 'rc_new' => [ 0, 1 ] ],
271 // Build the final data
272 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
273 $this->filterByCategories( $rows, $opts );
279 protected function runMainQueryHook( &$tables, &$fields, &$conds,
280 &$query_options, &$join_conds, $opts
282 return parent
::runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts )
284 'SpecialRecentChangesQuery',
285 [ &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ],
290 protected function getDB() {
291 return wfGetDB( DB_REPLICA
, 'recentchanges' );
294 public function outputFeedLinks() {
295 $this->addFeedLinks( $this->getFeedQuery() );
299 * Get URL query parameters for action=feedrecentchanges API feed of current recent changes view.
303 protected function getFeedQuery() {
304 $query = array_filter( $this->getOptions()->getAllValues(), function ( $value ) {
305 // API handles empty parameters in a different way
306 return $value !== '';
308 $query['action'] = 'feedrecentchanges';
309 $feedLimit = $this->getConfig()->get( 'FeedLimit' );
310 if ( $query['limit'] > $feedLimit ) {
311 $query['limit'] = $feedLimit;
318 * Build and output the actual changes list.
320 * @param ResultWrapper $rows Database rows
321 * @param FormOptions $opts
323 public function outputChangesList( $rows, $opts ) {
324 $limit = $opts['limit'];
326 $showWatcherCount = $this->getConfig()->get( 'RCShowWatchingUsers' )
327 && $this->getUser()->getOption( 'shownumberswatching' );
330 $dbr = $this->getDB();
333 $list = ChangesList
::newFromContext( $this->getContext() );
334 $list->initChangesListRows( $rows );
336 $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
337 $rclistOutput = $list->beginRecentChangesList();
338 foreach ( $rows as $obj ) {
342 $rc = RecentChange
::newFromRow( $obj );
344 # Skip CatWatch entries for hidden cats based on user preference
346 $rc->getAttribute( 'rc_type' ) == RC_CATEGORIZE
&&
347 !$userShowHiddenCats &&
348 $rc->getParam( 'hidden-cat' )
353 $rc->counter
= $counter++
;
354 # Check if the page has been updated since the last visit
355 if ( $this->getConfig()->get( 'ShowUpdatedMarker' )
356 && !empty( $obj->wl_notificationtimestamp
)
358 $rc->notificationtimestamp
= ( $obj->rc_timestamp
>= $obj->wl_notificationtimestamp
);
360 $rc->notificationtimestamp
= false; // Default
362 # Check the number of users watching the page
363 $rc->numberofWatchingusers
= 0; // Default
364 if ( $showWatcherCount && $obj->rc_namespace
>= 0 ) {
365 if ( !isset( $watcherCache[$obj->rc_namespace
][$obj->rc_title
] ) ) {
366 $watcherCache[$obj->rc_namespace
][$obj->rc_title
] =
367 MediaWikiServices
::getInstance()->getWatchedItemStore()->countWatchers(
368 new TitleValue( (int)$obj->rc_namespace
, $obj->rc_title
)
371 $rc->numberofWatchingusers
= $watcherCache[$obj->rc_namespace
][$obj->rc_title
];
374 $changeLine = $list->recentChangesLine( $rc, !empty( $obj->wl_user
), $counter );
375 if ( $changeLine !== false ) {
376 $rclistOutput .= $changeLine;
380 $rclistOutput .= $list->endRecentChangesList();
382 if ( $rows->numRows() === 0 ) {
383 $this->getOutput()->addHTML(
384 '<div class="mw-changeslist-empty">' .
385 $this->msg( 'recentchanges-noresult' )->parse() .
388 if ( !$this->including() ) {
389 $this->getOutput()->setStatusCode( 404 );
392 $this->getOutput()->addHTML( $rclistOutput );
397 * Set the text to be displayed above the changes
399 * @param FormOptions $opts
400 * @param int $numRows Number of rows in the result to show after this header
402 public function doHeader( $opts, $numRows ) {
403 $this->setTopText( $opts );
405 $defaults = $opts->getAllValues();
406 $nondefaults = $opts->getChangedValues();
409 $panel[] = $this->makeLegend();
410 $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows );
413 $extraOpts = $this->getExtraOptions( $opts );
414 $extraOptsCount = count( $extraOpts );
416 $submit = ' ' . Xml
::submitButton( $this->msg( 'recentchanges-submit' )->text() );
418 $out = Xml
::openElement( 'table', [ 'class' => 'mw-recentchanges-table' ] );
419 foreach ( $extraOpts as $name => $optionRow ) {
420 # Add submit button to the last row only
422 $addSubmit = ( $count === $extraOptsCount ) ?
$submit : '';
424 $out .= Xml
::openElement( 'tr' );
425 if ( is_array( $optionRow ) ) {
428 [ 'class' => 'mw-label mw-' . $name . '-label' ],
433 [ 'class' => 'mw-input' ],
434 $optionRow[1] . $addSubmit
439 [ 'class' => 'mw-input', 'colspan' => 2 ],
440 $optionRow . $addSubmit
443 $out .= Xml
::closeElement( 'tr' );
445 $out .= Xml
::closeElement( 'table' );
447 $unconsumed = $opts->getUnconsumedValues();
448 foreach ( $unconsumed as $key => $value ) {
449 $out .= Html
::hidden( $key, $value );
452 $t = $this->getPageTitle();
453 $out .= Html
::hidden( 'title', $t->getPrefixedText() );
454 $form = Xml
::tags( 'form', [ 'action' => wfScript() ], $out );
456 $panelString = implode( "\n", $panel );
458 // Insert a placeholder for RCFilters
459 if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
460 $this->getOutput()->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
461 $this->getOutput()->addHTML(
464 [ 'class' => 'rcfilters-container' ]
469 $this->getOutput()->addHTML(
471 $this->msg( 'recentchanges-legend' )->text(),
473 [ 'class' => 'rcoptions' ]
477 $this->setBottomText( $opts );
481 * Send the text to be displayed above the options
483 * @param FormOptions $opts Unused
485 function setTopText( FormOptions
$opts ) {
488 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
489 if ( !$message->isDisabled() ) {
490 $this->getOutput()->addWikiText(
491 Html
::rawElement( 'div',
492 [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
493 "\n" . $message->plain() . "\n"
495 /* $lineStart */ true,
496 /* $interface */ false
502 * Get options to be displayed in a form
504 * @param FormOptions $opts
507 function getExtraOptions( $opts ) {
508 $opts->consumeValues( [
509 'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
513 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
515 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
516 $extraOpts['category'] = $this->categoryFilterForm( $opts );
519 $tagFilter = ChangeTags
::buildTagFilterSelector(
520 $opts['tagfilter'], false, $this->getContext() );
521 if ( count( $tagFilter ) ) {
522 $extraOpts['tagfilter'] = $tagFilter;
525 // Don't fire the hook for subclasses. (Or should we?)
526 if ( $this->getName() === 'Recentchanges' ) {
527 Hooks
::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
534 * Add page-specific modules.
536 protected function addModules() {
537 parent
::addModules();
538 $out = $this->getOutput();
539 $out->addModules( 'mediawiki.special.recentchanges' );
540 if ( $this->getUser()->getOption(
543 /*ignoreHidden=*/ true
546 $out->addModules( 'mediawiki.rcfilters.filters.ui' );
551 * Get last modified date, for client caching
552 * Don't use this if we are using the patrol feature, patrol changes don't
553 * update the timestamp
555 * @return string|bool
557 public function checkLastModified() {
558 $dbr = $this->getDB();
559 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__
);
565 * Creates the choose namespace selection
567 * @param FormOptions $opts
570 protected function namespaceFilterForm( FormOptions
$opts ) {
571 $nsSelect = Html
::namespaceSelector(
572 [ 'selected' => $opts['namespace'], 'all' => '' ],
573 [ 'name' => 'namespace', 'id' => 'namespace' ]
575 $nsLabel = Xml
::label( $this->msg( 'namespace' )->text(), 'namespace' );
576 $invert = Xml
::checkLabel(
577 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
579 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
581 $associated = Xml
::checkLabel(
582 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
584 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
587 return [ $nsLabel, "$nsSelect $invert $associated" ];
591 * Create an input to filter changes by categories
593 * @param FormOptions $opts
596 protected function categoryFilterForm( FormOptions
$opts ) {
597 list( $label, $input ) = Xml
::inputLabelSep( $this->msg( 'rc_categories' )->text(),
598 'categories', 'mw-categories', false, $opts['categories'] );
600 $input .= ' ' . Xml
::checkLabel( $this->msg( 'rc_categories_any' )->text(),
601 'categories_any', 'mw-categories_any', $opts['categories_any'] );
603 return [ $label, $input ];
607 * Filter $rows by categories set in $opts
609 * @param ResultWrapper $rows Database rows
610 * @param FormOptions $opts
612 function filterByCategories( &$rows, FormOptions
$opts ) {
613 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
615 if ( !count( $categories ) ) {
621 foreach ( $categories as $cat ) {
633 foreach ( $rows as $k => $r ) {
634 $nt = Title
::makeTitle( $r->rc_namespace
, $r->rc_title
);
635 $id = $nt->getArticleID();
637 continue; # Page might have been deleted...
639 if ( !in_array( $id, $articles ) ) {
642 if ( !isset( $a2r[$id] ) ) {
650 if ( !count( $articles ) ||
!count( $cats ) ) {
655 $catFind = new CategoryFinder
;
656 $catFind->seed( $articles, $cats, $opts['categories_any'] ?
'OR' : 'AND' );
657 $match = $catFind->run();
661 foreach ( $match as $id ) {
662 foreach ( $a2r[$id] as $rev ) {
664 $newrows[$k] = $rowsarr[$k];
671 * Makes change an option link which carries all the other options
673 * @param string $title Title
674 * @param array $override Options to override
675 * @param array $options Current options
676 * @param bool $active Whether to show the link in bold
679 function makeOptionsLink( $title, $override, $options, $active = false ) {
680 $params = $override +
$options;
682 // T38524: false values have be converted to "0" otherwise
683 // wfArrayToCgi() will omit it them.
684 foreach ( $params as &$value ) {
685 if ( $value === false ) {
692 $title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
695 return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [], $params );
699 * Creates the options panel.
701 * @param array $defaults
702 * @param array $nondefaults
703 * @param int $numRows Number of rows in the result to show after this header
706 function optionsPanel( $defaults, $nondefaults, $numRows ) {
707 $options = $nondefaults +
$defaults;
710 $msg = $this->msg( 'rclegend' );
711 if ( !$msg->isDisabled() ) {
712 $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
715 $lang = $this->getLanguage();
716 $user = $this->getUser();
717 $config = $this->getConfig();
718 if ( $options['from'] ) {
719 $note .= $this->msg( 'rcnotefrom' )
720 ->numParams( $options['limit'] )
722 $lang->userTimeAndDate( $options['from'], $user ),
723 $lang->userDate( $options['from'], $user ),
724 $lang->userTime( $options['from'], $user )
726 ->numParams( $numRows )
727 ->parse() . '<br />';
730 # Sort data for display and make sure it's unique after we've added user data.
731 $linkLimits = $config->get( 'RCLinkLimits' );
732 $linkLimits[] = $options['limit'];
734 $linkLimits = array_unique( $linkLimits );
736 $linkDays = $config->get( 'RCLinkDays' );
737 $linkDays[] = $options['days'];
739 $linkDays = array_unique( $linkDays );
743 foreach ( $linkLimits as $value ) {
744 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
745 [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
747 $cl = $lang->pipeList( $cl );
749 // day links, reset 'from' to none
751 foreach ( $linkDays as $value ) {
752 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
753 [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
755 $dl = $lang->pipeList( $dl );
759 'hideminor' => 'rcshowhideminor',
760 'hidebots' => 'rcshowhidebots',
761 'hideanons' => 'rcshowhideanons',
762 'hideliu' => 'rcshowhideliu',
763 'hidepatrolled' => 'rcshowhidepatr',
764 'hidemyself' => 'rcshowhidemine'
767 if ( $config->get( 'RCWatchCategoryMembership' ) ) {
768 $filters['hidecategorization'] = 'rcshowhidecategorization';
771 $showhide = [ 'show', 'hide' ];
773 foreach ( $this->getRenderableCustomFilters( $this->getCustomFilters() ) as $key => $params ) {
774 $filters[$key] = $params['msg'];
777 // Disable some if needed
778 if ( !$user->useRCPatrol() ) {
779 unset( $filters['hidepatrolled'] );
783 foreach ( $filters as $key => $msg ) {
784 // The following messages are used here:
785 // rcshowhideminor-show, rcshowhideminor-hide, rcshowhidebots-show, rcshowhidebots-hide,
786 // rcshowhideanons-show, rcshowhideanons-hide, rcshowhideliu-show, rcshowhideliu-hide,
787 // rcshowhidepatr-show, rcshowhidepatr-hide, rcshowhidemine-show, rcshowhidemine-hide,
788 // rcshowhidecategorization-show, rcshowhidecategorization-hide.
789 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
790 // Extensions can define additional filters, but don't need to define the corresponding
791 // messages. If they don't exist, just fall back to 'show' and 'hide'.
792 if ( !$linkMessage->exists() ) {
793 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
796 $link = $this->makeOptionsLink( $linkMessage->text(),
797 [ $key => 1 - $options[$key] ], $nondefaults );
798 $links[] = "<span class=\"$msg rcshowhideoption\">"
799 . $this->msg( $msg )->rawParams( $link )->escaped() . '</span>';
802 // show from this onward link
803 $timestamp = wfTimestampNow();
804 $now = $lang->userTimeAndDate( $timestamp, $user );
805 $timenow = $lang->userTime( $timestamp, $user );
806 $datenow = $lang->userDate( $timestamp, $user );
807 $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
809 $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, $pipedLinks )
810 ->parse() . '</span>';
812 $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
813 $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
814 [ 'from' => $timestamp ],
818 return "{$note}$rclinks<br />$rclistfrom";
821 public function isIncludable() {
825 protected function getCacheTTL() {
829 function filterOnUserExperienceLevel( &$tables, &$conds, &$join_conds, $opts ) {
830 global $wgLearnerEdits,
831 $wgExperiencedUserEdits,
832 $wgLearnerMemberSince,
833 $wgExperiencedUserMemberSince;
835 $selectedExpLevels = explode( ',', strtolower( $opts['userExpLevel'] ) );
836 // remove values that are not recognized
837 $selectedExpLevels = array_intersect(
839 [ 'newcomer', 'learner', 'experienced' ]
841 sort( $selectedExpLevels );
843 if ( $selectedExpLevels ) {
845 $join_conds['user'] = [ 'LEFT JOIN', 'rc_user = user_id' ];
848 $secondsPerDay = 86400;
849 $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
850 $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
852 $aboveNewcomer = $this->getDB()->makeList(
854 'user_editcount >= ' . intval( $wgLearnerEdits ),
855 'user_registration <= ' . $this->getDB()->timestamp( $learnerCutoff ),
860 $aboveLearner = $this->getDB()->makeList(
862 'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
863 'user_registration <= ' . $this->getDB()->timestamp( $experiencedUserCutoff ),
868 if ( $selectedExpLevels === [ 'newcomer' ] ) {
869 $conds[] = "NOT ( $aboveNewcomer )";
870 } elseif ( $selectedExpLevels === [ 'learner' ] ) {
871 $conds[] = $this->getDB()->makeList(
872 [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
875 } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
876 $conds[] = $aboveLearner;
877 } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
878 $conds[] = "NOT ( $aboveLearner )";
879 } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
880 $conds[] = $this->getDB()->makeList(
881 [ "NOT ( $aboveNewcomer )", $aboveLearner ],
884 } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
885 $conds[] = $aboveNewcomer;