Go to the documentation of this file.
77 $this->mCacheDuration =
null;
80 $this->mDisabled =
false;
82 $this->mResponseCode =
'200 OK';
83 $this->mLastModified =
false;
84 $this->mContentType =
'application/x-wiki';
96 $this->mCacheDuration = $duration;
104 $this->mVary = $vary;
112 $this->mResponseCode = $code;
120 $this->mContentType =
$type;
127 $this->mDisabled =
true;
135 if ( ! $this->mDisabled && $text ) {
136 $this->mText .= $text;
144 if ( ! $this->mDisabled ) {
153 global $wgUseSquid, $wgUseESI;
155 if ( $this->mResponseCode ) {
156 $n = preg_replace(
'/^ *(\d+)/',
'\1', $this->mResponseCode );
157 header(
"Status: " . $this->mResponseCode,
true, (
int)
$n );
160 header (
"Content-Type: " . $this->mContentType );
162 if ( $this->mLastModified ) {
163 header (
"Last-Modified: " . $this->mLastModified );
165 header (
"Last-Modified: " . gmdate(
"D, d M Y H:i:s" ) .
" GMT" );
168 if ( $this->mCacheDuration ) {
169 # If squid caches are configured, tell them to cache the response,
170 # and tell the client to always check with the squid. Otherwise,
171 # tell the client to use a cached copy, without a way to purge it.
174 # Expect explicit purge of the proxy cache, but require end user agents
175 # to revalidate against the proxy on each visit.
176 # Surrogate-Control controls our Squid, Cache-Control downstream caches
179 header(
'Surrogate-Control: max-age=' . $this->mCacheDuration .
', content="ESI/1.0"' );
180 header(
'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
182 header(
'Cache-Control: s-maxage=' . $this->mCacheDuration .
', must-revalidate, max-age=0' );
186 # Let the client do the caching. Cache is not purged.
187 header (
"Expires: " . gmdate(
"D, d M Y H:i:s", time() + $this->mCacheDuration ) .
" GMT" );
188 header (
"Cache-Control: s-maxage={$this->mCacheDuration}," .
189 "public,max-age={$this->mCacheDuration}" );
193 # always expired, always modified
194 header (
"Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
195 header (
"Cache-Control: no-cache, must-revalidate" );
196 header (
"Pragma: no-cache" );
199 if ( $this->mVary ) {
200 header (
"Vary: " . $this->mVary );
214 $fname =
'AjaxResponse::checkLastModified';
217 wfDebug(
"$fname: CACHE DISABLED, NO TIMESTAMP\n",
'log' );
221 if ( !$wgCachePages ) {
222 wfDebug(
"$fname: CACHE DISABLED\n",
'log' );
229 if ( !empty( $_SERVER[
'HTTP_IF_MODIFIED_SINCE'] ) ) {
230 # IE sends sizes after the date like this:
231 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
232 # this breaks strtotime().
233 $modsince = preg_replace(
'/;.*$/',
'', $_SERVER[
"HTTP_IF_MODIFIED_SINCE"] );
234 $modsinceTime = strtotime( $modsince );
236 wfDebug(
"$fname: -- client send If-Modified-Since: " . $modsince .
"\n",
'log' );
237 wfDebug(
"$fname: -- we might send Last-Modified : $lastmod\n",
'log' );
240 &&
$wgUser->validateCache( $ismodsince ) &&
241 $ismodsince >= $wgCacheEpoch
243 ini_set(
'zlib.output_compression', 0 );
246 $this->mLastModified = $lastmod;
248 wfDebug(
"$fname: CACHED client: $ismodsince ; user: {$wgUser->getTouched()} ; " .
249 "page: $timestamp ; site $wgCacheEpoch\n",
'log' );
253 wfDebug(
"$fname: READY client: $ismodsince ; user: {$wgUser->getTouched()} ; " .
254 "page: $timestamp ; site $wgCacheEpoch\n",
'log' );
255 $this->mLastModified = $lastmod;
258 wfDebug(
"$fname: client did not send If-Modified-Since header\n",
'log' );
259 $this->mLastModified = $lastmod;
276 $mcvalue =
$wgMemc->get( $mckey );
278 # Check to see if the value has been invalidated
279 if ( $touched <= $mcvalue[
'timestamp'] ) {
280 wfDebug(
"Got $mckey from cache\n" );
281 $this->mText = $mcvalue[
'value'];
285 wfDebug(
"$mckey has expired\n" );
303 'value' => $this->mText
string $mText
Content of our HTTP response $mText.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
setResponseCode( $code)
Set the HTTP response code.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
checkLastModified( $timestamp)
checkLastModified tells the client to use the client-cached response if possible.
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
string $mContentType
HTTP header Content-Type $mContentType.
loadFromMemcached( $mckey, $touched)
string $mResponseCode
HTTP response code $mResponseCode.
setContentType( $type)
Set the HTTP header Content-Type.
string $mVary
HTTP Vary header $mVary.
setVary( $vary)
Set the HTTP Vary header.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
addText( $text)
Add content to the response.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
string false $mLastModified
Date for the HTTP header Last-modified $mLastModified.
Handle responses for Ajax requests (send headers, print content, that sort of thing)
storeInMemcached( $mckey, $expiry=86400)
setCacheDuration( $duration)
Set the number of seconds to get the response cached by a proxy.
sendHeaders()
Construct the header and output it.
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
bool $mDisabled
Disables output.
int $mCacheDuration
Number of seconds to get the response cached by a proxy $mCacheDuration.