From: Roan Kattouw Date: Mon, 16 Jun 2008 19:49:43 +0000 (+0000) Subject: (bug 14402) Added smaxage parameter to api.php X-Git-Tag: 1.31.0-rc.0~46997 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=044ad0c0ce1354ad033c71f84ee341f1b95f2145;p=lhc%2Fweb%2Fwiklou.git (bug 14402) Added smaxage parameter to api.php --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e2cd03e35d..63d88053c9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -450,6 +450,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 14526) Unescaped SQL in list=backlinks * Added 'hidden' flag to list=allcategories and prop=categoryinfo output * Added nocreate parameter to action=edit +* (bug 14402) Added smaxage parameter to api.php === Languages updated in 1.13 === diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index c8a663722b..091148211b 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -154,7 +154,7 @@ class ApiMain extends ApiBase { $this->mRequest = & $request; - $this->mSquidMaxage = 0; + $this->mSquidMaxage = -1; // flag for executeActionWithErrorHandling() $this->mCommit = false; } @@ -260,6 +260,11 @@ class ApiMain extends ApiBase { $this->printResult(true); } + $params = $this->extractRequestParams(); + if($this->mSquidMaxage == -1) + # Nobody called setCacheMaxAge(), use the smaxage parameter + $this->mSquidMaxage = $params['smaxage']; + // Set the cache expiration at the last moment, as any errors may change the expiration. // if $this->mSquidMaxage == 0, the expiry time is set to the first second of unix epoch $expires = $this->mSquidMaxage == 0 ? 1 : time() + $this->mSquidMaxage; @@ -411,6 +416,10 @@ class ApiMain extends ApiBase { 'maxlag' => array ( ApiBase :: PARAM_TYPE => 'integer' ), + 'smaxage' => array ( + ApiBase :: PARAM_TYPE => 'integer', + ApiBase :: PARAM_DFLT => 0 + ), ); } @@ -422,7 +431,8 @@ class ApiMain extends ApiBase { 'format' => 'The format of the output', 'action' => 'What action you would like to perform', 'version' => 'When showing help, include version for each module', - 'maxlag' => 'Maximum lag' + 'maxlag' => 'Maximum lag', + 'smaxage' => 'Cache the result for this many seconds. Errors are never cached', ); }