83 $this->mCacheDuration = null;
87 $this->mDisabled =
false;
89 $this->mResponseCode = 200;
90 $this->mLastModified =
false;
91 $this->mContentType =
'application/x-wiki';
103 $this->mCacheDuration = $duration;
111 $this->mVary = $vary;
119 $this->mResponseCode =
$code;
127 $this->mContentType =
$type;
134 $this->mDisabled =
true;
142 if ( !$this->mDisabled && $text ) {
143 $this->mText .= $text;
151 if ( !$this->mDisabled ) {
160 if ( $this->mResponseCode ) {
165 $n = intval( trim( $this->mResponseCode ) );
169 header(
"Content-Type: " . $this->mContentType );
171 if ( $this->mLastModified ) {
172 header(
"Last-Modified: " . $this->mLastModified );
174 header(
"Last-Modified: " . gmdate(
"D, d M Y H:i:s" ) .
" GMT" );
177 if ( $this->mCacheDuration ) {
178 # If CDN caches are configured, tell them to cache the response,
179 # and tell the client to always check with the CDN. Otherwise,
180 # tell the client to use a cached copy, without a way to purge it.
182 if ( $this->mConfig->get(
'UseSquid' ) ) {
183 # Expect explicit purge of the proxy cache, but require end user agents
184 # to revalidate against the proxy on each visit.
185 # Surrogate-Control controls our CDN, Cache-Control downstream caches
187 if ( $this->mConfig->get(
'UseESI' ) ) {
188 header(
'Surrogate-Control: max-age=' . $this->mCacheDuration .
', content="ESI/1.0"' );
189 header(
'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
191 header(
'Cache-Control: s-maxage=' . $this->mCacheDuration .
', must-revalidate, max-age=0' );
195 # Let the client do the caching. Cache is not purged.
196 header(
"Expires: " . gmdate(
"D, d M Y H:i:s", time() + $this->mCacheDuration ) .
" GMT" );
197 header(
"Cache-Control: s-maxage={$this->mCacheDuration}," .
198 "public,max-age={$this->mCacheDuration}" );
202 # always expired, always modified
203 header(
"Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
204 header(
"Cache-Control: no-cache, must-revalidate" );
205 header(
"Pragma: no-cache" );
208 if ( $this->mVary ) {
209 header(
"Vary: " . $this->mVary );
223 $fname =
'AjaxResponse::checkLastModified';
226 wfDebug(
"$fname: CACHE DISABLED, NO TIMESTAMP",
'private' );
230 if ( !$wgCachePages ) {
231 wfDebug(
"$fname: CACHE DISABLED",
'private' );
238 if ( !empty( $_SERVER[
'HTTP_IF_MODIFIED_SINCE'] ) ) {
239 # IE sends sizes after the date like this:
240 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
241 # this breaks strtotime().
242 $modsince = preg_replace(
'/;.*$/',
'', $_SERVER[
"HTTP_IF_MODIFIED_SINCE"] );
243 $modsinceTime = strtotime( $modsince );
245 wfDebug(
"$fname: -- client send If-Modified-Since: $modsince",
'private' );
246 wfDebug(
"$fname: -- we might send Last-Modified : $lastmod",
'private' );
249 && $wgUser->validateCache( $ismodsince ) &&
252 ini_set(
'zlib.output_compression', 0 );
255 $this->mLastModified = $lastmod;
257 wfDebug(
"$fname: CACHED client: $ismodsince ; user: {$wgUser->getTouched()} ; " .
258 "page: $timestamp ; site $wgCacheEpoch",
'private' );
262 wfDebug(
"$fname: READY client: $ismodsince ; user: {$wgUser->getTouched()} ; " .
263 "page: $timestamp ; site $wgCacheEpoch",
'private' );
264 $this->mLastModified = $lastmod;
267 wfDebug(
"$fname: client did not send If-Modified-Since header",
'private' );
268 $this->mLastModified = $lastmod;
285 # Check to see if the value has been invalidated
286 if ( $touched <= $mcvalue[
'timestamp'] ) {
287 wfDebug(
"Got $mckey from cache" );
288 $this->mText = $mcvalue[
'value'];
292 wfDebug(
"$mckey has expired" );
308 'value' => $this->mText
sendHeaders()
Construct the header and output it.
static getMainWANInstance()
Get the main WAN cache object.
static header($code)
Output an HTTP status code header.
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
$mLastModified
Date for the HTTP header Last-modified.
when a variable name is used in a it is silently declared as a new local masking the global
$mResponseCode
HTTP response code.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
setContentType($type)
Set the HTTP header Content-Type.
loadFromMemcached($mckey, $touched)
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
$wgCachePages
Allow client-side caching of pages.
Handle responses for Ajax requests (send headers, print content, that sort of thing) ...
checkLastModified($timestamp)
checkLastModified tells the client to use the client-cached response if possible. ...
$mText
Content of our HTTP response.
$mDisabled
Disables output.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
static getDefaultInstance()
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined...
$mContentType
HTTP header Content-Type.
__construct($text=null, Config $config=null)
setResponseCode($code)
Set the HTTP response code.
addText($text)
Add content to the response.
storeInMemcached($mckey, $expiry=86400)
$wgCacheEpoch
Set this to current time to invalidate all prior cached pages.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
$mCacheDuration
Number of seconds to get the response cached by a proxy.
setVary($vary)
Set the HTTP Vary header.
setCacheDuration($duration)
Set the number of seconds to get the response cached by a proxy.