Go to the documentation of this file.
44 parent::__construct();
47 if ( !in_array( $action, $allowedTypes ) ) {
48 throw new MWException(
'Invalid file cache type given.' );
51 ?
$title->getPrefixedDBkey()
53 $this->mType = (string)$action;
62 return [
'view',
'history' ];
80 if ( $this->mType ===
'view' ) {
83 return $this->mType .
'/';
94 $config = MediaWikiServices::getInstance()->getMainConfig();
101 $queryVals =
$context->getRequest()->getValues();
102 foreach ( $queryVals as $query => $val ) {
103 if ( $query ===
'title' || $query ===
'curid' ) {
106 } elseif ( $query ===
'action' && in_array( $val, self::cacheablePageActions() ) ) {
109 } elseif ( $query ===
'maxage' || $query ===
'smaxage' ) {
122 if ( $user->getId() ||
123 !$ulang->equals( MediaWikiServices::getInstance()->getContentLanguage() ) ) {
127 if ( ( $mode === self::MODE_NORMAL ) && $user->getNewtalk() ) {
142 $config = MediaWikiServices::getInstance()->getMainConfig();
144 wfDebug( __METHOD__ .
"()\n" );
147 if ( $mode === self::MODE_OUTAGE ) {
149 $context->getTitle()->resetArticleID( 0 );
152 $context->getOutput()->sendCacheControl();
153 header(
"Content-Type: {$config->get( 'MimeType' )}; charset=UTF-8" );
154 header(
'Content-Language: ' .
155 MediaWikiServices::getInstance()->getContentLanguage()->getHtmlCode() );
158 header(
'Content-Encoding: gzip' );
159 readfile( $filename );
162 wfDebug( __METHOD__ .
" uncompressing cache file and sending it\n" );
163 readgzfile( $filename );
166 readfile( $filename );
185 if ( strlen( $text ) < 512 ) {
190 wfDebug( __METHOD__ .
"()\n",
'private' );
195 '</html>',
'<!-- Cached/compressed ' . $now .
" -->\n</html>", $text );
198 '</html>',
'<!-- Cached ' . $now .
" -->\n</html>", $text );
202 $compressed = $this->
saveText( $text );
203 if ( $compressed ===
false ) {
210 header(
'Content-Encoding: gzip' );
224 $config = MediaWikiServices::getInstance()->getMainConfig();
226 if ( !$config->get(
'UseFileCache' ) ) {
230 foreach ( self::cacheablePageActions() as
$type ) {
static useFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Check if pages can be cached for this request/user.
saveText( $text)
Save and compress text to the cache.
static clearFileCache(Title $title)
Clear the file caches for a page for all actions.
Page view caching in the file system.
typeSubdirectory()
Get the cache type subdirectory (with the trailing slash) or the empty string Alter the type -> direc...
static cacheablePageActions()
Cacheable actions.
saveToFileCache( $text)
Save this cache object with the given text.
useGzip()
Check if the cache is gzipped.
baseCacheDirectory()
Get the base file cache directory.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
__construct( $title, $action)
wfClientAcceptsGzip( $force=false)
Whether the client accept gzip encoding.
Interface for objects which can provide a MediaWiki context on request.
Represents a title within MediaWiki.
loadFromFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Read from cache to context output.
cachePath()
Get the path to the cache file.
cacheDirectory()
Get the base file cache directory.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Base class for data storage in the file system.