r70061 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70060‎ | r70061 | r70062 >
Date:02:01, 28 July 2010
Author:tstarling
Status:ok
Tags:
Comment:
Brought the API cache header handling into sync with the REL1_16 branch, by reverting r69521, r69381, r69380 and r69342, and merging r69932 from REL1_16. It's effectively equivalent to MFT r69776, r69784, r69928 and r69931 except without the conflicts.
Modified paths:
  • /branches/wmf/1.16wmf4/includes/api (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiExpandTemplates.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiLogin.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiLogout.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiMain.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiOpenSearch.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiParse.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiPatrol.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiPurge.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQuery.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryAllCategories.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryAllLinks.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryAllimages.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryAllmessages.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryAllpages.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryBase.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryBlocks.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryCategories.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryInfo.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryMembers.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryDuplicateFiles.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryExtLinksUsage.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryExternalLinks.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryImageInfo.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryImages.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryInfo.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryLangLinks.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryLinks.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryLogEvents.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryProtectedTitles.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryRandom.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryRecentChanges.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQuerySearch.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQuerySiteinfo.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryTags.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryUserContributions.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryUserInfo.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryUsers.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlist.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlistRaw.php (modified) (history)
  • /branches/wmf/1.16wmf4/includes/api/ApiWatch.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/includes/api/ApiQueryExternalLinks.php
@@ -83,6 +83,10 @@
8484 $db->freeResult( $res );
8585 }
8686
 87+ public function getCacheMode( $params ) {
 88+ return 'public';
 89+ }
 90+
8791 public function getAllowedParams() {
8892 return array(
8993 'limit' => array(
@@ -117,4 +121,4 @@
118122 public function getVersion() {
119123 return __CLASS__ . ': $Id$';
120124 }
121 -}
\ No newline at end of file
 125+}
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryInfo.php
@@ -99,6 +99,10 @@
100100 $db->freeResult( $res );
101101 }
102102
 103+ public function getCacheMode( $params ) {
 104+ return 'public';
 105+ }
 106+
103107 public function getAllowedParams() {
104108 return array (
105109 'continue' => null,
@@ -122,4 +126,4 @@
123127 public function getVersion() {
124128 return __CLASS__ . ': $Id$';
125129 }
126 -}
\ No newline at end of file
 130+}
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryUsers.php
@@ -156,9 +156,6 @@
157157
158158 if ( !is_null( $params['token'] ) )
159159 {
160 - // Don't cache tokens
161 - $this->getMain()->setCachePrivate();
162 -
163160 $tokenFunctions = $this->getTokenFunctions();
164161 foreach ( $params['token'] as $t )
165162 {
@@ -210,6 +207,14 @@
211208 return $this->getResult()->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'user' );
212209 }
213210
 211+ public function getCacheMode( $params ) {
 212+ if ( isset( $params['token'] ) ) {
 213+ return 'private';
 214+ } else {
 215+ return 'public';
 216+ }
 217+ }
 218+
214219 public function getAllowedParams() {
215220 return array (
216221 'prop' => array (
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryUserContributions.php
@@ -164,8 +164,6 @@
165165 "rev_timestamp $op= '$encTS')" );
166166 }
167167
168 - // Make sure private data (deleted revisions) isn't cached
169 - $this->getMain()->setVaryCookie();
170168 if ( !$wgUser->isAllowed( 'hideuser' ) )
171169 $this->addWhere( $this->getDB()->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' );
172170 // We only want pages by the specified users.
@@ -212,12 +210,8 @@
213211 $this->fld_patrolled )
214212 {
215213 global $wgUser;
216 - // Don't cache private data
217 - $this->getMain()->setVaryCookie();
218 - if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) {
219 - $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
220 - }
221 -
 214+ if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() )
 215+ $this->dieUsage( "You need the patrol right to request the patrolled flag", 'permissiondenied' );
222216 // Use a redundant join condition on both
223217 // timestamp and ID so we can use the timestamp
224218 // index
@@ -314,7 +308,6 @@
315309
316310 if ( $this->fld_parsedcomment ) {
317311 global $wgUser;
318 - $this->getMain()->setVaryCookie();
319312 $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->rev_comment, $title );
320313 }
321314 }
@@ -345,6 +338,12 @@
346339 wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
347340 }
348341
 342+ public function getCacheMode( $params ) {
 343+ // This module provides access to deleted revisions and patrol flags if
 344+ // the requester is logged in
 345+ return 'anon-public-user-private';
 346+ }
 347+
