From: PiRSquared17 Date: Wed, 26 Feb 2014 20:57:58 +0000 (+0000) Subject: Add option to show only creations in Special:Contribs, API X-Git-Tag: 1.31.0-rc.0~16787^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dcompta/operations/modifier.php?a=commitdiff_plain;h=2dfbd7761a1b8f293a3b6856e94217d8472a5da8;p=lhc%2Fweb%2Fwiklou.git Add option to show only creations in Special:Contribs, API * Add newOnly option to Special:Contributions * Add to i18n files * Add ucshow={new,!new,top,!top} to list=usercontribs * Deprecated 'uctoponly' in favor of ucshow=top per Anomie. * Add param 'newonly' to API action=feedcontributions * Implementation: rev_parent_id=0 Bug: 42026 Change-Id: I07d597ef378d897690097804bf7c774fdadb654c --- diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index 4f29097e19..5ac56479a0 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -109,6 +109,8 @@ production. $wgPasswordExpirationDays configuration setting. * Add new hook SendWatchlistEmailNotification, this will be used to determine whether to send a watchlist email notification. +* (bug 42026) Special:Contributions now includes an option to filter page + creations, similar to the topOnly option. === Bug fixes in 1.23 === * (bug 41759) The "updated since last visit" markers (on history pages, recent @@ -193,6 +195,9 @@ production. * Added llprop=langname and llprop=autonym for action=query&prop=langlinks. * prop=redirects is added, to return redirects to the pages in the query. * list=allredirects is added, to list all redirects pointing to a namespace. +* (bug 42026) Added ucshow={new,!new,top,!top} to list=usercontribs. + Also added newonly to action=feedcontributions. +* (bug 42026) Deprecated uctoponly in favor of ucshow=top. === Languages updated in 1.23 === diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index f90ba988e3..2cdc87585d 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -78,6 +78,7 @@ class ApiFeedContributions extends ApiBase { 'tagFilter' => $params['tagfilter'], 'deletedOnly' => $params['deletedonly'], 'topOnly' => $params['toponly'], + 'newOnly' => $params['newonly'], 'showSizeDiff' => $params['showsizediff'], ) ); @@ -186,6 +187,7 @@ class ApiFeedContributions extends ApiBase { ), 'deletedonly' => false, 'toponly' => false, + 'newonly' => false, 'showsizediff' => false, ); } @@ -200,6 +202,7 @@ class ApiFeedContributions extends ApiBase { 'tagfilter' => 'Filter contributions that have these tags', 'deletedonly' => 'Show only deleted contributions', 'toponly' => 'Only show edits that are latest revisions', + 'newonly' => 'Only show edits that are page creations', 'showsizediff' => 'Show the size difference between revisions. Disabled in Miser Mode', ); } diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index b492d9a326..9ad77d4860 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -207,10 +207,16 @@ class ApiQueryContributions extends ApiQueryBase { $this->addWhereFld( 'page_namespace', $this->params['namespace'] ); $show = $this->params['show']; + if ( $this->params['toponly'] ) { // deprecated/old param + $show[] = 'top'; + } if ( !is_null( $show ) ) { $show = array_flip( $show ); + if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) ) || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) + || ( isset( $show['top'] ) && isset( $show['!top'] ) ) + || ( isset( $show['new'] ) && isset( $show['!new'] ) ) ) { $this->dieUsageMsg( 'show' ); } @@ -219,6 +225,10 @@ class ApiQueryContributions extends ApiQueryBase { $this->addWhereIf( 'rev_minor_edit != 0', isset( $show['minor'] ) ); $this->addWhereIf( 'rc_patrolled = 0', isset( $show['!patrolled'] ) ); $this->addWhereIf( 'rc_patrolled != 0', isset( $show['patrolled'] ) ); + $this->addWhereIf( 'rev_id != page_latest', isset( $show['!top'] ) ); + $this->addWhereIf( 'rev_id = page_latest', isset( $show['top'] ) ); + $this->addWhereIf( 'rev_parent_id != 0', isset( $show['!new'] ) ); + $this->addWhereIf( 'rev_parent_id = 0', isset( $show['new'] ) ); } $this->addOption( 'LIMIT', $this->params['limit'] + 1 ); $index = array( 'revision' => 'usertext_timestamp' ); @@ -294,10 +304,6 @@ class ApiQueryContributions extends ApiQueryBase { $this->addWhereFld( 'ct_tag', $this->params['tag'] ); } - if ( $this->params['toponly'] ) { - $this->addWhere( 'rev_id = page_latest' ); - } - $this->addOption( 'USE INDEX', $index ); } @@ -477,10 +483,17 @@ class ApiQueryContributions extends ApiQueryBase { '!minor', 'patrolled', '!patrolled', + 'top', + '!top', + 'new', + '!new', ) ), 'tag' => null, - 'toponly' => false, + 'toponly' => array( + ApiBase::PARAM_DFLT => false, + ApiBase::PARAM_DEPRECATED => true, + ), ); } diff --git a/includes/specials/SpecialContributions.php b/includes/specials/SpecialContributions.php index c5948076e7..fdb781bf4a 100644 --- a/includes/specials/SpecialContributions.php +++ b/includes/specials/SpecialContributions.php @@ -74,6 +74,7 @@ class SpecialContributions extends IncludableSpecialPage { $this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) ); $this->opts['target'] = $target; $this->opts['topOnly'] = $request->getBool( 'topOnly' ); + $this->opts['newOnly'] = $request->getBool( 'newOnly' ); $nt = Title::makeTitleSafe( NS_USER, $target ); if ( !$nt ) { @@ -140,6 +141,9 @@ class SpecialContributions extends IncludableSpecialPage { if ( $this->opts['topOnly'] ) { $feedParams['toponly'] = true; } + if ( $this->opts['newOnly'] ) { + $feedParams['newonly'] = true; + } if ( $this->opts['deletedOnly'] ) { $feedParams['deletedonly'] = true; } @@ -185,6 +189,7 @@ class SpecialContributions extends IncludableSpecialPage { 'month' => $this->opts['month'], 'deletedOnly' => $this->opts['deletedOnly'], 'topOnly' => $this->opts['topOnly'], + 'newOnly' => $this->opts['newOnly'], 'nsInvert' => $this->opts['nsInvert'], 'associated' => $this->opts['associated'], ) ); @@ -404,6 +409,10 @@ class SpecialContributions extends IncludableSpecialPage { $this->opts['topOnly'] = false; } + if ( !isset( $this->opts['newOnly'] ) ) { + $this->opts['newOnly'] = false; + } + $form = Html::openElement( 'form', array( @@ -423,6 +432,7 @@ class SpecialContributions extends IncludableSpecialPage { 'year', 'month', 'topOnly', + 'newOnly', 'associated' ); @@ -555,10 +565,21 @@ class SpecialContributions extends IncludableSpecialPage { array( 'class' => 'mw-input' ) ) ); + $checkLabelNewOnly = Html::rawElement( + 'span', + array( 'style' => 'white-space: nowrap' ), + Xml::checkLabel( + $this->msg( 'sp-contributions-newonly' )->text(), + 'newOnly', + 'mw-show-new-only', + $this->opts['newOnly'], + array( 'class' => 'mw-input' ) + ) + ); $extraOptions = Html::rawElement( 'td', array( 'colspan' => 2 ), - $deletedOnlyCheck . $checkLabelTopOnly + $deletedOnlyCheck . $checkLabelTopOnly . $checkLabelNewOnly ); $dateSelectionAndSubmit = Xml::tags( 'td', array( 'colspan' => 2 ), @@ -642,6 +663,7 @@ class ContribsPager extends ReverseChronologicalPager { $this->deletedOnly = !empty( $options['deletedOnly'] ); $this->topOnly = !empty( $options['topOnly'] ); + $this->newOnly = !empty( $options['newOnly'] ); $year = isset( $options['year'] ) ? $options['year'] : false; $month = isset( $options['month'] ) ? $options['month'] : false; @@ -821,6 +843,10 @@ class ContribsPager extends ReverseChronologicalPager { $condition[] = 'rev_id = page_latest'; } + if ( $this->newOnly ) { + $condition[] = 'rev_parent_id = 0'; + } + return array( $tables, $index, $condition, $join_conds ); } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 3fffec2374..9716619829 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3266,6 +3266,7 @@ The latest block log entry is provided below for reference:', 'sp-contributions-search' => 'Search for contributions', 'sp-contributions-username' => 'IP address or username:', 'sp-contributions-toponly' => 'Only show edits that are latest revisions', +'sp-contributions-newonly' => 'Only show edits that are page creations', 'sp-contributions-submit' => 'Search', 'sp-contributions-explain' => '', # only translate this message to other languages if you have to change it 'sp-contributions-footer' => '-', # do not translate or duplicate this message to other languages diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 345bcd948a..5a4fea5484 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -6266,6 +6266,7 @@ Anon version: 'sp-contributions-username' => 'This message appears whenever someone requests [[Special:Contributions]]. {{Identical|IP address or username}}', 'sp-contributions-toponly' => '"top revision" means the "latest revision"', +'sp-contributions-newonly' => '"page creation" means the "first revision" of a page', 'sp-contributions-submit' => '{{Identical|Search}}', 'sp-contributions-explain' => '{{optional}}', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index eab6cf6766..7a9fc92174 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2241,6 +2241,7 @@ $wgMessageStructure = array( 'sp-contributions-search', 'sp-contributions-username', 'sp-contributions-toponly', + 'sp-contributions-newonly', 'sp-contributions-submit', 'sp-contributions-explain', 'sp-contributions-footer',