From: Brad Jorsch Date: Tue, 3 Nov 2015 17:18:29 +0000 (-0500) Subject: API: Log all deprecated parameter uses to api-feature-usage.log X-Git-Tag: 1.31.0-rc.0~9120^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=05ff357a423ada930d059609095eac3a94b72bc1 API: Log all deprecated parameter uses to api-feature-usage.log Some were being logged, and some weren't. Let's log them all automatically when PARAM_DEPRECATED is processed, instead of requiring each module to manually log them. Bug: T117569 Change-Id: Ia38aeeccd0b9857b12b28914f509284483fbcca8 --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 1465543a48..4f9a94d49f 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -986,6 +986,17 @@ abstract class ApiBase extends ContextSource { // Set a warning if a deprecated parameter has been passed if ( $deprecated && $value !== false ) { $this->setWarning( "The $encParamName parameter has been deprecated." ); + + $feature = $encParamName; + $m = $this; + while ( !$m->isMain() ) { + $p = $m->getParent(); + $name = $m->getModuleName(); + $param = $p->encodeParamName( $p->getModuleManager()->getModuleGroup( $name ) ); + $feature = "{$param}={$name}&{$feature}"; + $m = $p; + } + $this->logFeatureUsage( $feature ); } } elseif ( $required ) { $this->dieUsageMsg( array( 'missingparam', $paramName ) ); diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index bfd841f572..edcee86238 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -88,10 +88,8 @@ class ApiDelete extends ApiBase { // Deprecated parameters if ( $params['watch'] ) { - $this->logFeatureUsage( 'action=delete&watch' ); $watch = 'watch'; } elseif ( $params['unwatch'] ) { - $this->logFeatureUsage( 'action=delete&unwatch' ); $watch = 'unwatch'; } else { $watch = $params['watchlist']; diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 2f1c01ce7d..90d976a53e 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -349,10 +349,8 @@ class ApiEditPage extends ApiBase { // Deprecated parameters if ( $params['watch'] ) { - $this->logFeatureUsage( 'action=edit&watch' ); $watch = true; } elseif ( $params['unwatch'] ) { - $this->logFeatureUsage( 'action=edit&unwatch' ); $watch = false; } diff --git a/includes/api/ApiExpandTemplates.php b/includes/api/ApiExpandTemplates.php index 6112534cf2..8a63070ce6 100644 --- a/includes/api/ApiExpandTemplates.php +++ b/includes/api/ApiExpandTemplates.php @@ -80,10 +80,6 @@ class ApiExpandTemplates extends ApiBase { $retval = array(); if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) { - if ( !isset( $prop['parsetree'] ) ) { - $this->logFeatureUsage( 'action=expandtemplates&generatexml' ); - } - $wgParser->startExternalParse( $title_obj, $options, Parser::OT_PREPROCESS ); $dom = $wgParser->preprocessToDom( $params['text'] ); if ( is_callable( array( $dom, 'saveXML' ) ) ) { diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 60fd42668a..c38457eba7 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -130,10 +130,8 @@ class ApiMove extends ApiBase { $watch = $params['watchlist']; } elseif ( $params['watch'] ) { $watch = 'watch'; - $this->logFeatureUsage( 'action=move&watch' ); } elseif ( $params['unwatch'] ) { $watch = 'unwatch'; - $this->logFeatureUsage( 'action=move&unwatch' ); } // Watch pages diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index 2ab37ad140..a9ddc6bb7f 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -52,7 +52,6 @@ class ApiParamInfo extends ApiBase { } if ( is_array( $params['querymodules'] ) ) { - $this->logFeatureUsage( 'action=paraminfo&querymodules' ); $queryModules = $params['querymodules']; foreach ( $queryModules as $m ) { $modules[] = 'query+' . $m; @@ -62,7 +61,6 @@ class ApiParamInfo extends ApiBase { } if ( is_array( $params['formatmodules'] ) ) { - $this->logFeatureUsage( 'action=paraminfo&formatmodules' ); $formatModules = $params['formatmodules']; foreach ( $formatModules as $m ) { $modules[] = $m; @@ -109,12 +107,10 @@ class ApiParamInfo extends ApiBase { } if ( $params['mainmodule'] ) { - $this->logFeatureUsage( 'action=paraminfo&mainmodule' ); $res['mainmodule'] = $this->getModuleInfo( $this->getMain() ); } if ( $params['pagesetmodule'] ) { - $this->logFeatureUsage( 'action=paraminfo&pagesetmodule' ); $pageSet = new ApiPageSet( $this->getMain()->getModuleManager()->getModule( 'query' ) ); $res['pagesetmodule'] = $this->getModuleInfo( $pageSet ); unset( $res['pagesetmodule']['name'] ); diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index fcab9be2c3..1b2efa5f02 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -427,9 +427,6 @@ class ApiParse extends ApiBase { } if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) { - if ( !isset( $prop['parsetree'] ) ) { - $this->logFeatureUsage( 'action=parse&generatexml' ); - } if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) { $this->dieUsage( "parsetree is only supported for wikitext content", "notwikitext" ); } diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index c07aaca436..22bd29cfa8 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -101,9 +101,6 @@ class ApiProtect extends ApiBase { $cascade = $params['cascade']; - if ( $params['watch'] ) { - $this->logFeatureUsage( 'action=protect&watch' ); - } $watch = $params['watch'] ? 'watch' : $params['watchlist']; $this->setWatch( $watch, $titleObj, 'watchdefault' ); diff --git a/includes/api/ApiQueryCategoryMembers.php b/includes/api/ApiQueryCategoryMembers.php index 6dcfe0eb00..af4042333e 100644 --- a/includes/api/ApiQueryCategoryMembers.php +++ b/includes/api/ApiQueryCategoryMembers.php @@ -158,9 +158,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { } $startsortkey = pack( 'H*', $params['starthexsortkey'] ); } else { - if ( $params['startsortkey'] !== null ) { - $this->logFeatureUsage( 'list=categorymembers&cmstartsortkey' ); - } $startsortkey = $params['startsortkey']; } if ( $params['endsortkeyprefix'] !== null ) { @@ -171,9 +168,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase { } $endsortkey = pack( 'H*', $params['endhexsortkey'] ); } else { - if ( $params['endsortkey'] !== null ) { - $this->logFeatureUsage( 'list=categorymembers&cmendsortkey' ); - } $endsortkey = $params['endsortkey']; } diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index 82619cc463..7123138f9f 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -51,7 +51,6 @@ class ApiQueryIWLinks extends ApiQueryBase { // Handle deprecated param $this->requireMaxOneParameter( $params, 'url', 'prop' ); if ( $params['url'] ) { - $this->logFeatureUsage( 'prop=iwlinks&iwurl' ); $prop = array( 'url' => 1 ); } diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index 899a3829bd..f964c7a3eb 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -50,7 +50,6 @@ class ApiQueryLangLinks extends ApiQueryBase { // Handle deprecated param $this->requireMaxOneParameter( $params, 'url', 'prop' ); if ( $params['url'] ) { - $this->logFeatureUsage( 'prop=langlinks&llurl' ); $prop = array( 'url' => 1 ); } diff --git a/includes/api/ApiQueryRandom.php b/includes/api/ApiQueryRandom.php index e553d12a70..c7dbfb820f 100644 --- a/includes/api/ApiQueryRandom.php +++ b/includes/api/ApiQueryRandom.php @@ -130,10 +130,6 @@ class ApiQueryRandom extends ApiQueryGeneratorBase { $this->requireMaxOneParameter( $params, 'filterredir', 'redirect' ); } - if ( $params['redirect'] ) { - $this->logFeatureUsage( "list=random&rnredirect=" ); - } - if ( isset( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); $this->dieContinueUsageIf( count( $cont ) != 4 ); diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php index ebc5c2e010..0c5d5f302d 100644 --- a/includes/api/ApiQueryRevisionsBase.php +++ b/includes/api/ApiQueryRevisionsBase.php @@ -276,9 +276,6 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { } } if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) { - if ( !$this->fld_parsetree ) { - $this->logFeatureUsage( 'action=query&prop=revisions+base&generatexml' ); - } if ( $content ) { if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) { $t = $content->getNativeData(); # note: don't set $text diff --git a/includes/api/ApiQueryStashImageInfo.php b/includes/api/ApiQueryStashImageInfo.php index 0a759616f5..229e1585aa 100644 --- a/includes/api/ApiQueryStashImageInfo.php +++ b/includes/api/ApiQueryStashImageInfo.php @@ -47,7 +47,6 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo { // Alias sessionkey to filekey, but give an existing filekey precedence. if ( !$params['filekey'] && $params['sessionkey'] ) { - $this->logFeatureUsage( 'prop=stashimageinfo&siisessionkey' ); $params['filekey'] = $params['sessionkey']; } diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index e30309444d..1ef0f35f95 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -224,7 +224,6 @@ class ApiQueryContributions extends ApiQueryBase { $show = $this->params['show']; if ( $this->params['toponly'] ) { // deprecated/old param - $this->logFeatureUsage( 'list=usercontribs&uctoponly' ); $show[] = 'top'; } if ( !is_null( $show ) ) { diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 5e13e98f11..5f347017d5 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -53,7 +53,6 @@ class ApiUpload extends ApiBase { // Copy the session key to the file key, for backward compatibility. if ( !$this->mParams['filekey'] && $this->mParams['sessionkey'] ) { - $this->logFeatureUsage( 'action=upload&sessionkey' ); $this->mParams['filekey'] = $this->mParams['sessionkey']; } @@ -730,7 +729,6 @@ class ApiUpload extends ApiBase { // Deprecated parameters if ( $this->mParams['watch'] ) { - $this->logFeatureUsage( 'action=upload&watch' ); $watch = true; } diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 85d051def5..9eb5f2a4ec 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -85,7 +85,6 @@ class ApiWatch extends ApiBase { ); } - $this->logFeatureUsage( 'action=watch&title' ); $title = Title::newFromText( $params['title'] ); if ( !$title || !$title->isWatchable() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );