From 606d92191118c7439cea061406bbb97a46b5a79a Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 5 Aug 2008 16:12:52 +0000 Subject: [PATCH] * (bug 15044) Added requestid parameter to api.php to facilitate distinguishing between requests * Clean up indentation from r38566 * Use $this->mRequest rather than $wgRequest in ApiMain --- RELEASE-NOTES | 7 ++++--- includes/api/ApiMain.php | 27 +++++++++++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 268e0452cd..e9a5ee3b26 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -67,9 +67,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN This means you can use API search on Wikipedia without explicitly adding &srwhat=text to the query. * Added iiprop=bitdepth to imageinfo and aiprop=bitdepth to allimages -* API-specific permissions (such as 'writeapi' and 'apihighlimits' are now - listed on action=help - +* (bug 14713) API-specific permissions (such as 'writeapi' and 'apihighlimits' + are now listed on action=help +* (bug 15044) Added requestid parameter to api.php to facilitate distinguishing + between requests === Languages updated in 1.14 === diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 37893c179e..2e9da654e8 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -106,11 +106,15 @@ class ApiMain extends ApiBase { * 'params' => array ( $someVarToSubst ) ), * ); */ - private static $mRights = array( 'writeapi' => array( 'msg' => 'Use of the write API' , - 'params' => array() ), - 'apihighlimits' => array( 'msg' => 'Use higher limits in API queries (Slow queries: $1 results; Fast queries: $2 results). These limits also apply to multivalue parameters.', - 'params' => array ( ApiMain :: LIMIT_SML2, ApiMain :: LIMIT_BIG2 ) ), - ); + private static $mRights = array('writeapi' => array( + 'msg' => 'Use of the write API', + 'params' => array() + ), + 'apihighlimits' => array( + 'msg' => 'Use higher limits in API queries (Slow queries: $1 results; Fast queries: $2 results). These limits also apply to multivalue parameters.', + 'params' => array (ApiMain::LIMIT_SML2, ApiMain::LIMIT_BIG2) + ) + ); private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames; @@ -273,12 +277,11 @@ class ApiMain extends ApiBase { $this->printResult(true); } - global $wgRequest; if($this->mSquidMaxage == -1) { # Nobody called setCacheMaxAge(), use the (s)maxage parameters - $smaxage = $wgRequest->getVal('smaxage', 0); - $maxage = $wgRequest->getVal('maxage', 0); + $smaxage = $this->mRequest->getVal('smaxage', 0); + $maxage = $this->mRequest->getVal('maxage', 0); } else $smaxage = $maxage = $this->mSquidMaxage; @@ -345,6 +348,9 @@ class ApiMain extends ApiBase { } $this->getResult()->reset(); + // Re-add the id + if($this->mRequest->getCheck('requestid')) + $this->getResult()->addValue(null, 'requestid', $this->mRequest->getVal('requestid')); $this->getResult()->addValue(null, 'error', $errMessage); return $errMessage['code']; @@ -354,6 +360,9 @@ class ApiMain extends ApiBase { * Execute the actual module, without any error handling */ protected function executeAction() { + // First add the id to the top element + if($this->mRequest->getCheck('requestid')) + $this->getResult()->addValue(null, 'requestid', $this->mRequest->getVal('requestid')); $params = $this->extractRequestParams(); @@ -454,6 +463,7 @@ class ApiMain extends ApiBase { ApiBase :: PARAM_TYPE => 'integer', ApiBase :: PARAM_DFLT => 0 ), + 'requestid' => null, ); } @@ -468,6 +478,7 @@ class ApiMain extends ApiBase { 'maxlag' => 'Maximum lag', 'smaxage' => 'Set the s-maxage header to this many seconds. Errors are never cached', 'maxage' => 'Set the max-age header to this many seconds. Errors are never cached', + 'requestid' => 'Request ID to distinguish requests. This will just be output back to you', ); } -- 2.20.1