Anomie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/250705

Change subject: API: Log all deprecated parameter uses to api-feature-usage.log
......................................................................

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
---
M includes/api/ApiBase.php
M includes/api/ApiDelete.php
M includes/api/ApiEditPage.php
M includes/api/ApiExpandTemplates.php
M includes/api/ApiMove.php
M includes/api/ApiParamInfo.php
M includes/api/ApiParse.php
M includes/api/ApiProtect.php
M includes/api/ApiQueryCategoryMembers.php
M includes/api/ApiQueryIWLinks.php
M includes/api/ApiQueryLangLinks.php
M includes/api/ApiQueryRandom.php
M includes/api/ApiQueryRevisionsBase.php
M includes/api/ApiQueryStashImageInfo.php
M includes/api/ApiQueryUserContributions.php
M includes/api/ApiUpload.php
M includes/api/ApiWatch.php
17 files changed, 11 insertions(+), 40 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/05/250705/1

diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 1465543..4f9a94d 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -986,6 +986,17 @@
                        // 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 bfd841f..edcee86 100644
--- a/includes/api/ApiDelete.php
+++ b/includes/api/ApiDelete.php
@@ -88,10 +88,8 @@
 
                // 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 2f1c01c..90d976a 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -349,10 +349,8 @@
 
                // 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 6112534c..8a63070 100644
--- a/includes/api/ApiExpandTemplates.php
+++ b/includes/api/ApiExpandTemplates.php
@@ -80,10 +80,6 @@
                $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 60fd426..c38457e 100644
--- a/includes/api/ApiMove.php
+++ b/includes/api/ApiMove.php
@@ -130,10 +130,8 @@
                        $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 2ab37ad..a9ddc6b 100644
--- a/includes/api/ApiParamInfo.php
+++ b/includes/api/ApiParamInfo.php
@@ -52,7 +52,6 @@
                }
 
                if ( is_array( $params['querymodules'] ) ) {
-                       $this->logFeatureUsage( 'action=paraminfo&querymodules' 
);
                        $queryModules = $params['querymodules'];
                        foreach ( $queryModules as $m ) {
                                $modules[] = 'query+' . $m;
@@ -62,7 +61,6 @@
                }
 
                if ( is_array( $params['formatmodules'] ) ) {
-                       $this->logFeatureUsage( 
'action=paraminfo&formatmodules' );
                        $formatModules = $params['formatmodules'];
                        foreach ( $formatModules as $m ) {
                                $modules[] = $m;
@@ -109,12 +107,10 @@
                }
 
                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 fcab9be..1b2efa5 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -427,9 +427,6 @@
                }
 
                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 c07aaca..22bd29c 100644
--- a/includes/api/ApiProtect.php
+++ b/includes/api/ApiProtect.php
@@ -101,9 +101,6 @@
 
                $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 6dcfe0e..af40423 100644
--- a/includes/api/ApiQueryCategoryMembers.php
+++ b/includes/api/ApiQueryCategoryMembers.php
@@ -158,9 +158,6 @@
                                        }
                                        $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 @@
                                        }
                                        $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 82619cc..7123138 100644
--- a/includes/api/ApiQueryIWLinks.php
+++ b/includes/api/ApiQueryIWLinks.php
@@ -51,7 +51,6 @@
                // 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 899a382..f964c7a 100644
--- a/includes/api/ApiQueryLangLinks.php
+++ b/includes/api/ApiQueryLangLinks.php
@@ -50,7 +50,6 @@
                // 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 e553d12..c7dbfb8 100644
--- a/includes/api/ApiQueryRandom.php
+++ b/includes/api/ApiQueryRandom.php
@@ -130,10 +130,6 @@
                        $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 ebc5c2e..0c5d5f3 100644
--- a/includes/api/ApiQueryRevisionsBase.php
+++ b/includes/api/ApiQueryRevisionsBase.php
@@ -276,9 +276,6 @@
                        }
                }
                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 0a75961..229e158 100644
--- a/includes/api/ApiQueryStashImageInfo.php
+++ b/includes/api/ApiQueryStashImageInfo.php
@@ -47,7 +47,6 @@
 
                // 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 e303094..1ef0f35 100644
--- a/includes/api/ApiQueryUserContributions.php
+++ b/includes/api/ApiQueryUserContributions.php
@@ -224,7 +224,6 @@
 
                $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 5e13e98..5f34701 100644
--- a/includes/api/ApiUpload.php
+++ b/includes/api/ApiUpload.php
@@ -53,7 +53,6 @@
 
                // 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 @@
 
                // 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 85d051d..9eb5f2a 100644
--- a/includes/api/ApiWatch.php
+++ b/includes/api/ApiWatch.php
@@ -85,7 +85,6 @@
                                );
                        }
 
-                       $this->logFeatureUsage( 'action=watch&title' );
                        $title = Title::newFromText( $params['title'] );
                        if ( !$title || !$title->isWatchable() ) {
                                $this->dieUsageMsg( array( 'invalidtitle', 
$params['title'] ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/250705
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia38aeeccd0b9857b12b28914f509284483fbcca8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to