349348 public function getAllowedParams() {
350349 return array (
351350 'limit' => array (
Index: branches/wmf/1.16wmf4/includes/api/ApiQuerySearch.php
@@ -155,6 +155,10 @@
156156 }
157157 }
158158
 159+ public function getCacheMode( $params ) {
 160+ return 'public';
 161+ }
 162+
159163 public function getAllowedParams() {
160164 return array (
161165 'search' => null,
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryRecentChanges.php
@@ -137,12 +137,8 @@
138138
139139 // Check permissions
140140 global $wgUser;
141 - if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
142 - $this->getMain()->setVaryCookie();
143 - if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) {
144 - $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
145 - }
146 - }
 141+ if ( ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() )
 142+ $this->dieUsage( "You need the patrol right to request the patrolled flag", 'permissiondenied' );
147143
148144 /* Add additional conditions to query depending upon parameters. */
149145 $this->addWhereIf( 'rc_minor = 0', isset ( $show['!minor'] ) );
@@ -362,7 +358,6 @@
363359
364360 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
365361 global $wgUser;
366 - $this->getMain()->setVaryCookie();
367362 $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->rc_comment, $title );
368363 }
369364
@@ -395,9 +390,6 @@
396391
397392 if ( !is_null( $this->token ) )
398393 {
399 - // Don't cache tokens
400 - $this->getMain()->setCachePrivate();
401 -
402394 $tokenFunctions = $this->getTokenFunctions();
403395 foreach ( $this->token as $t )
404396 {
@@ -430,6 +422,24 @@
431423 }
432424 }
433425
 426+ public function getCacheMode( $params ) {
 427+ if ( isset( $params['show'] ) ) {
 428+ foreach ( $params['show'] as $show ) {
 429+ if ( $show === 'patrolled' || $show === '!patrolled' ) {
 430+ return 'private';
 431+ }
 432+ }
 433+ }
 434+ if ( isset( $params['token'] ) ) {
 435+ return 'private';
 436+ }
 437+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
 438+ // formatComment() calls wfMsg() among other things
 439+ return 'anon-public-user-private';
 440+ }
 441+ return 'public';
 442+ }
 443+
434444 public function getAllowedParams() {
435445 return array (
436446 'start' => array (
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlistRaw.php
@@ -65,7 +65,6 @@
6666 $this->addFields( array( 'wl_namespace', 'wl_title' ) );
6767 $this->addFieldsIf( 'wl_notificationtimestamp', isset( $prop['changed'] ) );
6868 $this->addWhereFld( 'wl_user', $wgUser->getId() );
69 - $this->getMain()->setVaryCookie(); // Temp live hack until new code using getWatchlistUser() is merged
7069 $this->addWhereFld( 'wl_namespace', $params['namespace'] );
7170 $this->addWhereIf( 'wl_notificationtimestamp IS NOT NULL', isset( $show['changed'] ) );
7271 $this->addWhereIf( 'wl_notificationtimestamp IS NULL', isset( $show['!changed'] ) );
@@ -189,4 +188,4 @@
190189 public function getVersion() {
191190 return __CLASS__ . ': $Id$';
192191 }
193 -}
 192+}
\ No newline at end of file
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryAllCategories.php
@@ -44,6 +44,10 @@
4545 $this->run();
4646 }
4747
 48+ public function getCacheMode( $params ) {
 49+ return 'public';
 50+ }
 51+
4852 public function executeGenerator( $resultPageSet ) {
4953 $this->run( $resultPageSet );
5054 }
@@ -177,4 +181,4 @@
178182 public function getVersion() {
179183 return __CLASS__ . ': $Id$';
180184 }
181 -}
\ No newline at end of file
 185+}
Index: branches/wmf/1.16wmf4/includes/api/ApiQuery.php
@@ -206,9 +206,15 @@
207207 $this->InstantiateModules( $modules, 'list', $this->mQueryListModules );
208208 $this->InstantiateModules( $modules, 'meta', $this->mQueryMetaModules );
209209
 210+ $cacheMode = 'public';
 211+
210212 // If given, execute generator to substitute user supplied data with generated data.
211213 if ( isset ( $this->params['generator'] ) ) {
212 - $this->executeGeneratorModule( $this->params['generator'], $modules );
 214+ $generator = $this->newGenerator( $this->params['generator'] );
 215+ $params = $generator->extractRequestParams();
 216+ $cacheMode = $this->mergeCacheMode( $cacheMode,
 217+ $generator->getCacheMode( $params ) );
 218+ $this->executeGeneratorModule( $generator, $modules );
213219 } else {
214220 // Append custom fields and populate page/revision information
215221 $this->addCustomFldsToPageSet( $modules, $this->mPageSet );
@@ -220,14 +226,38 @@
221227
222228 // Execute all requested modules.
223229 foreach ( $modules as $module ) {
 230+ $params = $module->extractRequestParams();
 231+ $cacheMode = $this->mergeCacheMode(
 232+ $cacheMode, $module->getCacheMode( $params ) );
224233 $module->profileIn();
225234 $module->execute();
226235 wfRunHooks( 'APIQueryAfterExecute', array( &$module ) );
227236 $module->profileOut();
228237 }
 238+
 239+ // Set the cache mode
 240+ $this->getMain()->setCacheMode( $cacheMode );
229241 }
230242
231243 /**
 244+ * Update a cache mode string, applying the cache mode of a new module to it.
 245+ * The cache mode may increase in the level of privacy, but public modules
 246+ * added to private data do not decrease the level of privacy.
 247+ */
 248+ protected function mergeCacheMode( $cacheMode, $modCacheMode ) {
 249+ if ( $modCacheMode === 'anon-public-user-private' ) {
 250+ if ( $cacheMode !== 'private' ) {
 251+ $cacheMode = 'anon-public-user-private';
 252+ }
 253+ } elseif ( $modCacheMode === 'public' ) {
 254+ // do nothing, if it's public already it will stay public
 255+ } else { // private
 256+ $cacheMode = 'private';
 257+ }
 258+ return $cacheMode;
 259+ }
 260+
 261+ /**
232262 * Query modules may optimize data requests through the $this->getPageSet() object
233263 * by adding extra fields from the page table.
234264 * This function will gather all the extra request fields from the modules.
@@ -401,12 +431,9 @@
402432 }
403433
404434 /**
405 - * For generator mode, execute generator, and use its output as new
406 - * ApiPageSet
407 - * @param $generatorName string Module name
408 - * @param $modules array of module objects
 435+ * Create a generator object of the given type and return it
409436 */
410 - protected function executeGeneratorModule( $generatorName, $modules ) {
 437+ public function newGenerator( $generatorName ) {
411438
412439 // Find class that implements requested generator
413440 if ( isset ( $this->mQueryListModules[$generatorName] ) ) {
@@ -424,9 +451,20 @@
425452 $generator = new $className ( $this, $generatorName );
426453 if ( !$generator instanceof ApiQueryGeneratorBase )
427454 $this->dieUsage( "Module $generatorName cannot be used as a generator", "badgenerator" );
428 -
429455 $generator->setGeneratorMode();
 456+ return $generator;
 457+ }
430458
 459+ /**
 460+ * For generator mode, execute generator, and use its output as new
 461+ * ApiPageSet
 462+ * @param $generatorName string Module name
 463+ * @param $modules array of module objects
 464+ */
 465+ protected function executeGeneratorModule( $generator, $modules ) {
 466+ // Generator results
 467+ $resultPageSet = new ApiPageSet( $this, $this->redirects, $this->convertTitles );
 468+
431469 // Add any additional fields modules may need
432470 $generator->requestExtraData( $this->mPageSet );
433471 $this->addCustomFldsToPageSet( $modules, $resultPageSet );
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryLinks.php
@@ -64,6 +64,10 @@
6565 $this->run();
6666 }
6767
 68+ public function getCacheMode( $params ) {
 69+ return 'public';
 70+ }
 71+
6872 public function executeGenerator( $resultPageSet ) {
6973 $this->run( $resultPageSet );
7074 }
@@ -206,4 +210,4 @@
207211 public function getVersion() {
208212 return __CLASS__ . ': $Id$';
209213 }
210 -}
\ No newline at end of file
 214+}
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiLogin.php
___________________________________________________________________
Modified: svn:mergeinfo
211215 Merged /branches/REL1_16/phase3/includes/api/ApiLogin.php:r69932
Index: branches/wmf/1.16wmf4/includes/api/ApiLogout.php
@@ -42,7 +42,6 @@
4343
4444 public function execute() {
4545 global $wgUser;
46 - $this->getMain()->setCachePrivate();
4746 $oldName = $wgUser->getName();
4847 $wgUser->logout();
4948
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryExtLinksUsage.php
@@ -41,6 +41,10 @@
4242 $this->run();
4343 }
4444
 45+ public function getCacheMode( $params ) {
 46+ return 'public';
 47+ }
 48+
