From: Matthias Mullie Date: Tue, 7 Mar 2017 15:34:43 +0000 (+0100) Subject: Allow filtering on newbies in Special:NewFiles X-Git-Tag: 1.31.0-rc.0~2967^2 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=15dabe6941a1ebe1f0475b656773feae84bb0236;p=lhc%2Fweb%2Fwiklou.git Allow filtering on newbies in Special:NewFiles Bug: T122354 Change-Id: I4b659a78e70a5102bc8592816160df888e9fc439 --- diff --git a/includes/specials/SpecialNewimages.php b/includes/specials/SpecialNewimages.php index 583d4f9e7c..bc4eed7bdc 100644 --- a/includes/specials/SpecialNewimages.php +++ b/includes/specials/SpecialNewimages.php @@ -42,6 +42,7 @@ class SpecialNewFiles extends IncludableSpecialPage { $opts->add( 'like', '' ); $opts->add( 'user', '' ); $opts->add( 'showbots', false ); + $opts->add( 'newbies', false ); $opts->add( 'hidepatrolled', false ); $opts->add( 'limit', 50 ); $opts->add( 'offset', '' ); @@ -98,6 +99,12 @@ class SpecialNewFiles extends IncludableSpecialPage { 'name' => 'user', ], + 'newbies' => [ + 'type' => 'check', + 'label-message' => 'newimages-newbies', + 'name' => 'newbies', + ], + 'showbots' => [ 'type' => 'check', 'label-message' => 'newimages-showbots', diff --git a/includes/specials/pagers/NewFilesPager.php b/includes/specials/pagers/NewFilesPager.php index cce0323198..07e99514aa 100644 --- a/includes/specials/pagers/NewFilesPager.php +++ b/includes/specials/pagers/NewFilesPager.php @@ -74,6 +74,20 @@ class NewFilesPager extends RangeChronologicalPager { } } + if ( $opts->getValue( 'newbies' ) ) { + // newbie = most recent 1% of users + $dbr = wfGetDB( DB_REPLICA ); + $max = $dbr->selectField( 'user', 'max(user_id)', false, __METHOD__ ); + $conds[] = 'img_user >' . (int)( $max - $max / 100 ); + + // there's no point in looking for new user activity in a far past; + // beyond a certain point, we'd just end up scanning the rest of the + // table even though the users we're looking for didn't yet exist... + // see T140537, (for ContribsPages, but similar to this) + $conds[] = 'img_timestamp > ' . + $dbr->addQuotes( $dbr->timestamp( wfTimestamp() - 30 * 24 * 60 * 60 ) ); + } + if ( !$opts->getValue( 'showbots' ) ) { $groupsWithBotPermission = User::getGroupsWithPermission( 'bot' ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 9fe0e3cfc5..86478e8ecb 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -3042,6 +3042,7 @@ "newimages-legend": "Filter", "newimages-label": "Filename (or a part of it):", "newimages-user": "IP address or username", + "newimages-newbies": "Show contributions of new accounts only", "newimages-showbots": "Show uploads by bots", "newimages-hidepatrolled": "Hide patrolled uploads", "noimages": "Nothing to see.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 4d46e6fb2c..f48dfe3873 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -3232,6 +3232,7 @@ "newimages-legend": "Caption of the fieldset for the filter on [[Special:NewImages]]\n\n{{Identical|Filter}}", "newimages-label": "Caption of the filter editbox on [[Special:NewImages]]", "newimages-user": "Caption of the username/IP address editbox on [[Special:NewImages]]", + "newimages-newbies": "Used as label for a checkbox. When checked, [[Special:NewImages]] will only display uploads by new users.", "newimages-showbots": "Used as label for a checkbox. When checked, [[Special:NewImages]] will also display uploads by users in the bots group.", "newimages-hidepatrolled": "Used as label for a checkbox. When checked, [[Special:NewImages]] will not display patrolled uploads.\n\nCf. {{msg-mw|tog-hidepatrolled}} and {{msg-mw|apihelp-feedrecentchanges-param-hidepatrolled}}.", "noimages": "This is shown on the special page [[Special:NewImages]], when there aren't any recently uploaded files.",