44 parent::__construct();
47 if ( !in_array( $action, $allowedTypes ) ) {
48 throw new MWException(
'Invalid file cache type given.' );
50 $this->mKey = ( $title instanceof
Title )
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();
96 if ( !$config->get(
'UseFileCache' ) && $mode !== self::MODE_REBUILD ) {
98 } elseif ( $config->get(
'DebugToolbar' ) ) {
99 wfDebug(
"HTML file cache skipped. \$wgDebugToolbar on\n" );
105 $queryVals =
$context->getRequest()->getValues();
106 foreach ( $queryVals as
$query => $val ) {
110 } elseif (
$query ===
'action' && in_array( $val, self::cacheablePageActions() ) ) {
113 } elseif (
$query ===
'maxage' ||
$query ===
'smaxage' ) {
126 if ( $user->getId() || $ulang->getCode() !== $config->get(
'LanguageCode' ) ) {
130 if ( $mode === self::MODE_NORMAL ) {
131 if ( $user->getNewtalk() ) {
137 return Hooks::run(
'HTMLFileCache::useFileCache', [
$context ] );
148 $config = MediaWikiServices::getInstance()->getMainConfig();
150 wfDebug( __METHOD__ .
"()\n" );
153 if ( $mode === self::MODE_OUTAGE ) {
155 $context->getTitle()->resetArticleID( 0 );
158 $context->getOutput()->sendCacheControl();
159 header(
"Content-Type: {$config->get( 'MimeType' )}; charset=UTF-8" );
160 header(
"Content-Language: {$wgContLang->getHtmlCode()}" );
163 header(
'Content-Encoding: gzip' );
164 readfile( $filename );
167 wfDebug( __METHOD__ .
" uncompressing cache file and sending it\n" );
168 readgzfile( $filename );
171 readfile( $filename );
190 if ( strlen( $text ) < 512 ) {
195 wfDebug( __METHOD__ .
"()\n",
'private' );
200 '</html>',
'<!-- Cached/compressed ' . $now .
" -->\n</html>", $text );
203 '</html>',
'<!-- Cached ' . $now .
" -->\n</html>", $text );
207 $compressed = $this->
saveText( $text );
208 if ( $compressed ===
false ) {
216 header(
'Content-Encoding: gzip' );
233 $config = MediaWikiServices::getInstance()->getMainConfig();
235 if ( !$config->get(
'UseFileCache' ) ) {
239 foreach ( self::cacheablePageActions() as
$type ) {
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfClientAcceptsGzip( $force=false)
Whether the client accept gzip encoding.
Base class for data storage in the file system.
useGzip()
Check if the cache is gzipped.
cachePath()
Get the path to the cache file.
saveText( $text)
Save and compress text to the cache.
baseCacheDirectory()
Get the base file cache directory.
Page view caching in the file system.
static useFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Check if pages can be cached for this request/user.
loadFromFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Read from cache to context output.
saveToFileCache( $text)
Save this cache object with the given text.
cacheDirectory()
Get the base file cache directory.
static clearFileCache(Title $title)
Clear the file caches for a page for all actions.
typeSubdirectory()
Get the cache type subdirectory (with the trailing slash) or the empty string Alter the type -> direc...
static cacheablePageActions()
Cacheable actions.
__construct( $title, $action)
Represents a title within MediaWiki.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
namespace and then decline to actually register it file or subcat img or subcat $title
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Interface for objects which can provide a MediaWiki context on request.