4549 public function executeGenerator( $resultPageSet ) {
4650 $this->run( $resultPageSet );
4751 }
@@ -218,4 +222,4 @@
219223 public function getVersion() {
220224 return __CLASS__ . ': $Id$';
221225 }
222 -}
\ No newline at end of file
 226+}
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryUserInfo.php
@@ -40,7 +40,6 @@
4141 }
4242
4343 public function execute() {
44 - $this->getMain()->setCachePrivate();
4544 $params = $this->extractRequestParams();
4645 $result = $this->getResult();
4746 $r = array();
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php
@@ -92,6 +92,10 @@
9393 $this->run();
9494 }
9595
 96+ public function getCacheMode( $params ) {
 97+ return 'public';
 98+ }
 99+
96100 public function executeGenerator( $resultPageSet ) {
97101 $this->run( $resultPageSet );
98102 }
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php
@@ -42,7 +42,6 @@
4343 public function execute() {
4444
4545 global $wgUser;
46 - $this->getMain()->setVaryCookie();
4746 // Before doing anything at all, let's check permissions
4847 if ( !$wgUser->isAllowed( 'deletedhistory' ) )
4948 $this->dieUsage( 'You don\'t have permission to view deleted revision information', 'permissiondenied' );
@@ -200,7 +199,6 @@
201200
202201 if ( $fld_parsedcomment ) {
203202 global $wgUser;
204 - $this->getMain()->setVaryCookie();
205203 $rev['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->ar_comment, $title );
206204 }
207205 if ( $fld_minor && $row->ar_minor_edit == 1 )
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryCategories.php
@@ -43,6 +43,10 @@
4444 $this->run();
4545 }
4646
 47+ public function getCacheMode( $params ) {
 48+ return 'public';
 49+ }
 50+
4751 public function executeGenerator( $resultPageSet ) {
4852 $this->run( $resultPageSet );
4953 }
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryMembers.php
@@ -43,6 +43,10 @@
4444 $this->run();
4545 }
4646
 47+ public function getCacheMode( $params ) {
 48+ return 'public';
 49+ }
 50+
4751 public function executeGenerator( $resultPageSet ) {
4852 $this->run( $resultPageSet );
4953 }
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php
@@ -189,6 +189,10 @@
190190 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'u' );
191191 }
192192
 193+ public function getCacheMode( $params ) {
 194+ return 'public';
 195+ }
 196+
