API: Log all deprecated parameter uses to api-feature-usage.log
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 3 Nov 2015 17:18:29 +0000 (12:18 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 3 Nov 2015 17:23:00 +0000 (12:23 -0500)
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

17 files changed:
includes/api/ApiBase.php
includes/api/ApiDelete.php
includes/api/ApiEditPage.php
includes/api/ApiExpandTemplates.php
includes/api/ApiMove.php
includes/api/ApiParamInfo.php
includes/api/ApiParse.php
includes/api/ApiProtect.php
includes/api/ApiQueryCategoryMembers.php
includes/api/ApiQueryIWLinks.php
includes/api/ApiQueryLangLinks.php
includes/api/ApiQueryRandom.php
includes/api/ApiQueryRevisionsBase.php
includes/api/ApiQueryStashImageInfo.php
includes/api/ApiQueryUserContributions.php
includes/api/ApiUpload.php
includes/api/ApiWatch.php

index 1465543..4f9a94d 100644 (file)
@@ -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." );
                        // 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 ) );
                        }
                } elseif ( $required ) {
                        $this->dieUsageMsg( array( 'missingparam', $paramName ) );
index bfd841f..edcee86 100644 (file)
@@ -88,10 +88,8 @@ class ApiDelete extends ApiBase {
 
                // Deprecated parameters
                if ( $params['watch'] ) {
 
                // Deprecated parameters
                if ( $params['watch'] ) {
-                       $this->logFeatureUsage( 'action=delete&watch' );
                        $watch = 'watch';
                } elseif ( $params['unwatch'] ) {
                        $watch = 'watch';
                } elseif ( $params['unwatch'] ) {
-                       $this->logFeatureUsage( 'action=delete&unwatch' );
                        $watch = 'unwatch';
                } else {
                        $watch = $params['watchlist'];
                        $watch = 'unwatch';
                } else {
                        $watch = $params['watchlist'];
index 2f1c01c..90d976a 100644 (file)
@@ -349,10 +349,8 @@ class ApiEditPage extends ApiBase {
 
                // Deprecated parameters
                if ( $params['watch'] ) {
 
                // Deprecated parameters
                if ( $params['watch'] ) {
-                       $this->logFeatureUsage( 'action=edit&watch' );
                        $watch = true;
                } elseif ( $params['unwatch'] ) {
                        $watch = true;
                } elseif ( $params['unwatch'] ) {
-                       $this->logFeatureUsage( 'action=edit&unwatch' );
                        $watch = false;
                }
 
                        $watch = false;
                }
 
index 6112534..8a63070 100644 (file)
@@ -80,10 +80,6 @@ class ApiExpandTemplates extends ApiBase {
                $retval = array();
 
                if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
                $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' ) ) ) {
                        $wgParser->startExternalParse( $title_obj, $options, Parser::OT_PREPROCESS );
                        $dom = $wgParser->preprocessToDom( $params['text'] );
                        if ( is_callable( array( $dom, 'saveXML' ) ) ) {
index 60fd426..c38457e 100644 (file)
@@ -130,10 +130,8 @@ class ApiMove extends ApiBase {
                        $watch = $params['watchlist'];
                } elseif ( $params['watch'] ) {
                        $watch = 'watch';
                        $watch = $params['watchlist'];
                } elseif ( $params['watch'] ) {
                        $watch = 'watch';
-                       $this->logFeatureUsage( 'action=move&watch' );
                } elseif ( $params['unwatch'] ) {
                        $watch = 'unwatch';
                } elseif ( $params['unwatch'] ) {
                        $watch = 'unwatch';
-                       $this->logFeatureUsage( 'action=move&unwatch' );
                }
 
                // Watch pages
                }
 
                // Watch pages
index 2ab37ad..a9ddc6b 100644 (file)
@@ -52,7 +52,6 @@ class ApiParamInfo extends ApiBase {
                }
 
                if ( is_array( $params['querymodules'] ) ) {
                }
 
                if ( is_array( $params['querymodules'] ) ) {
-                       $this->logFeatureUsage( 'action=paraminfo&querymodules' );
                        $queryModules = $params['querymodules'];
                        foreach ( $queryModules as $m ) {
                                $modules[] = 'query+' . $m;
                        $queryModules = $params['querymodules'];
                        foreach ( $queryModules as $m ) {
                                $modules[] = 'query+' . $m;
@@ -62,7 +61,6 @@ class ApiParamInfo extends ApiBase {
                }
 
                if ( is_array( $params['formatmodules'] ) ) {
                }
 
                if ( is_array( $params['formatmodules'] ) ) {
-                       $this->logFeatureUsage( 'action=paraminfo&formatmodules' );
                        $formatModules = $params['formatmodules'];
                        foreach ( $formatModules as $m ) {
                                $modules[] = $m;
                        $formatModules = $params['formatmodules'];
                        foreach ( $formatModules as $m ) {
                                $modules[] = $m;
@@ -109,12 +107,10 @@ class ApiParamInfo extends ApiBase {
                }
 
                if ( $params['mainmodule'] ) {
                }
 
                if ( $params['mainmodule'] ) {
-                       $this->logFeatureUsage( 'action=paraminfo&mainmodule' );
                        $res['mainmodule'] = $this->getModuleInfo( $this->getMain() );
                }
 
                if ( $params['pagesetmodule'] ) {
                        $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'] );
                        $pageSet = new ApiPageSet( $this->getMain()->getModuleManager()->getModule( 'query' ) );
                        $res['pagesetmodule'] = $this->getModuleInfo( $pageSet );
                        unset( $res['pagesetmodule']['name'] );
index fcab9be..1b2efa5 100644 (file)
@@ -427,9 +427,6 @@ class ApiParse extends ApiBase {
                }
 
                if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
                }
 
                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" );
                        }
                        if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) {
                                $this->dieUsage( "parsetree is only supported for wikitext content", "notwikitext" );
                        }
index c07aaca..22bd29c 100644 (file)
@@ -101,9 +101,6 @@ class ApiProtect extends ApiBase {
 
                $cascade = $params['cascade'];
 
 
                $cascade = $params['cascade'];
 
-               if ( $params['watch'] ) {
-                       $this->logFeatureUsage( 'action=protect&watch' );
-               }
                $watch = $params['watch'] ? 'watch' : $params['watchlist'];
                $this->setWatch( $watch, $titleObj, 'watchdefault' );
 
                $watch = $params['watch'] ? 'watch' : $params['watchlist'];
                $this->setWatch( $watch, $titleObj, 'watchdefault' );
 
index 6dcfe0e..af40423 100644 (file)
@@ -158,9 +158,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                                        }
                                        $startsortkey = pack( 'H*', $params['starthexsortkey'] );
                                } else {
                                        }
                                        $startsortkey = pack( 'H*', $params['starthexsortkey'] );
                                } else {
-                                       if ( $params['startsortkey'] !== null ) {
-                                               $this->logFeatureUsage( 'list=categorymembers&cmstartsortkey' );
-                                       }
                                        $startsortkey = $params['startsortkey'];
                                }
                                if ( $params['endsortkeyprefix'] !== null ) {
                                        $startsortkey = $params['startsortkey'];
                                }
                                if ( $params['endsortkeyprefix'] !== null ) {
@@ -171,9 +168,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                                        }
                                        $endsortkey = pack( 'H*', $params['endhexsortkey'] );
                                } else {
                                        }
                                        $endsortkey = pack( 'H*', $params['endhexsortkey'] );
                                } else {
-                                       if ( $params['endsortkey'] !== null ) {
-                                               $this->logFeatureUsage( 'list=categorymembers&cmendsortkey' );
-                                       }
                                        $endsortkey = $params['endsortkey'];
                                }
 
                                        $endsortkey = $params['endsortkey'];
                                }
 
index 82619cc..7123138 100644 (file)
@@ -51,7 +51,6 @@ class ApiQueryIWLinks extends ApiQueryBase {
                // Handle deprecated param
                $this->requireMaxOneParameter( $params, 'url', 'prop' );
                if ( $params['url'] ) {
                // Handle deprecated param
                $this->requireMaxOneParameter( $params, 'url', 'prop' );
                if ( $params['url'] ) {
-                       $this->logFeatureUsage( 'prop=iwlinks&iwurl' );
                        $prop = array( 'url' => 1 );
                }
 
                        $prop = array( 'url' => 1 );
                }
 
index 899a382..f964c7a 100644 (file)
@@ -50,7 +50,6 @@ class ApiQueryLangLinks extends ApiQueryBase {
                // Handle deprecated param
                $this->requireMaxOneParameter( $params, 'url', 'prop' );
                if ( $params['url'] ) {
                // Handle deprecated param
                $this->requireMaxOneParameter( $params, 'url', 'prop' );
                if ( $params['url'] ) {
-                       $this->logFeatureUsage( 'prop=langlinks&llurl' );
                        $prop = array( 'url' => 1 );
                }
 
                        $prop = array( 'url' => 1 );
                }
 
index e553d12..c7dbfb8 100644 (file)
@@ -130,10 +130,6 @@ class ApiQueryRandom extends ApiQueryGeneratorBase {
                        $this->requireMaxOneParameter( $params, 'filterredir', 'redirect' );
                }
 
                        $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 );
                if ( isset( $params['continue'] ) ) {
                        $cont = explode( '|', $params['continue'] );
                        $this->dieContinueUsageIf( count( $cont ) != 4 );
index ebc5c2e..0c5d5f3 100644 (file)
@@ -276,9 +276,6 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                        }
                }
                if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
                        }
                }
                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
                        if ( $content ) {
                                if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
                                        $t = $content->getNativeData(); # note: don't set $text
index 0a75961..229e158 100644 (file)
@@ -47,7 +47,6 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
 
                // Alias sessionkey to filekey, but give an existing filekey precedence.
                if ( !$params['filekey'] && $params['sessionkey'] ) {
 
                // Alias sessionkey to filekey, but give an existing filekey precedence.
                if ( !$params['filekey'] && $params['sessionkey'] ) {
-                       $this->logFeatureUsage( 'prop=stashimageinfo&siisessionkey' );
                        $params['filekey'] = $params['sessionkey'];
                }
 
                        $params['filekey'] = $params['sessionkey'];
                }
 
index e303094..1ef0f35 100644 (file)
@@ -224,7 +224,6 @@ class ApiQueryContributions extends ApiQueryBase {
 
                $show = $this->params['show'];
                if ( $this->params['toponly'] ) { // deprecated/old param
 
                $show = $this->params['show'];
                if ( $this->params['toponly'] ) { // deprecated/old param
-                       $this->logFeatureUsage( 'list=usercontribs&uctoponly' );
                        $show[] = 'top';
                }
                if ( !is_null( $show ) ) {
                        $show[] = 'top';
                }
                if ( !is_null( $show ) ) {
index 5e13e98..5f34701 100644 (file)
@@ -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'] ) {
 
                // 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'];
                }
 
                        $this->mParams['filekey'] = $this->mParams['sessionkey'];
                }
 
@@ -730,7 +729,6 @@ class ApiUpload extends ApiBase {
 
                // Deprecated parameters
                if ( $this->mParams['watch'] ) {
 
                // Deprecated parameters
                if ( $this->mParams['watch'] ) {
-                       $this->logFeatureUsage( 'action=upload&watch' );
                        $watch = true;
                }
 
                        $watch = true;
                }
 
index 85d051d..9eb5f2a 100644 (file)
@@ -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'] ) );
                        $title = Title::newFromText( $params['title'] );
                        if ( !$title || !$title->isWatchable() ) {
                                $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );