r36349 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36348‎ | r36349 | r36350 >
Date:20:06, 16 June 2008
Author:catrope
Status:old
Tags:
Comment:
Add maxage too
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiMain.php
@@ -262,14 +262,20 @@
263263
264264 $params = $this->extractRequestParams();
265265 if($this->mSquidMaxage == -1)
266 - # Nobody called setCacheMaxAge(), use the smaxage parameter
267 - $this->mSquidMaxage = $params['smaxage'];
268 -
 266+ {
 267+ # Nobody called setCacheMaxAge(), use the (s)maxage parameters
 268+ $smaxage = $params['smaxage'];
 269+ $maxage = $params['maxage'];
 270+ }
 271+ else
 272+ $smaxage = $maxage = $this->mSquidMaxage;
 273+
269274 // Set the cache expiration at the last moment, as any errors may change the expiration.
270275 // if $this->mSquidMaxage == 0, the expiry time is set to the first second of unix epoch
271 - $expires = $this->mSquidMaxage == 0 ? 1 : time() + $this->mSquidMaxage;
 276+ $exp = min($smaxage, $maxage);
 277+ $expires = $exp == 0 ? 1 : time() + $this->mSquidMaxage;
272278 header('Expires: ' . wfTimestamp(TS_RFC2822, $expires));
273 - header('Cache-Control: s-maxage=' . $this->mSquidMaxage . ', must-revalidate, max-age=0');
 279+ header('Cache-Control: s-maxage=' . $smaxage . ', must-revalidate, max-age=' . $maxage);
274280
275281 if($this->mPrinter->getIsHtml())
276282 echo wfReportTime();
@@ -420,6 +426,10 @@
421427 ApiBase :: PARAM_TYPE => 'integer',
422428 ApiBase :: PARAM_DFLT => 0
423429 ),
 430+ 'maxage' => array (
 431+ ApiBase :: PARAM_TYPE => 'integer',
 432+ ApiBase :: PARAM_DFLT => 0
 433+ ),
424434 );
425435 }
426436
@@ -432,7 +442,8 @@
433443 'action' => 'What action you would like to perform',
434444 'version' => 'When showing help, include version for each module',
435445 'maxlag' => 'Maximum lag',
436 - 'smaxage' => 'Cache the result for this many seconds. Errors are never cached',
 446+ 'smaxage' => 'Set the s-maxage header to this many seconds. Errors are never cached',
 447+ 'maxage' => 'Set the max-age header to this many seconds. Errors are never cached',
437448 );
438449 }
439450
Index: trunk/phase3/RELEASE-NOTES
@@ -450,7 +450,7 @@
451451 * (bug 14526) Unescaped SQL in list=backlinks
452452 * Added 'hidden' flag to list=allcategories and prop=categoryinfo output
453453 * Added nocreate parameter to action=edit
454 -* (bug 14402) Added smaxage parameter to api.php
 454+* (bug 14402) Added maxage and smaxage parameters to api.php
455455
456456 === Languages updated in 1.13 ===
457457

Status & tagging log