193197 public function getAllowedParams() {
194198 return array (
195199 'from' => null,
@@ -242,4 +246,4 @@
243247 public function getVersion() {
244248 return __CLASS__ . ': $Id$';
245249 }
246 -}
\ No newline at end of file
 250+}
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php
___________________________________________________________________
Added: svn:mergeinfo
247251 Merged /trunk/phase3/includes/api/ApiQueryAllUsers.php:r69339,69347,69350,69369,69379,69776,69931
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryInfo.php
@@ -244,7 +244,6 @@
245245 $this->getProtectionInfo();
246246
247247 if ( $this->fld_watched )
248 - $this->getMain()->setVaryCookie();
249248 $this->getWatchedInfo();
250249
251250 // Run the talkid/subjectid query if requested
@@ -289,9 +288,6 @@
290289 }
291290
292291 if ( !is_null( $this->params['token'] ) ) {
293 - // Don't cache tokens
294 - $this->getMain()->setCachePrivate();
295 -
296292 $tokenFunctions = $this->getTokenFunctions();
297293 $pageInfo['starttimestamp'] = wfTimestamp( TS_ISO_8601, time() );
298294 foreach ( $this->params['token'] as $t )
@@ -557,6 +553,27 @@
558554 }
559555 }
560556
 557+ public function getCacheMode( $params ) {
 558+ $publicProps = array(
 559+ 'protection',
 560+ 'talkid',
 561+ 'subjectid',
 562+ 'url',
 563+ 'preload',
 564+ );
 565+ if ( !is_null( $params['prop'] ) ) {
 566+ foreach ( $params['prop'] as $prop ) {
 567+ if ( !in_array( $prop, $publicProps ) ) {
 568+ return 'private';
 569+ }
 570+ }
 571+ }
 572+ if ( !is_null( $params['token'] ) ) {
 573+ return 'private';
 574+ }
 575+ return 'public';
 576+ }
 577+
561578 public function getAllowedParams() {
562579 return array (
563580 'prop' => array (
@@ -565,11 +582,13 @@
566583 ApiBase :: PARAM_TYPE => array (
567584 'protection',
568585 'talkid',
569 - 'watched',
 586+ 'watched', # private
570587 'subjectid',
571588 'url',
572 - 'readable',
 589+ 'readable', # private
573590 'preload'
 591+ // If you add more properties here, please consider whether they
 592+ // need to be added to getCacheMode()
574593 ) ),
575594 'token' => array (
576595 ApiBase :: PARAM_DFLT => null,
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryDuplicateFiles.php
@@ -43,6 +43,10 @@
4444 $this->run();
4545 }
4646
 47+ public function getCacheMode( $params ) {
 48+ return 'public';
 49+ }
 50+
4751 public function executeGenerator( $resultPageSet ) {
4852 $this->run( $resultPageSet );
4953 }
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryAllimages.php
@@ -55,6 +55,10 @@
5656 $this->run();
5757 }
5858
 59+ public function getCacheMode( $params ) {
 60+ return 'public';
 61+ }
 62+
5963 public function executeGenerator( $resultPageSet ) {
6064 if ( $resultPageSet->isResolvingRedirects() )
6165 $this->dieUsage( 'Use "gaifilterredir=nonredirects" option instead of "redirects" when using allimages as a generator', 'params' );
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryTags.php
@@ -129,6 +129,10 @@
130130 return true;
131131 }
132132
 133+ public function getCacheMode( $params ) {
 134+ return 'public';
 135+ }
 136+
133137 public function getAllowedParams() {
134138 return array (
135139 'continue' => array(
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryAllmessages.php
@@ -46,9 +46,6 @@
4747 {
4848 global $wgLang;
4949 $wgLang = Language::factory( $params['lang'] );
50 - } else if ( is_null( $params['lang'] ) ) {
51 - // Language not determined by URL but by user preferences, so don't cache
52 - $this->getMain()->setVaryCookie();
5350 }
5451
5552 $prop = array_flip( (array)$params['prop'] );
@@ -123,6 +120,19 @@
124121 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'message' );
125122 }
126123
 124+ public function getCacheMode( $params ) {
 125+ if ( is_null( $params['lang'] ) ) {
 126+ // Language not specified, will be fetched from preferences
 127+ return 'anon-public-user-private';
 128+ } elseif ( $params['enableparser'] ) {
 129+ // User-specific parser options will be used
 130+ return 'anon-public-user-private';
 131+ } else {
 132+ // OK to cache
 133+ return 'public';
 134+ }
 135+ }
 136+
127137 public function getAllowedParams() {
128138 return array (
129139 'messages' => array (
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryImages.php
@@ -122,6 +122,10 @@
123123 $db->freeResult( $res );
124124 }
125125
 126+ public function getCacheMode( $params ) {
 127+ return 'public';
 128+ }
 129+
126130 public function getAllowedParams() {
127131 return array(
128132 'limit' => array(
@@ -164,4 +168,4 @@
165169 public function getVersion() {
166170 return __CLASS__ . ': $Id$';
167171 }
168 -}
\ No newline at end of file
 172+}
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryLogEvents.php
@@ -267,7 +267,6 @@
268268
269269 if ( $this->fld_parsedcomment ) {
270270 global $wgUser;
271 - $this->getMain()->setVaryCookie();
272271 $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->log_comment, $title );
273272 }
274273 }
@@ -286,6 +285,15 @@
287286 return $vals;
288287 }
289288
 289+ public function getCacheMode( $params ) {
 290+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
 291+ // formatComment() calls wfMsg() among other things
 292+ return 'anon-public-user-private';
 293+ } else {
 294+ return 'public';
 295+ }
 296+ }
 297+
290298 public function getAllowedParams() {
291299 global $wgLogTypes;
292300 return array (
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryAllLinks.php
@@ -43,6 +43,10 @@
4444 $this->run();
4545 }
4646
 47+ public function getCacheMode( $params ) {
 48+ return 'public';
 49+ }
 50+
4751 public function executeGenerator( $resultPageSet ) {
4852 $this->run( $resultPageSet );
4953 }
@@ -207,4 +211,4 @@
208212 public function getVersion() {
209213 return __CLASS__ . ': $Id$';
210214 }
211 -}
\ No newline at end of file
 215+}
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryProtectedTitles.php
@@ -100,7 +100,6 @@
101101
102102 if ( isset( $prop['parsedcomment'] ) ) {
103103 global $wgUser;
104 - $this->getMain()->setVaryCookie();
105104 $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->pt_reason, $title );
106105 }
107106
@@ -127,6 +126,15 @@
128127 $resultPageSet->populateFromTitles( $titles );
129128 }
130129
 130+ public function getCacheMode( $params ) {
 131+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
 132+ // formatComment() calls wfMsg() among other things
 133+ return 'anon-public-user-private';
 134+ } else {
 135+ return 'public';
 136+ }
 137+ }
 138+
