http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70061
Revision: 70061
Author: tstarling
Date: 2010-07-28 02:01:03 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
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/ApiExpandTemplates.php
branches/wmf/1.16wmf4/includes/api/ApiLogout.php
branches/wmf/1.16wmf4/includes/api/ApiMain.php
branches/wmf/1.16wmf4/includes/api/ApiOpenSearch.php
branches/wmf/1.16wmf4/includes/api/ApiParse.php
branches/wmf/1.16wmf4/includes/api/ApiPatrol.php
branches/wmf/1.16wmf4/includes/api/ApiPurge.php
branches/wmf/1.16wmf4/includes/api/ApiQuery.php
branches/wmf/1.16wmf4/includes/api/ApiQueryAllCategories.php
branches/wmf/1.16wmf4/includes/api/ApiQueryAllLinks.php
branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php
branches/wmf/1.16wmf4/includes/api/ApiQueryAllimages.php
branches/wmf/1.16wmf4/includes/api/ApiQueryAllmessages.php
branches/wmf/1.16wmf4/includes/api/ApiQueryAllpages.php
branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php
branches/wmf/1.16wmf4/includes/api/ApiQueryBase.php
branches/wmf/1.16wmf4/includes/api/ApiQueryBlocks.php
branches/wmf/1.16wmf4/includes/api/ApiQueryCategories.php
branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryInfo.php
branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryMembers.php
branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php
branches/wmf/1.16wmf4/includes/api/ApiQueryDuplicateFiles.php
branches/wmf/1.16wmf4/includes/api/ApiQueryExtLinksUsage.php
branches/wmf/1.16wmf4/includes/api/ApiQueryExternalLinks.php
branches/wmf/1.16wmf4/includes/api/ApiQueryImageInfo.php
branches/wmf/1.16wmf4/includes/api/ApiQueryImages.php
branches/wmf/1.16wmf4/includes/api/ApiQueryInfo.php
branches/wmf/1.16wmf4/includes/api/ApiQueryLangLinks.php
branches/wmf/1.16wmf4/includes/api/ApiQueryLinks.php
branches/wmf/1.16wmf4/includes/api/ApiQueryLogEvents.php
branches/wmf/1.16wmf4/includes/api/ApiQueryProtectedTitles.php
branches/wmf/1.16wmf4/includes/api/ApiQueryRandom.php
branches/wmf/1.16wmf4/includes/api/ApiQueryRecentChanges.php
branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php
branches/wmf/1.16wmf4/includes/api/ApiQuerySearch.php
branches/wmf/1.16wmf4/includes/api/ApiQuerySiteinfo.php
branches/wmf/1.16wmf4/includes/api/ApiQueryTags.php
branches/wmf/1.16wmf4/includes/api/ApiQueryUserContributions.php
branches/wmf/1.16wmf4/includes/api/ApiQueryUserInfo.php
branches/wmf/1.16wmf4/includes/api/ApiQueryUsers.php
branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlist.php
branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlistRaw.php
branches/wmf/1.16wmf4/includes/api/ApiWatch.php
Property Changed:
----------------
branches/wmf/1.16wmf4/includes/api/
branches/wmf/1.16wmf4/includes/api/ApiLogin.php
branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php
Property changes on: branches/wmf/1.16wmf4/includes/api
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/api:51646
/branches/sqlite/includes/api:58211-58321
/branches/wmf-deployment/includes/api:53381,59952,60970
/trunk/phase3/includes/api:63549,63764,63897-63901,64454,66486
+ /branches/REL1_15/phase3/includes/api:51646
/branches/REL1_16/phase3/includes/api:69932
/branches/sqlite/includes/api:58211-58321
/branches/wmf-deployment/includes/api:53381,59952,60970
/trunk/phase3/includes/api:63549,63764,63897-63901,64454,66486,69339,69347,69350,69369,69379,69776,69931
Modified: branches/wmf/1.16wmf4/includes/api/ApiExpandTemplates.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiExpandTemplates.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiExpandTemplates.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -42,6 +42,9 @@
}
public function execute() {
+ // Cache may vary on $wgUser because ParserOptions gets data
from it
+ $this->getMain()->setCacheMode( 'anon-public-user-private' );
+
// Get parameters
$params = $this->extractRequestParams();
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiLogin.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/api/ApiLogin.php:51646
/branches/sqlite/includes/api/ApiLogin.php:58211-58321
/branches/wmf-deployment/includes/api/ApiLogin.php:53381,59952,60970
/trunk/phase3/includes/api/ApiLogin.php:63549,63764,63897-63901,64454,64694,66486
+ /branches/REL1_15/phase3/includes/api/ApiLogin.php:51646
/branches/REL1_16/phase3/includes/api/ApiLogin.php:69932
/branches/sqlite/includes/api/ApiLogin.php:58211-58321
/branches/wmf-deployment/includes/api/ApiLogin.php:53381,59952,60970
/trunk/phase3/includes/api/ApiLogin.php:63549,63764,63897-63901,64454,64694,66486
Modified: branches/wmf/1.16wmf4/includes/api/ApiLogout.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiLogout.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiLogout.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -42,7 +42,6 @@
public function execute() {
global $wgUser;
- $this->getMain()->setCachePrivate();
$oldName = $wgUser->getName();
$wgUser->logout();
Modified: branches/wmf/1.16wmf4/includes/api/ApiMain.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiMain.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiMain.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -124,9 +124,10 @@
private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames;
private $mResult, $mAction, $mShowVersions, $mEnableWrite, $mRequest;
- private $mInternalMode, $mSquidMaxage, $mModule, $mVaryCookie;
+ private $mInternalMode, $mSquidMaxage, $mModule;
- private $mCacheControl = array( 'must-revalidate' => true );
+ private $mCacheMode = 'private';
+ private $mCacheControl = array();
/**
* Constructs an instance of ApiMain that utilizes the module and format
specified by $request.
@@ -171,7 +172,6 @@
$this->mSquidMaxage = - 1; // flag for
executeActionWithErrorHandling()
$this->mCommit = false;
- $this->mVaryCookie = false;
}
/**
@@ -222,19 +222,67 @@
's-maxage' => $maxage
) );
}
+
+ /**
+ * Set the type of caching headers which will be sent.
+ *
+ * @param $mode One of:
+ * - 'public': Cache this object in public caches, if the maxage
or smaxage
+ * parameter is set, or if setCacheMaxAge() was called. If a
maximum age is
+ * not provided by any of these means, the object will be
private.
+ * - 'private': Cache this object only in private client-side
caches.
+ * - 'anon-public-user-private': Make this object cacheable for
logged-out
+ * users, but private for logged-in users. IMPORTANT: If this
is set, it must be
+ * set consistently for a given URL, it cannot be set
differently depending on
+ * things like the contents of the database, or whether the
user is logged in.
+ *
+ * If the wiki does not allow anonymous users to read it, the mode set
here
+ * will be ignored, and private caching headers will always be sent.
In other words,
+ * the "public" mode is equivalent to saying that the data sent is as
public as a page
+ * view.
+ *
+ * For user-dependent data, the private mode should generally be used.
The
+ * anon-public-user-private mode should only be used where there is a
particularly
+ * good performance reason for caching the anonymous response, but
where the
+ * response to logged-in users may differ, or may contain private
data.
+ *
+ * If this function is never called, then the default will be the
private mode.
+ */
+ public function setCacheMode( $mode ) {
+ if ( !in_array( $mode, array( 'private', 'public',
'anon-public-user-private' ) ) ) {
+ wfDebug( __METHOD__.": unrecognised cache mode
\"$mode\"\n" );
+ // Ignore for forwards-compatibility
+ return;
+ }
+
+ if ( !in_array( 'read', User::getGroupPermissions( array( '*' )
), true ) ) {
+ // Private wiki, only private headers
+ if ( $mode !== 'private' ) {
+ wfDebug( __METHOD__.": ignoring request for
$mode cache mode, private wiki\n" );
+ return;
+ }
+ }
+
+ wfDebug( __METHOD__.": setting cache mode $mode\n" );
+ $this->mCacheMode = $mode;
+ }
/**
- * Make sure Cache-Control: private is set. Use this when the output of
a request
- * is for the current recipient only and should not be cached in any
shared cache.
+ * @deprecated Private caching is now the default, so there is usually
no
+ * need to call this function. If there is a need, you can use
+ * $this->setCacheMode('private')
*/
public function setCachePrivate() {
- $this->setCacheControl( array( 'private' => true ) );
+ $this->setCacheMode( 'private' );
}
/**
* Set directives (key/value pairs) for the Cache-Control header.
* Boolean values will be formatted as such, by including or omitting
* without an equals sign.
+ *
+ * Cache control values set here will only be used if the cache mode is
not
+ * private, see setCacheMode().
*/
public function setCacheControl( $directives ) {
$this->mCacheControl = $directives + $this->mCacheControl;
@@ -247,27 +295,12 @@
* WARNING: This function must be called CONSISTENTLY for a given URL.
This means that a
* given URL must either always or never call this function; if it
sometimes does and
* sometimes doesn't, stuff will break.
+ *
+ * @deprecated Use setCacheMode( 'anon-public-user-private' )
*/
public function setVaryCookie() {
- $this->mVaryCookie = true;
+ $this->setCacheMode( 'anon-public-user-private' );
}
-
- /**
- * Actually output the Vary: Cookie header and its friends, if flagged
with setVaryCookie().
- * Outputs the appropriate X-Vary-Options header and Cache-Control:
private if needed.
- */
- private function outputVaryCookieHeader() {
- global $wgUseXVO, $wgOut;
- if ( $this->mVaryCookie ) {
- header( 'Vary: Cookie' );
- if ( $wgUseXVO ) {
- header( $wgOut->getXVO() );
- if ( $wgOut->haveCacheVaryCookies() ) {
- $this->setCacheControl( array(
'private' => true ) );
- }
- }
- }
- }
/**
* Create an instance of an output formatter by its name
@@ -318,8 +351,7 @@
$errCode = $this->substituteResultWithError( $e );
// Error results should not be cached
- $this->setCacheMaxAge( 0 );
- $this->setCachePrivate();
+ $this->setCacheMode( 'private' );
$headerStr = 'MediaWiki-API-Error: ' . $errCode;
if ( $e->getCode() === 0 )
@@ -334,12 +366,49 @@
$this->mPrinter->safeProfileOut();
$this->printResult( true );
}
-
- // If this wiki is private, don't cache anything ever
- if ( ! in_array( 'read', User::getGroupPermissions( array( '*'
) ), true ) ) {
- $this->setCachePrivate();
+
+ // Send cache headers after any code which might generate an
error, to
+ // avoid sending public cache headers for errors.
+ $this->sendCacheHeaders();
+
+ if ( $this->mPrinter->getIsHtml() &&
!$this->mPrinter->isDisabled() ) {
+ echo wfReportTime();
}
+ ob_end_flush();
+ }
+
+ protected function sendCacheHeaders() {
+ if ( $this->mCacheMode == 'private' ) {
+ header( 'Cache-Control: private' );
+ return;
+ }
+
+ if ( $this->mCacheMode == 'anon-public-user-private' ) {
+ global $wgUseXVO, $wgOut;
+ header( 'Vary: Accept-Encoding, Cookie' );
+ if ( $wgUseXVO ) {
+ header( $wgOut->getXVO() );
+ if ( $wgOut->haveCacheVaryCookies() ) {
+ // Logged in, mark this request private
+ header( 'Cache-Control: private' );
+ return;
+ }
+ // Logged out, send normal public headers below
+ } elseif ( session_id() != '' ) {
+ // Logged in or otherwise has session (e.g.
anonymous users who have edited)
+ // Mark request private
+ header( 'Cache-Control: private' );
+ return;
+ } // else no XVO and anonymous, send public headers
below
+ } else /* if public */ {
+ // Give a debugging message if the user object is
unstubbed on a public request
+ global $wgUser;
+ if ( !( $wgUser instanceof StubUser ) ) {
+ wfDebug( __METHOD__." \$wgUser is unstubbed on
a public request!\n" );
+ }
+ }
+
// If nobody called setCacheMaxAge(), use the (s)maxage
parameters
if ( !isset( $this->mCacheControl['s-maxage'] ) ) {
$this->mCacheControl['s-maxage'] = $this->getParameter(
'smaxage' );
@@ -348,12 +417,21 @@
$this->mCacheControl['max-age'] = $this->getParameter(
'maxage' );
}
- // 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
- $exp = min( $this->mCacheControl['s-maxage'],
$this->mCacheControl['max-age'] );
- $expires = ( $exp == 0 ? 1 : time() + $exp );
- header( 'Expires: ' . wfTimestamp( TS_RFC2822, $expires ) );
+ if ( !$this->mCacheControl['s-maxage'] &&
!$this->mCacheControl['max-age'] ) {
+ // Public cache not requested
+ // Sending a Vary header in this case is harmless, and
protects us
+ // against conditional calls of setCacheMaxAge().
+ header( 'Cache-Control: private' );
+ return;
+ }
+ $this->mCacheControl['public'] = true;
+
+ // Send an Expires header
+ $maxAge = min( $this->mCacheControl['s-maxage'],
$this->mCacheControl['max-age'] );
+ $expiryUnixTime = ( $maxAge == 0 ? 1 : time() + $maxAge );
+ header( 'Expires: ' . wfTimestamp( TS_RFC2822, $expiryUnixTime
) );
+
// Construct the Cache-Control header
$ccHeader = '';
$separator = '';
@@ -370,12 +448,6 @@
}
header( "Cache-Control: $ccHeader" );
- $this->outputVaryCookieHeader();
-
- if ( $this->mPrinter->getIsHtml() )
- echo wfReportTime();
-
- ob_end_flush();
}
/**
@@ -491,8 +563,7 @@
}
global $wgUser, $wgGroupPermissions;
- if ( $module->isReadMode() && !in_array( 'read',
User::getGroupPermissions( array( '*' ) ), true ) &&
- !$wgUser->isAllowed( 'read' ) )
+ if ( $module->isReadMode() && !in_array( 'read',
User::getGroupPermissions( array( '*' ) ), true ) && !$wgUser->isAllowed(
'read' ) )
$this->dieUsageMsg( array( 'readrequired' ) );
if ( $module->isWriteMode() ) {
if ( !$this->mEnableWrite )
Modified: branches/wmf/1.16wmf4/includes/api/ApiOpenSearch.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiOpenSearch.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiOpenSearch.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -56,7 +56,7 @@
// Open search results may be stored for a very long
// time
$this->getMain()->setCacheMaxAge(
$wgSearchSuggestCacheExpiry );
- $this->getMain()->setCacheControl( array(
'must-revalidate' => false ) );
+ $this->getMain()->setCacheMode( 'public' );
$srchres = PrefixSearch::titleSearch( $search, $limit,
$namespaces );
Modified: branches/wmf/1.16wmf4/includes/api/ApiParse.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiParse.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiParse.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -38,6 +38,9 @@
}
public function execute() {
+ // The data is hot but user-dependent, like page views, so we
set vary cookies
+ $this->getMain()->setCacheMode( 'anon-public-user-private' );
+
// Get parameters
$params = $this->extractRequestParams();
$text = $params['text'];
@@ -118,11 +121,10 @@
if ( !$titleObj )
$titleObj = Title::newFromText( "API" );
$wgTitle = $titleObj;
- if ( $params['pst'] || $params['onlypst'] ) {
+ if ( $params['pst'] || $params['onlypst'] )
$text = $wgParser->preSaveTransform( $text,
$titleObj, $wgUser, $popts );
- $this->getMain()->setVaryCookie();
- }
- if ( $params['onlypst'] ) {
+ if ( $params['onlypst'] )
+ {
// Build a result and bail out
$result_array['text'] = array();
$this->getResult()->setContent(
$result_array['text'], $text );
@@ -145,7 +147,6 @@
if ( !is_null( $params['summary'] ) ) {
$result_array['parsedsummary'] = array();
- $this->getMain()->setVaryCookie();
$result->setContent( $result_array['parsedsummary'],
$wgUser->getSkin()->formatComment( $params['summary'], $titleObj ) );
}
@@ -174,7 +175,6 @@
if ( isset( $prop['headhtml'] ) ) {
$out = new OutputPage;
$out->addParserOutputNoText( $p_result );
- $this->getMain()->setVaryCookie();
$result_array['headhtml'] = array();
$result->setContent( $result_array['headhtml'],
$out->headElement( $wgUser->getSkin() ) );
}
Modified: branches/wmf/1.16wmf4/includes/api/ApiPatrol.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiPatrol.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiPatrol.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -41,7 +41,6 @@
* Patrols the article or provides the reason the patrol failed.
*/
public function execute() {
- $this->getMain()->setCachePrivate();
$params = $this->extractRequestParams();
if ( !isset( $params['rcid'] ) )
Modified: branches/wmf/1.16wmf4/includes/api/ApiPurge.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiPurge.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiPurge.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -42,7 +42,6 @@
*/
public function execute() {
global $wgUser;
- $this->getMain()->setCachePrivate();
$params = $this->extractRequestParams();
if ( !$wgUser->isAllowed( 'purge' ) )
$this->dieUsageMsg( array( 'cantpurge' ) );
Modified: branches/wmf/1.16wmf4/includes/api/ApiQuery.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQuery.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQuery.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -206,9 +206,15 @@
$this->InstantiateModules( $modules, 'list',
$this->mQueryListModules );
$this->InstantiateModules( $modules, 'meta',
$this->mQueryMetaModules );
+ $cacheMode = 'public';
+
// If given, execute generator to substitute user supplied data
with generated data.
if ( isset ( $this->params['generator'] ) ) {
- $this->executeGeneratorModule(
$this->params['generator'], $modules );
+ $generator = $this->newGenerator(
$this->params['generator'] );
+ $params = $generator->extractRequestParams();
+ $cacheMode = $this->mergeCacheMode( $cacheMode,
+ $generator->getCacheMode( $params ) );
+ $this->executeGeneratorModule( $generator, $modules );
} else {
// Append custom fields and populate page/revision
information
$this->addCustomFldsToPageSet( $modules,
$this->mPageSet );
@@ -220,14 +226,38 @@
// Execute all requested modules.
foreach ( $modules as $module ) {
+ $params = $module->extractRequestParams();
+ $cacheMode = $this->mergeCacheMode(
+ $cacheMode, $module->getCacheMode( $params ) );
$module->profileIn();
$module->execute();
wfRunHooks( 'APIQueryAfterExecute', array( &$module ) );
$module->profileOut();
}
+
+ // Set the cache mode
+ $this->getMain()->setCacheMode( $cacheMode );
}
/**
+ * Update a cache mode string, applying the cache mode of a new module
to it.
+ * The cache mode may increase in the level of privacy, but public
modules
+ * added to private data do not decrease the level of privacy.
+ */
+ protected function mergeCacheMode( $cacheMode, $modCacheMode ) {
+ if ( $modCacheMode === 'anon-public-user-private' ) {
+ if ( $cacheMode !== 'private' ) {
+ $cacheMode = 'anon-public-user-private';
+ }
+ } elseif ( $modCacheMode === 'public' ) {
+ // do nothing, if it's public already it will stay
public
+ } else { // private
+ $cacheMode = 'private';
+ }
+ return $cacheMode;
+ }
+
+ /**
* Query modules may optimize data requests through the
$this->getPageSet() object
* by adding extra fields from the page table.
* This function will gather all the extra request fields from the
modules.
@@ -401,12 +431,9 @@
}
/**
- * For generator mode, execute generator, and use its output as new
- * ApiPageSet
- * @param $generatorName string Module name
- * @param $modules array of module objects
+ * Create a generator object of the given type and return it
*/
- protected function executeGeneratorModule( $generatorName, $modules ) {
+ public function newGenerator( $generatorName ) {
// Find class that implements requested generator
if ( isset ( $this->mQueryListModules[$generatorName] ) ) {
@@ -424,9 +451,20 @@
$generator = new $className ( $this, $generatorName );
if ( !$generator instanceof ApiQueryGeneratorBase )
$this->dieUsage( "Module $generatorName cannot be used
as a generator", "badgenerator" );
-
$generator->setGeneratorMode();
+ return $generator;
+ }
+ /**
+ * For generator mode, execute generator, and use its output as new
+ * ApiPageSet
+ * @param $generatorName string Module name
+ * @param $modules array of module objects
+ */
+ protected function executeGeneratorModule( $generator, $modules ) {
+ // Generator results
+ $resultPageSet = new ApiPageSet( $this, $this->redirects,
$this->convertTitles );
+
// Add any additional fields modules may need
$generator->requestExtraData( $this->mPageSet );
$this->addCustomFldsToPageSet( $modules, $resultPageSet );
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryAllCategories.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryAllCategories.php
2010-07-28 00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryAllCategories.php
2010-07-28 02:01:03 UTC (rev 70061)
@@ -44,6 +44,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
@@ -177,4 +181,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryAllLinks.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryAllLinks.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryAllLinks.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -43,6 +43,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
@@ -207,4 +211,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -189,6 +189,10 @@
$result->setIndexedTagName_internal( array( 'query',
$this->getModuleName() ), 'u' );
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function getAllowedParams() {
return array (
'from' => null,
@@ -242,4 +246,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Property changes on: branches/wmf/1.16wmf4/includes/api/ApiQueryAllUsers.php
___________________________________________________________________
Added: svn:mergeinfo
+
/trunk/phase3/includes/api/ApiQueryAllUsers.php:69339,69347,69350,69369,69379,69776,69931
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryAllimages.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryAllimages.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryAllimages.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -55,6 +55,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
if ( $resultPageSet->isResolvingRedirects() )
$this->dieUsage( 'Use "gaifilterredir=nonredirects"
option instead of "redirects" when using allimages as a generator', 'params' );
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryAllmessages.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryAllmessages.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryAllmessages.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -46,9 +46,6 @@
{
global $wgLang;
$wgLang = Language::factory( $params['lang'] );
- } else if ( is_null( $params['lang'] ) ) {
- // Language not determined by URL but by user
preferences, so don't cache
- $this->getMain()->setVaryCookie();
}
$prop = array_flip( (array)$params['prop'] );
@@ -123,6 +120,19 @@
$result->setIndexedTagName_internal( array( 'query',
$this->getModuleName() ), 'message' );
}
+ public function getCacheMode( $params ) {
+ if ( is_null( $params['lang'] ) ) {
+ // Language not specified, will be fetched from
preferences
+ return 'anon-public-user-private';
+ } elseif ( $params['enableparser'] ) {
+ // User-specific parser options will be used
+ return 'anon-public-user-private';
+ } else {
+ // OK to cache
+ return 'public';
+ }
+ }
+
public function getAllowedParams() {
return array (
'messages' => array (
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryAllpages.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryAllpages.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryAllpages.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -43,6 +43,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
if ( $resultPageSet->isResolvingRedirects() )
$this->dieUsage( 'Use "gapfilterredir=nonredirects"
option instead of "redirects" when using allpages as a generator', 'params' );
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryBacklinks.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -92,6 +92,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryBase.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryBase.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryBase.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -47,6 +47,17 @@
}
/**
+ * Get the cache mode for the data generated by this module. Override
this
+ * in the module subclass.
+ *
+ * Public caching will only be allowed if *all* the modules that supply
+ * data for a given request return a cache mode of public.
+ */
+ public function getCacheMode( $params ) {
+ return 'private';
+ }
+
+ /**
* Blank the internal arrays with query parameters
*/
protected function resetQueryParams() {
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryBlocks.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryBlocks.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryBlocks.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -121,9 +121,6 @@
'ipb_auto' => 0
) );
}
-
- // Make sure private data (deleted blocks) isn't cached
- $this->getMain()->setVaryCookie();
if ( !$wgUser->isAllowed( 'hideuser' ) )
$this->addWhereFld( 'ipb_deleted', 0 );
@@ -283,4 +280,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
+}
\ No newline at end of file
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryCategories.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryCategories.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryCategories.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -43,6 +43,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryInfo.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryInfo.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryInfo.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -99,6 +99,10 @@
$db->freeResult( $res );
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function getAllowedParams() {
return array (
'continue' => null,
@@ -122,4 +126,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryMembers.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryMembers.php
2010-07-28 00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryCategoryMembers.php
2010-07-28 02:01:03 UTC (rev 70061)
@@ -43,6 +43,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryDeletedrevs.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -42,7 +42,6 @@
public function execute() {
global $wgUser;
- $this->getMain()->setVaryCookie();
// Before doing anything at all, let's check permissions
if ( !$wgUser->isAllowed( 'deletedhistory' ) )
$this->dieUsage( 'You don\'t have permission to view
deleted revision information', 'permissiondenied' );
@@ -200,7 +199,6 @@
if ( $fld_parsedcomment ) {
global $wgUser;
- $this->getMain()->setVaryCookie();
$rev['parsedcomment'] =
$wgUser->getSkin()->formatComment( $row->ar_comment, $title );
}
if ( $fld_minor && $row->ar_minor_edit == 1 )
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryDuplicateFiles.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryDuplicateFiles.php
2010-07-28 00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryDuplicateFiles.php
2010-07-28 02:01:03 UTC (rev 70061)
@@ -43,6 +43,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryExtLinksUsage.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryExtLinksUsage.php
2010-07-28 00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryExtLinksUsage.php
2010-07-28 02:01:03 UTC (rev 70061)
@@ -41,6 +41,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
@@ -218,4 +222,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryExternalLinks.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryExternalLinks.php
2010-07-28 00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryExternalLinks.php
2010-07-28 02:01:03 UTC (rev 70061)
@@ -83,6 +83,10 @@
$db->freeResult( $res );
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function getAllowedParams() {
return array(
'limit' => array(
@@ -117,4 +121,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryImageInfo.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryImageInfo.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryImageInfo.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -244,6 +244,10 @@
return $retval;
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
private function getContinueStr( $img )
{
return $img->getOriginalTitle()->getText() .
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryImages.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryImages.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryImages.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -122,6 +122,10 @@
$db->freeResult( $res );
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function getAllowedParams() {
return array(
'limit' => array(
@@ -164,4 +168,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryInfo.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryInfo.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryInfo.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -244,7 +244,6 @@
$this->getProtectionInfo();
if ( $this->fld_watched )
- $this->getMain()->setVaryCookie();
$this->getWatchedInfo();
// Run the talkid/subjectid query if requested
@@ -289,9 +288,6 @@
}
if ( !is_null( $this->params['token'] ) ) {
- // Don't cache tokens
- $this->getMain()->setCachePrivate();
-
$tokenFunctions = $this->getTokenFunctions();
$pageInfo['starttimestamp'] = wfTimestamp( TS_ISO_8601,
time() );
foreach ( $this->params['token'] as $t )
@@ -557,6 +553,27 @@
}
}
+ public function getCacheMode( $params ) {
+ $publicProps = array(
+ 'protection',
+ 'talkid',
+ 'subjectid',
+ 'url',
+ 'preload',
+ );
+ if ( !is_null( $params['prop'] ) ) {
+ foreach ( $params['prop'] as $prop ) {
+ if ( !in_array( $prop, $publicProps ) ) {
+ return 'private';
+ }
+ }
+ }
+ if ( !is_null( $params['token'] ) ) {
+ return 'private';
+ }
+ return 'public';
+ }
+
public function getAllowedParams() {
return array (
'prop' => array (
@@ -565,11 +582,13 @@
ApiBase :: PARAM_TYPE => array (
'protection',
'talkid',
- 'watched',
+ 'watched', # private
'subjectid',
'url',
- 'readable',
+ 'readable', # private
'preload'
+ // If you add more properties here,
please consider whether they
+ // need to be added to getCacheMode()
) ),
'token' => array (
ApiBase :: PARAM_DFLT => null,
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryLangLinks.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryLangLinks.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryLangLinks.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -93,6 +93,10 @@
$db->freeResult( $res );
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function getAllowedParams() {
return array(
'limit' => array(
@@ -133,4 +137,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryLinks.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryLinks.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryLinks.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -64,6 +64,10 @@
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
@@ -206,4 +210,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryLogEvents.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryLogEvents.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryLogEvents.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -267,7 +267,6 @@
if ( $this->fld_parsedcomment ) {
global $wgUser;
- $this->getMain()->setVaryCookie();
$vals['parsedcomment'] =
$wgUser->getSkin()->formatComment( $row->log_comment, $title );
}
}
@@ -286,6 +285,15 @@
return $vals;
}
+ public function getCacheMode( $params ) {
+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment',
$params['prop'] ) ) {
+ // formatComment() calls wfMsg() among other things
+ return 'anon-public-user-private';
+ } else {
+ return 'public';
+ }
+ }
+
public function getAllowedParams() {
global $wgLogTypes;
return array (
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryProtectedTitles.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryProtectedTitles.php
2010-07-28 00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryProtectedTitles.php
2010-07-28 02:01:03 UTC (rev 70061)
@@ -100,7 +100,6 @@
if ( isset( $prop['parsedcomment'] ) ) {
global $wgUser;
- $this->getMain()->setVaryCookie();
$vals['parsedcomment'] =
$wgUser->getSkin()->formatComment( $row->pt_reason, $title );
}
@@ -127,6 +126,15 @@
$resultPageSet->populateFromTitles( $titles );
}
+ public function getCacheMode( $params ) {
+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment',
$params['prop'] ) ) {
+ // formatComment() calls wfMsg() among other things
+ return 'anon-public-user-private';
+ } else {
+ return 'public';
+ }
+ }
+
public function getAllowedParams() {
global $wgRestrictionLevels;
return array (
@@ -198,4 +206,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryRandom.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryRandom.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryRandom.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -121,6 +121,10 @@
return $vals;
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function getAllowedParams() {
return array (
'namespace' => array(
@@ -161,4 +165,4 @@
public function getVersion() {
return __CLASS__ . ': $Id: ApiQueryRandom.php overlordq$';
}
-}
\ No newline at end of file
+}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryRecentChanges.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryRecentChanges.php
2010-07-28 00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryRecentChanges.php
2010-07-28 02:01:03 UTC (rev 70061)
@@ -137,12 +137,8 @@
// Check permissions
global $wgUser;
- if ( isset( $show['patrolled'] ) || isset(
$show['!patrolled'] ) ) {
- $this->getMain()->setVaryCookie();
- if ( !$wgUser->useRCPatrol() &&
!$wgUser->useNPPatrol() ) {
- $this->dieUsage( 'You need the patrol
right to request the patrolled flag', 'permissiondenied' );
- }
- }
+ if ( ( isset( $show['patrolled'] ) || isset(
$show['!patrolled'] ) ) && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() )
+ $this->dieUsage( "You need the patrol right to
request the patrolled flag", 'permissiondenied' );
/* Add additional conditions to query depending upon
parameters. */
$this->addWhereIf( 'rc_minor = 0', isset (
$show['!minor'] ) );
@@ -362,7 +358,6 @@
if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
global $wgUser;
- $this->getMain()->setVaryCookie();
$vals['parsedcomment'] =
$wgUser->getSkin()->formatComment( $row->rc_comment, $title );
}
@@ -395,9 +390,6 @@
if ( !is_null( $this->token ) )
{
- // Don't cache tokens
- $this->getMain()->setCachePrivate();
-
$tokenFunctions = $this->getTokenFunctions();
foreach ( $this->token as $t )
{
@@ -430,6 +422,24 @@
}
}
+ public function getCacheMode( $params ) {
+ if ( isset( $params['show'] ) ) {
+ foreach ( $params['show'] as $show ) {
+ if ( $show === 'patrolled' || $show ===
'!patrolled' ) {
+ return 'private';
+ }
+ }
+ }
+ if ( isset( $params['token'] ) ) {
+ return 'private';
+ }
+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment',
$params['prop'] ) ) {
+ // formatComment() calls wfMsg() among other things
+ return 'anon-public-user-private';
+ }
+ return 'public';
+ }
+
public function getAllowedParams() {
return array (
'start' => array (
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryRevisions.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -378,7 +378,6 @@
if ( $this->fld_parsedcomment ) {
global $wgUser;
-
$this->getMain()->setVaryCookie();
$vals['parsedcomment'] =
$wgUser->getSkin()->formatComment( $comment, $title );
}
}
@@ -397,9 +396,6 @@
if ( !is_null( $this->token ) )
{
- // Don't cache tokens
- $this->getMain()->setCachePrivate();
-
$tokenFunctions = $this->getTokenFunctions();
foreach ( $this->token as $t )
{
@@ -468,6 +464,17 @@
return $vals;
}
+ public function getCacheMode( $params ) {
+ if ( isset( $params['token'] ) ) {
+ return 'private';
+ }
+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment',
$params['prop'] ) ) {
+ // formatComment() calls wfMsg() among other things
+ return 'anon-public-user-private';
+ }
+ return 'public';
+ }
+
public function getAllowedParams() {
return array (
'prop' => array (
Modified: branches/wmf/1.16wmf4/includes/api/ApiQuerySearch.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQuerySearch.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQuerySearch.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -155,6 +155,10 @@
}
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function getAllowedParams() {
return array (
'search' => null,
Modified: branches/wmf/1.16wmf4/includes/api/ApiQuerySiteinfo.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQuerySiteinfo.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQuerySiteinfo.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -421,6 +421,9 @@
return $this->getResult()->addValue( 'query', $property, $data
);
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
public function getAllowedParams() {
return array(
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryTags.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryTags.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryTags.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -129,6 +129,10 @@
return true;
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function getAllowedParams() {
return array (
'continue' => array(
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryUserContributions.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryUserContributions.php
2010-07-28 00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryUserContributions.php
2010-07-28 02:01:03 UTC (rev 70061)
@@ -164,8 +164,6 @@
"rev_timestamp $op= '$encTS')" );
}
- // Make sure private data (deleted revisions) isn't cached
- $this->getMain()->setVaryCookie();
if ( !$wgUser->isAllowed( 'hideuser' ) )
$this->addWhere( $this->getDB()->bitAnd( 'rev_deleted',
Revision::DELETED_USER ) . ' = 0' );
// We only want pages by the specified users.
@@ -212,12 +210,8 @@
$this->fld_patrolled )
{
global $wgUser;
- // Don't cache private data
- $this->getMain()->setVaryCookie();
- if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol()
) {
- $this->dieUsage( 'You need the patrol right to
request the patrolled flag', 'permissiondenied' );
- }
-
+ if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol()
)
+ $this->dieUsage( "You need the patrol right to
request the patrolled flag", 'permissiondenied' );
// Use a redundant join condition on both
// timestamp and ID so we can use the timestamp
// index
@@ -314,7 +308,6 @@
if ( $this->fld_parsedcomment ) {
global $wgUser;
- $this->getMain()->setVaryCookie();
$vals['parsedcomment'] =
$wgUser->getSkin()->formatComment( $row->rev_comment, $title );
}
}
@@ -345,6 +338,12 @@
wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
}
+ public function getCacheMode( $params ) {
+ // This module provides access to deleted revisions and patrol
flags if
+ // the requester is logged in
+ return 'anon-public-user-private';
+ }
+
public function getAllowedParams() {
return array (
'limit' => array (
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryUserInfo.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryUserInfo.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryUserInfo.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -40,7 +40,6 @@
}
public function execute() {
- $this->getMain()->setCachePrivate();
$params = $this->extractRequestParams();
$result = $this->getResult();
$r = array();
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryUsers.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryUsers.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryUsers.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -156,9 +156,6 @@
if ( !is_null( $params['token'] ) )
{
- // Don't cache tokens
- $this->getMain()->setCachePrivate();
-
$tokenFunctions =
$this->getTokenFunctions();
foreach ( $params['token'] as $t )
{
@@ -210,6 +207,14 @@
return $this->getResult()->setIndexedTagName_internal( array(
'query', $this->getModuleName() ), 'user' );
}
+ public function getCacheMode( $params ) {
+ if ( isset( $params['token'] ) ) {
+ return 'private';
+ } else {
+ return 'public';
+ }
+ }
+
public function getAllowedParams() {
return array (
'prop' => array (
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlist.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlist.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlist.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -68,14 +68,9 @@
if ( $token == '' || $token != $params['token'] ) {
$this->dieUsage( 'Incorrect watchlist token
provided -- please set a correct token in Special:Preferences', 'bad_wltoken' );
}
+ } elseif ( !$wgUser->isLoggedIn() ) {
+ $this->dieUsage( 'You must be logged-in to have a
watchlist', 'notloggedin' );
} else {
- // Temp live hack until new code using
getWatchlistUser() is deployed
-
- // User not determined by URL, so don't cache
- $this->getMain()->setVaryCookie();
- if ( !$wgUser->isLoggedIn() ) {
- $this->dieUsage( 'You must be logged-in to have
a watchlist', 'notloggedin' );
- }
$user = $wgUser;
}
@@ -95,7 +90,6 @@
$this->fld_notificationtimestamp = isset(
$prop['notificationtimestamp'] );
if ( $this->fld_patrol ) {
- $this->getMain()->setVaryCookie();
if ( !$user->useRCPatrol() &&
!$user->useNPPatrol() )
$this->dieUsage( 'patrol property is
not available', 'patrol' );
}
@@ -160,13 +154,9 @@
$this->dieUsageMsg( array( 'show' ) );
}
- // Check permissions. FIXME: should this check $user
instead of $wgUser?
- if ( isset( $show['patrolled'] ) || isset(
$show['!patrolled'] ) ) {
- $this->getMain()->setVaryCookie();
- if ( !$wgUser->useRCPatrol() &&
!$wgUser->useNPPatrol() ) {
- $this->dieUsage( 'You need the patrol
right to request the patrolled flag', 'permissiondenied' );
- }
- }
+ // Check permissions.
+ if ( ( isset( $show['patrolled'] ) || isset(
$show['!patrolled'] ) ) && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() )
+ $this->dieUsage( "You need the patrol right to
request the patrolled flag", 'permissiondenied' );
/* Add additional conditions to query depending upon
parameters. */
$this->addWhereIf( 'rc_minor = 0', isset (
$show['!minor'] ) );
@@ -282,7 +272,6 @@
if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
global $wgUser;
- $this->getMain()->setVaryCookie();
$vals['parsedcomment'] =
$wgUser->getSkin()->formatComment( $row->rc_comment, $title );
}
Modified: branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlistRaw.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlistRaw.php 2010-07-28
00:44:57 UTC (rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiQueryWatchlistRaw.php 2010-07-28
02:01:03 UTC (rev 70061)
@@ -65,7 +65,6 @@
$this->addFields( array( 'wl_namespace', 'wl_title' ) );
$this->addFieldsIf( 'wl_notificationtimestamp', isset(
$prop['changed'] ) );
$this->addWhereFld( 'wl_user', $wgUser->getId() );
- $this->getMain()->setVaryCookie(); // Temp live hack until new
code using getWatchlistUser() is merged
$this->addWhereFld( 'wl_namespace', $params['namespace'] );
$this->addWhereIf( 'wl_notificationtimestamp IS NOT NULL',
isset( $show['changed'] ) );
$this->addWhereIf( 'wl_notificationtimestamp IS NULL', isset(
$show['!changed'] ) );
@@ -189,4 +188,4 @@
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
+}
\ No newline at end of file
Modified: branches/wmf/1.16wmf4/includes/api/ApiWatch.php
===================================================================
--- branches/wmf/1.16wmf4/includes/api/ApiWatch.php 2010-07-28 00:44:57 UTC
(rev 70060)
+++ branches/wmf/1.16wmf4/includes/api/ApiWatch.php 2010-07-28 02:01:03 UTC
(rev 70061)
@@ -41,7 +41,6 @@
public function execute() {
global $wgUser;
- $this->getMain()->setCachePrivate();
if ( !$wgUser->isLoggedIn() )
$this->dieUsage( 'You must be logged-in to have a
watchlist', 'notloggedin' );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs