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();
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() ) {
148 $config = MediaWikiServices::getInstance()->getMainConfig();
150 wfDebug( __METHOD__ .
"()\n" );
153 if ( $mode === self::MODE_OUTAGE ) {
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 ) {
static useFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Check if pages can be cached for this request/user.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
saveText( $text)
Save and compress text to the cache.
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
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...
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static cacheablePageActions()
Cacheable actions.
saveToFileCache( $text)
Save this cache object with the given text.
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
null for the 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
namespace and then decline to actually register it file or subcat img or subcat $title
useGzip()
Check if the cache is gzipped.
baseCacheDirectory()
Get the base file cache directory.
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.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
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
__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.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
cachePath()
Get the path to the cache file.
cacheDirectory()
Get the base file cache directory.
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 MediaWikiServices
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.
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 content language as $wgContLang