131139 public function getAllowedParams() {
132140 global $wgRestrictionLevels;
133141 return array (
@@ -198,4 +206,4 @@
199207 public function getVersion() {
200208 return __CLASS__ . ': $Id$';
201209 }
202 -}
\ No newline at end of file
 210+}
Index: branches/wmf/1.16wmf4/includes/api/ApiWatch.php
@@ -41,7 +41,6 @@
4242
4343 public function execute() {
4444 global $wgUser;
45 - $this->getMain()->setCachePrivate();
4645 if ( !$wgUser->isLoggedIn() )
4746 $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
4847
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryRandom.php
@@ -121,6 +121,10 @@
122122 return $vals;
123123 }
124124
 125+ public function getCacheMode( $params ) {
 126+ return 'public';
 127+ }
 128+
125129 public function getAllowedParams() {
126130 return array (
127131 'namespace' => array(
@@ -161,4 +165,4 @@
162166 public function getVersion() {
163167 return __CLASS__ . ': $Id: ApiQueryRandom.php overlordq$';
164168 }
165 -}
\ No newline at end of file
 169+}
Index: branches/wmf/1.16wmf4/includes/api/ApiQuerySiteinfo.php
@@ -421,6 +421,9 @@
422422 return $this->getResult()->addValue( 'query', $property, $data );
423423 }
424424
 425+ public function getCacheMode( $params ) {
 426+ return 'public';
 427+ }
