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 $this->getOutput()->addHTML(
460 $this->msg( 'recentchanges-legend' )->text(),
462 [ 'class' => 'rcoptions' ]
466 $this->setBottomText( $opts );
470 * Send the text to be displayed above the options
472 * @param FormOptions $opts Unused
474 function setTopText( FormOptions
$opts ) {
477 $message = $this->msg( 'recentchangestext' )->inContentLanguage();
478 if ( !$message->isDisabled() ) {
479 $this->getOutput()->addWikiText(
480 Html
::rawElement( 'div',
481 [ 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ],
482 "\n" . $message->plain() . "\n"
484 /* $lineStart */ true,
485 /* $interface */ false
491 * Get options to be displayed in a form
493 * @param FormOptions $opts
496 function getExtraOptions( $opts ) {
497 $opts->consumeValues( [
498 'namespace', 'invert', 'associated', 'tagfilter', 'categories', 'categories_any'
502 $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
504 if ( $this->getConfig()->get( 'AllowCategorizedRecentChanges' ) ) {
505 $extraOpts['category'] = $this->categoryFilterForm( $opts );
508 $tagFilter = ChangeTags
::buildTagFilterSelector(
509 $opts['tagfilter'], false, $this->getContext() );
510 if ( count( $tagFilter ) ) {
511 $extraOpts['tagfilter'] = $tagFilter;
514 // Don't fire the hook for subclasses. (Or should we?)
515 if ( $this->getName() === 'Recentchanges' ) {
516 Hooks
::run( 'SpecialRecentChangesPanel', [ &$extraOpts, $opts ] );
523 * Add page-specific modules.
525 protected function addModules() {
526 parent
::addModules();
527 $out = $this->getOutput();
528 $out->addModules( 'mediawiki.special.recentchanges' );
529 if ( $this->getUser()->getOption(
532 /*ignoreHidden=*/ true
535 $out->addModules( 'mediawiki.rcfilters.filters' );
540 * Get last modified date, for client caching
541 * Don't use this if we are using the patrol feature, patrol changes don't
542 * update the timestamp
544 * @return string|bool
546 public function checkLastModified() {
547 $dbr = $this->getDB();
548 $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__
);
554 * Creates the choose namespace selection
556 * @param FormOptions $opts
559 protected function namespaceFilterForm( FormOptions
$opts ) {
560 $nsSelect = Html
::namespaceSelector(
561 [ 'selected' => $opts['namespace'], 'all' => '' ],
562 [ 'name' => 'namespace', 'id' => 'namespace' ]
564 $nsLabel = Xml
::label( $this->msg( 'namespace' )->text(), 'namespace' );
565 $invert = Xml
::checkLabel(
566 $this->msg( 'invert' )->text(), 'invert', 'nsinvert',
568 [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
570 $associated = Xml
::checkLabel(
571 $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated',
573 [ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
576 return [ $nsLabel, "$nsSelect $invert $associated" ];
580 * Create an input to filter changes by categories
582 * @param FormOptions $opts
585 protected function categoryFilterForm( FormOptions
$opts ) {
586 list( $label, $input ) = Xml
::inputLabelSep( $this->msg( 'rc_categories' )->text(),
587 'categories', 'mw-categories', false, $opts['categories'] );
589 $input .= ' ' . Xml
::checkLabel( $this->msg( 'rc_categories_any' )->text(),
590 'categories_any', 'mw-categories_any', $opts['categories_any'] );
592 return [ $label, $input ];
596 * Filter $rows by categories set in $opts
598 * @param ResultWrapper $rows Database rows
599 * @param FormOptions $opts
601 function filterByCategories( &$rows, FormOptions
$opts ) {
602 $categories = array_map( 'trim', explode( '|', $opts['categories'] ) );
604 if ( !count( $categories ) ) {
610 foreach ( $categories as $cat ) {
622 foreach ( $rows as $k => $r ) {
623 $nt = Title
::makeTitle( $r->rc_namespace
, $r->rc_title
);
624 $id = $nt->getArticleID();
626 continue; # Page might have been deleted...
628 if ( !in_array( $id, $articles ) ) {
631 if ( !isset( $a2r[$id] ) ) {
639 if ( !count( $articles ) ||
!count( $cats ) ) {
644 $catFind = new CategoryFinder
;
645 $catFind->seed( $articles, $cats, $opts['categories_any'] ?
'OR' : 'AND' );
646 $match = $catFind->run();
650 foreach ( $match as $id ) {
651 foreach ( $a2r[$id] as $rev ) {
653 $newrows[$k] = $rowsarr[$k];
660 * Makes change an option link which carries all the other options
662 * @param string $title Title
663 * @param array $override Options to override
664 * @param array $options Current options
665 * @param bool $active Whether to show the link in bold
668 function makeOptionsLink( $title, $override, $options, $active = false ) {
669 $params = $override +
$options;
671 // Bug 36524: false values have be converted to "0" otherwise
672 // wfArrayToCgi() will omit it them.
673 foreach ( $params as &$value ) {
674 if ( $value === false ) {
681 $title = new HtmlArmor( '<strong>' . htmlspecialchars( $title ) . '</strong>' );
684 return $this->getLinkRenderer()->makeKnownLink( $this->getPageTitle(), $title, [], $params );
688 * Creates the options panel.
690 * @param array $defaults
691 * @param array $nondefaults
692 * @param int $numRows Number of rows in the result to show after this header
695 function optionsPanel( $defaults, $nondefaults, $numRows ) {
696 $options = $nondefaults +
$defaults;
699 $msg = $this->msg( 'rclegend' );
700 if ( !$msg->isDisabled() ) {
701 $note .= '<div class="mw-rclegend">' . $msg->parse() . "</div>\n";
704 $lang = $this->getLanguage();
705 $user = $this->getUser();
706 $config = $this->getConfig();
707 if ( $options['from'] ) {
708 $note .= $this->msg( 'rcnotefrom' )
709 ->numParams( $options['limit'] )
711 $lang->userTimeAndDate( $options['from'], $user ),
712 $lang->userDate( $options['from'], $user ),
713 $lang->userTime( $options['from'], $user )
715 ->numParams( $numRows )
716 ->parse() . '<br />';
719 # Sort data for display and make sure it's unique after we've added user data.
720 $linkLimits = $config->get( 'RCLinkLimits' );
721 $linkLimits[] = $options['limit'];
723 $linkLimits = array_unique( $linkLimits );
725 $linkDays = $config->get( 'RCLinkDays' );
726 $linkDays[] = $options['days'];
728 $linkDays = array_unique( $linkDays );
732 foreach ( $linkLimits as $value ) {
733 $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
734 [ 'limit' => $value ], $nondefaults, $value == $options['limit'] );
736 $cl = $lang->pipeList( $cl );
738 // day links, reset 'from' to none
740 foreach ( $linkDays as $value ) {
741 $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ),
742 [ 'days' => $value, 'from' => '' ], $nondefaults, $value == $options['days'] );
744 $dl = $lang->pipeList( $dl );
748 'hideminor' => 'rcshowhideminor',
749 'hidebots' => 'rcshowhidebots',
750 'hideanons' => 'rcshowhideanons',
751 'hideliu' => 'rcshowhideliu',
752 'hidepatrolled' => 'rcshowhidepatr',
753 'hidemyself' => 'rcshowhidemine'
756 if ( $config->get( 'RCWatchCategoryMembership' ) ) {
757 $filters['hidecategorization'] = 'rcshowhidecategorization';
760 $showhide = [ 'show', 'hide' ];
762 foreach ( $this->getRenderableCustomFilters( $this->getCustomFilters() ) as $key => $params ) {
763 $filters[$key] = $params['msg'];
766 // Disable some if needed
767 if ( !$user->useRCPatrol() ) {
768 unset( $filters['hidepatrolled'] );
772 foreach ( $filters as $key => $msg ) {
773 // The following messages are used here:
774 // rcshowhideminor-show, rcshowhideminor-hide, rcshowhidebots-show, rcshowhidebots-hide,
775 // rcshowhideanons-show, rcshowhideanons-hide, rcshowhideliu-show, rcshowhideliu-hide,
776 // rcshowhidepatr-show, rcshowhidepatr-hide, rcshowhidemine-show, rcshowhidemine-hide,
777 // rcshowhidecategorization-show, rcshowhidecategorization-hide.
778 $linkMessage = $this->msg( $msg . '-' . $showhide[1 - $options[$key]] );
779 // Extensions can define additional filters, but don't need to define the corresponding
780 // messages. If they don't exist, just fall back to 'show' and 'hide'.
781 if ( !$linkMessage->exists() ) {
782 $linkMessage = $this->msg( $showhide[1 - $options[$key]] );
785 $link = $this->makeOptionsLink( $linkMessage->text(),
786 [ $key => 1 - $options[$key] ], $nondefaults );
787 $links[] = "<span class=\"$msg rcshowhideoption\">"
788 . $this->msg( $msg )->rawParams( $link )->escaped() . '</span>';
791 // show from this onward link
792 $timestamp = wfTimestampNow();
793 $now = $lang->userTimeAndDate( $timestamp, $user );
794 $timenow = $lang->userTime( $timestamp, $user );
795 $datenow = $lang->userDate( $timestamp, $user );
796 $pipedLinks = '<span class="rcshowhide">' . $lang->pipeList( $links ) . '</span>';
798 $rclinks = '<span class="rclinks">' . $this->msg( 'rclinks' )->rawParams( $cl, $dl, $pipedLinks )
799 ->parse() . '</span>';
801 $rclistfrom = '<span class="rclistfrom">' . $this->makeOptionsLink(
802 $this->msg( 'rclistfrom' )->rawParams( $now, $timenow, $datenow )->parse(),
803 [ 'from' => $timestamp ],
807 return "{$note}$rclinks<br />$rclistfrom";
810 public function isIncludable() {
814 protected function getCacheTTL() {
818 function filterOnUserExperienceLevel( &$tables, &$conds, &$join_conds, $opts ) {
819 global $wgLearnerEdits,
820 $wgExperiencedUserEdits,
821 $wgLearnerMemberSince,
822 $wgExperiencedUserMemberSince;
824 $selectedExpLevels = explode( ',', strtolower( $opts['userExpLevel'] ) );
825 // remove values that are not recognized
826 $selectedExpLevels = array_intersect(
828 [ 'newcomer', 'learner', 'experienced' ]
830 sort( $selectedExpLevels );
832 if ( $selectedExpLevels ) {
834 $join_conds['user'] = [ 'LEFT JOIN', 'rc_user = user_id' ];
837 $secondsPerDay = 86400;
838 $learnerCutoff = $now - $wgLearnerMemberSince * $secondsPerDay;
839 $experiencedUserCutoff = $now - $wgExperiencedUserMemberSince * $secondsPerDay;
841 $aboveNewcomer = $this->getDB()->makeList(
843 'user_editcount >= ' . intval( $wgLearnerEdits ),
844 'user_registration <= ' . $this->getDB()->timestamp( $learnerCutoff ),
849 $aboveLearner = $this->getDB()->makeList(
851 'user_editcount >= ' . intval( $wgExperiencedUserEdits ),
852 'user_registration <= ' . $this->getDB()->timestamp( $experiencedUserCutoff ),
857 if ( $selectedExpLevels === [ 'newcomer' ] ) {
858 $conds[] = "NOT ( $aboveNewcomer )";
859 } elseif ( $selectedExpLevels === [ 'learner' ] ) {
860 $conds[] = $this->getDB()->makeList(
861 [ $aboveNewcomer, "NOT ( $aboveLearner )" ],
864 } elseif ( $selectedExpLevels === [ 'experienced' ] ) {
865 $conds[] = $aboveLearner;
866 } elseif ( $selectedExpLevels === [ 'learner', 'newcomer' ] ) {
867 $conds[] = "NOT ( $aboveLearner )";
868 } elseif ( $selectedExpLevels === [ 'experienced', 'newcomer' ] ) {
869 $conds[] = $this->getDB()->makeList(
870 [ "NOT ( $aboveNewcomer )", $aboveLearner ],
873 } elseif ( $selectedExpLevels === [ 'experienced', 'learner' ] ) {
874 $conds[] = $aboveNewcomer;