From 0ccc69201277c2796db8762ee9099cd0506e6006 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 5 Mar 2019 17:43:16 -0500 Subject: [PATCH] API: Avoid duplicate logs to api-feature-usage It can wind up logging deprecations twice if extractRequestParams() is called with different values for 'parseLimit', for example. Change-Id: I921777089fb8cfb4339af6fd08ee3475ed31b7f6 --- includes/api/ApiBase.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 2ec4570069..9b3d11664d 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -2225,6 +2225,15 @@ abstract class ApiBase extends ContextSource { * @param string $feature Feature being used. */ public function logFeatureUsage( $feature ) { + static $loggedFeatures = []; + + // Only log each feature once per request. We can get multiple calls from calls to + // extractRequestParams() with different values for 'parseLimit', for example. + if ( isset( $loggedFeatures[$feature] ) ) { + return; + } + $loggedFeatures[$feature] = true; + $request = $this->getRequest(); $ctx = [ 'feature' => $feature, -- 2.20.1