425428
426429 public function getAllowedParams() {
427430 return array(
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryLangLinks.php
@@ -93,6 +93,10 @@
9494 $db->freeResult( $res );
9595 }
9696
 97+ public function getCacheMode( $params ) {
 98+ return 'public';
 99+ }
 100+
97101 public function getAllowedParams() {
98102 return array(
99103 'limit' => array(
@@ -133,4 +137,4 @@
134138 public function getVersion() {
135139 return __CLASS__ . ': $Id$';
136140 }
137 -}
\ No newline at end of file
 141+}
Index: branches/wmf/1.16wmf4/includes/api/ApiParse.php
@@ -38,6 +38,9 @@
3939 }
4040
4141 public function execute() {
 42+ // The data is hot but user-dependent, like page views, so we set vary cookies
 43+ $this->getMain()->setCacheMode( 'anon-public-user-private' );
 44+
4245 // Get parameters
4346 $params = $this->extractRequestParams();
4447 $text = $params['text'];
@@ -118,11 +121,10 @@
119122 if ( !$titleObj )
120123 $titleObj = Title::newFromText( "API" );
121124 $wgTitle = $titleObj;
122 - if ( $params['pst'] || $params['onlypst'] ) {
 125+ if ( $params['pst'] || $params['onlypst'] )
123126 $text = $wgParser->preSaveTransform( $text, $titleObj, $wgUser, $popts );
124 - $this->getMain()->setVaryCookie();
125 - }
126 - if ( $params['onlypst'] ) {
 127+ if ( $params['onlypst'] )
 128+ {
127129 // Build a result and bail out
128130 $result_array['text'] = array();
129131 $this->getResult()->setContent( $result_array['text'], $text );
@@ -145,7 +147,6 @@
146148
147149 if ( !is_null( $params['summary'] ) ) {
148150 $result_array['parsedsummary'] = array();
149 - $this->getMain()->setVaryCookie();
150151 $result->setContent( $result_array['parsedsummary'], $wgUser->getSkin()->formatComment( $params['summary'], $titleObj ) );
151152 }
152153
@@ -174,7 +175,6 @@
175176 if ( isset( $prop['headhtml'] ) ) {
176177 $out = new OutputPage;
177178 $out->addParserOutputNoText( $p_result );
178 - $this->getMain()->setVaryCookie();
179179 $result_array['headhtml'] = array();
180180 $result->setContent( $result_array['headhtml'], $out->headElement( $wgUser->getSkin() ) );
181181 }
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryAllpages.php
@@ -43,6 +43,10 @@
4444 $this->run();
4545 }
4646
 47+ public function getCacheMode( $params ) {
 48+ return 'public';
 49+ }
 50+
4751 public function executeGenerator( $resultPageSet ) {
4852 if ( $resultPageSet->isResolvingRedirects() )
4953 $this->dieUsage( 'Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator', 'params' );
Index: branches/wmf/1.16wmf4/includes/api/ApiPurge.php
@@ -42,7 +42,6 @@
4343 */
4444 public function execute() {
4545 global $wgUser;
46 - $this->getMain()->setCachePrivate();
4746 $params = $this->extractRequestParams();
4847 if ( !$wgUser->isAllowed( 'purge' ) )
4948 $this->dieUsageMsg( array( 'cantpurge' ) );
Index: branches/wmf/1.16wmf4/includes/api/ApiMain.php
@@ -124,9 +124,10 @@
125125
126126 private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames;
127127 private $mResult, $mAction, $mShowVersions, $mEnableWrite, $mRequest;
128 - private $mInternalMode, $mSquidMaxage, $mModule, $mVaryCookie;
 128+ private $mInternalMode, $mSquidMaxage, $mModule;
129129
130 - private $mCacheControl = array( 'must-revalidate' => true );
 130+ private $mCacheMode = 'private';
 131+ private $mCacheControl = array();
131132
132133 /**
133134 * Constructs an instance of ApiMain that utilizes the module and format specified by $request.
@@ -171,7 +172,6 @@
172173
173174 $this->mSquidMaxage = - 1; // flag for executeActionWithErrorHandling()
174175 $this->mCommit = false;
175 - $this->mVaryCookie = false;
176176 }
177177
178178 /**
@@ -222,19 +222,67 @@
223223 's-maxage' => $maxage
224224 ) );
225225 }
 226+
 227+ /**
 228+ * Set the type of caching headers which will be sent.
 229+ *
 230+ * @param $mode One of:
 231+ * - 'public': Cache this object in public caches, if the maxage or smaxage
 232+ * parameter is set, or if setCacheMaxAge() was called. If a maximum age is
 233+ * not provided by any of these means, the object will be private.
 234+ * - 'private': Cache this object only in private client-side caches.
 235+ * - 'anon-public-user-private': Make this object cacheable for logged-out
 236+ * users, but private for logged-in users. IMPORTANT: If this is set, it must be
 237+ * set consistently for a given URL, it cannot be set differently depending on
 238+ * things like the contents of the database, or whether the user is logged in.
 239+ *
 240+ * If the wiki does not allow anonymous users to read it, the mode set here
 241+ * will be ignored, and private caching headers will always be sent. In other words,
 242+ * the "public" mode is equivalent to saying that the data sent is as public as a page
 243+ * view.
 244+ *
 245+ * For user-dependent data, the private mode should generally be used. The
 246+ * anon-public-user-private mode should only be used where there is a particularly
 247+ * good performance reason for caching the anonymous response, but where the
 248+ * response to logged-in users may differ, or may contain private data.
 249+ *
 250+ * If this function is never called, then the default will be the private mode.
 251+ */
 252+ public function setCacheMode( $mode ) {
 253+ if ( !in_array( $mode, array( 'private', 'public', 'anon-public-user-private' ) ) ) {
 254+ wfDebug( __METHOD__.": unrecognised cache mode \"$mode\"\n" );
 255+ // Ignore for forwards-compatibility
 256+ return;
 257+ }
 258+
 259+ if ( !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) {
 260+ // Private wiki, only private headers
 261+ if ( $mode !== 'private' ) {
 262+ wfDebug( __METHOD__.": ignoring request for $mode cache mode, private wiki\n" );
 263+ return;
 264+ }
 265+ }
 266+
 267+ wfDebug( __METHOD__.": setting cache mode $mode\n" );
 268+ $this->mCacheMode = $mode;
 269+ }
226270
227271 /**
228 - * Make sure Cache-Control: private is set. Use this when the output of a request
229 - * is for the current recipient only and should not be cached in any shared cache.
 272+ * @deprecated Private caching is now the default, so there is usually no
 273+ * need to call this function. If there is a need, you can use
 274+ * $this->setCacheMode('private')
230275 */
231276 public function setCachePrivate() {
232 - $this->setCacheControl( array( 'private' => true ) );
 277+ $this->setCacheMode( 'private' );
233278 }
234279
235280 /**
236281 * Set directives (key/value pairs) for the Cache-Control header.
237282 * Boolean values will be formatted as such, by including or omitting
238283 * without an equals sign.
 284+ *
 285+ * Cache control values set here will only be used if the cache mode is not
 286+ * private, see setCacheMode().
239287 */
240288 public function setCacheControl( $directives ) {
241289 $this->mCacheControl = $directives + $this->mCacheControl;
@@ -247,27 +295,12 @@
248296 * WARNING: This function must be called CONSISTENTLY for a given URL. This means that a
249297 * given URL must either always or never call this function; if it sometimes does and
250298 * sometimes doesn't, stuff will break.
 299+ *
 300+ * @deprecated Use setCacheMode( 'anon-public-user-private' )
251301 */
252302 public function setVaryCookie() {
253 - $this->mVaryCookie = true;
 303+ $this->setCacheMode( 'anon-public-user-private' );
254304 }
255 -
256 - /**
257 - * Actually output the Vary: Cookie header and its friends, if flagged with setVaryCookie().
258 - * Outputs the appropriate X-Vary-Options header and Cache-Control: private if needed.
259 - */
260 - private function outputVaryCookieHeader() {
261 - global $wgUseXVO, $wgOut;
262 - if ( $this->mVaryCookie ) {
263 - header( 'Vary: Cookie' );
264 - if ( $wgUseXVO ) {
265 - header( $wgOut->getXVO() );
266 - if ( $wgOut->haveCacheVaryCookies() ) {
267 - $this->setCacheControl( array( 'private' => true ) );
268 - }
269 - }
270 - }
271 - }
272305
273306 /**
274307 * Create an instance of an output formatter by its name
@@ -318,8 +351,7 @@
319352 $errCode = $this->substituteResultWithError( $e );
320353
321354 // Error results should not be cached
322 - $this->setCacheMaxAge( 0 );
323 - $this->setCachePrivate();
 355+ $this->setCacheMode( 'private' );
324356
325357 $headerStr = 'MediaWiki-API-Error: ' . $errCode;
326358 if ( $e->getCode() === 0 )
@@ -334,12 +366,49 @@
335367 $this->mPrinter->safeProfileOut();
336368 $this->printResult( true );
337369 }
338 -
339 - // If this wiki is private, don't cache anything ever
340 - if ( ! in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) ) {
341 - $this->setCachePrivate();
 370+
 371+ // Send cache headers after any code which might generate an error, to
 372+ // avoid sending public cache headers for errors.
 373+ $this->sendCacheHeaders();
 374+
 375+ if ( $this->mPrinter->getIsHtml() && !$this->mPrinter->isDisabled() ) {
 376+ echo wfReportTime();
342377 }
343378
 379+ ob_end_flush();
 380+ }
 381+
 382+ protected function sendCacheHeaders() {
 383+ if ( $this->mCacheMode == 'private' ) {
 384+ header( 'Cache-Control: private' );
 385+ return;
 386+ }
 387+
 388+ if ( $this->mCacheMode == 'anon-public-user-private' ) {
 389+ global $wgUseXVO, $wgOut;
 390+ header( 'Vary: Accept-Encoding, Cookie' );
 391+ if ( $wgUseXVO ) {
 392+ header( $wgOut->getXVO() );
 393+ if ( $wgOut->haveCacheVaryCookies() ) {
 394+ // Logged in, mark this request private
 395+ header( 'Cache-Control: private' );
 396+ return;
 397+ }
 398+ // Logged out, send normal public headers below
 399+ } elseif ( session_id() != '' ) {
 400+ // Logged in or otherwise has session (e.g. anonymous users who have edited)
 401+ // Mark request private
 402+ header( 'Cache-Control: private' );
 403+ return;
 404+ } // else no XVO and anonymous, send public headers below
 405+ } else /* if public */ {
 406+ // Give a debugging message if the user object is unstubbed on a public request
 407+ global $wgUser;
 408+ if ( !( $wgUser instanceof StubUser ) ) {
 409+ wfDebug( __METHOD__." \$wgUser is unstubbed on a public request!\n" );
 410+ }
 411+ }
 412+
344413 // If nobody called setCacheMaxAge(), use the (s)maxage parameters
345414 if ( !isset( $this->mCacheControl['s-maxage'] ) ) {
346415 $this->mCacheControl['s-maxage'] = $this->getParameter( 'smaxage' );
@@ -348,12 +417,21 @@
349418 $this->mCacheControl['max-age'] = $this->getParameter( 'maxage' );
350419 }
351420
352 - // Set the cache expiration at the last moment, as any errors may change the expiration.
353 - // if $this->mSquidMaxage == 0, the expiry time is set to the first second of unix epoch
354 - $exp = min( $this->mCacheControl['s-maxage'], $this->mCacheControl['max-age'] );
355 - $expires = ( $exp == 0 ? 1 : time() + $exp );
356 - header( 'Expires: ' . wfTimestamp( TS_RFC2822, $expires ) );
 421+ if ( !$this->mCacheControl['s-maxage'] && !$this->mCacheControl['max-age'] ) {
 422+ // Public cache not requested
 423+ // Sending a Vary header in this case is harmless, and protects us
 424+ // against conditional calls of setCacheMaxAge().
 425+ header( 'Cache-Control: private' );
 426+ return;
 427+ }
357428
 429+ $this->mCacheControl['public'] = true;
 430+
 431+ // Send an Expires header
 432+ $maxAge = min( $this->mCacheControl['s-maxage'], $this->mCacheControl['max-age'] );
 433+ $expiryUnixTime = ( $maxAge == 0 ? 1 : time() + $maxAge );
 434+ header( 'Expires: ' . wfTimestamp( TS_RFC2822, $expiryUnixTime ) );
 435+
358436 // Construct the Cache-Control header
359437 $ccHeader = '';
360438 $separator = '';
@@ -370,12 +448,6 @@
371449 }
372450
373451 header( "Cache-Control: $ccHeader" );
374 - $this->outputVaryCookieHeader();
375 -
376 - if ( $this->mPrinter->getIsHtml() )
377 - echo wfReportTime();
378 -
379 - ob_end_flush();
380452 }
381453
382454 /**
@@ -491,8 +563,7 @@
492564 }
493565
494566 global $wgUser, $wgGroupPermissions;
495 - if ( $module->isReadMode() && !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) &&
496 - !$wgUser->isAllowed( 'read' ) )
 567+ if ( $module->isReadMode() && !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) && !$wgUser->isAllowed( 'read' ) )
497568 $this->dieUsageMsg( array( 'readrequired' ) );
498569 if ( $module->isWriteMode() ) {
499570 if ( !$this->mEnableWrite )
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryImageInfo.php
@@ -244,6 +244,10 @@
245245 return $retval;
246246 }
247247
 248+ public function getCacheMode( $params ) {
 249+ return 'public';
 250+ }
 251+
248252 private function getContinueStr( $img )
249253 {
250254 return $img->getOriginalTitle()->getText() .
Index: branches/wmf/1.16wmf4/includes/api/ApiOpenSearch.php
@@ -56,7 +56,7 @@
5757 // Open search results may be stored for a very long
5858 // time
5959 $this->getMain()->setCacheMaxAge( $wgSearchSuggestCacheExpiry );
60 - $this->getMain()->setCacheControl( array( 'must-revalidate' => false ) );
 60+ $this->getMain()->setCacheMode( 'public' );
6161
6262 $srchres = PrefixSearch::titleSearch( $search, $limit,
6363 $namespaces );
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlist.php
@@ -68,14 +68,9 @@
6969 if ( $token == '' || $token != $params['token'] ) {
7070 $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' );
7171 }
 72+ } elseif ( !$wgUser->isLoggedIn() ) {
 73+ $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
7274 } else {
73 - // Temp live hack until new code using getWatchlistUser() is deployed
74 -
75 - // User not determined by URL, so don't cache
76 - $this->getMain()->setVaryCookie();
77 - if ( !$wgUser->isLoggedIn() ) {
78 - $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
79 - }
8075 $user = $wgUser;
8176 }
8277
@@ -95,7 +90,6 @@
9691 $this->fld_notificationtimestamp = isset( $prop['notificationtimestamp'] );
9792
9893 if ( $this->fld_patrol ) {
99 - $this->getMain()->setVaryCookie();
10094 if ( !$user->useRCPatrol() && !$user->useNPPatrol() )
10195 $this->dieUsage( 'patrol property is not available', 'patrol' );
10296 }
@@ -160,13 +154,9 @@
161155 $this->dieUsageMsg( array( 'show' ) );
162156 }
163157
164 - // Check permissions. FIXME: should this check $user instead of $wgUser?
165 - if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
166 - $this->getMain()->setVaryCookie();
167 - if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) {
168 - $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
169 - }
170 - }
 158+ // Check permissions.
 159+ if ( ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() )
 160+ $this->dieUsage( "You need the patrol right to request the patrolled flag", 'permissiondenied' );
171161
172162 /* Add additional conditions to query depending upon parameters. */
173163 $this->addWhereIf( 'rc_minor = 0', isset ( $show['!minor'] ) );
@@ -282,7 +272,6 @@
283273
284274 if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
285275 global $wgUser;
286 - $this->getMain()->setVaryCookie();
287276 $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->rc_comment, $title );
288277 }
289278
Index: branches/wmf/1.16wmf4/includes/api/ApiExpandTemplates.php
@@ -42,6 +42,9 @@
4343 }
4444
4545 public function execute() {
 46+ // Cache may vary on $wgUser because ParserOptions gets data from it
 47+ $this->getMain()->setCacheMode( 'anon-public-user-private' );
 48+
4649 // Get parameters
4750 $params = $this->extractRequestParams();
4851
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryBase.php
@@ -47,6 +47,17 @@
4848 }
4949
5050 /**
 51+ * Get the cache mode for the data generated by this module. Override this
 52+ * in the module subclass.
 53+ *
 54+ * Public caching will only be allowed if *all* the modules that supply
 55+ * data for a given request return a cache mode of public.
 56+ */
 57+ public function getCacheMode( $params ) {
 58+ return 'private';
 59+ }
 60+
 61+ /**
5162 * Blank the internal arrays with query parameters
5263 */
5364 protected function resetQueryParams() {
Index: branches/wmf/1.16wmf4/includes/api/ApiPatrol.php
@@ -41,7 +41,6 @@
4242 * Patrols the article or provides the reason the patrol failed.
4343 */
4444 public function execute() {
45 - $this->getMain()->setCachePrivate();
4645 $params = $this->extractRequestParams();
4746
4847 if ( !isset( $params['rcid'] ) )
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryBlocks.php
@@ -121,9 +121,6 @@
122122 'ipb_auto' => 0
123123 ) );
124124 }
125 -
126 - // Make sure private data (deleted blocks) isn't cached
127 - $this->getMain()->setVaryCookie();
128125 if ( !$wgUser->isAllowed( 'hideuser' ) )
129126 $this->addWhereFld( 'ipb_deleted', 0 );
130127
@@ -283,4 +280,4 @@
284281 public function getVersion() {
285282 return __CLASS__ . ': $Id$';
286283 }
287 -}
 284+}
\ No newline at end of file
Index: branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php
@@ -378,7 +378,6 @@
379379
380380 if ( $this->fld_parsedcomment ) {
381381 global $wgUser;
382 - $this->getMain()->setVaryCookie();
383382 $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $comment, $title );
384383 }
385384 }
@@ -397,9 +396,6 @@
398397
399398 if ( !is_null( $this->token ) )
400399 {
401 - // Don't cache tokens
402 - $this->getMain()->setCachePrivate();
403 -
404400 $tokenFunctions = $this->getTokenFunctions();
405401 foreach ( $this->token as $t )
406402 {
@@ -468,6 +464,17 @@
469465 return $vals;
470466 }
471467
 468+ public function getCacheMode( $params ) {
 469+ if ( isset( $params['token'] ) ) {
 470+ return 'private';
 471+ }
 472+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
 473+ // formatComment() calls wfMsg() among other things
 474+ return 'anon-public-user-private';
 475+ }
 476+ return 'public';
 477+ }
 478+
472479 public function getAllowedParams() {
473480 return array (
474481 'prop' => array (
Property changes on: branches/wmf/1.16wmf4/includes/api
___________________________________________________________________
Modified: svn:mergeinfo
475482 Merged /branches/REL1_16/phase3/includes/api:r69932
476483 Merged /trunk/phase3/includes/api:r69339,69347,69350,69369,69379,69776,69931

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r693421.16wmf4: MFT r69339catrope19:27, 14 July 2010
r693801.16wmf4: MFT r69347, r69350, r69369, r69379catrope09:41, 15 July 2010
r69381Fixed syntax errors from botched merge r69342. Please check your diffs before...tstarling12:33, 15 July 2010
r69521One tiny missing character - one overloaded cluster! :-)midom21:21, 18 July 2010
r69776Rewrote r69339 etc. to clean up API cache header handling....tstarling07:17, 23 July 2010
r69784Followup to r69776: remove calls to setCachePrivate() and setVaryCookie() fro...catrope11:17, 23 July 2010
r69928Fixes for r69784:...tstarling06:00, 26 July 2010
r69931Fix for r69776: remove unused variable ApiMain::$mVaryCookietstarling07:35, 26 July 2010
r69932* MFT r69776, and followups r69784, r69928, r69931, and superseded base revis...tstarling08:03, 26 July 2010

Status & tagging log