48 return new self(
$title, $action );
57 parent::__construct();
59 $allowedTypes = self::cacheablePageActions();
60 if ( !in_array( $action, $allowedTypes ) ) {
61 throw new MWException(
'Invalid file cache type given.' );
64 ?
$title->getPrefixedDBkey()
66 $this->mType = (
string)$action;
75 return [
'view',
'history' ];
93 if ( $this->mType ===
'view' ) {
96 return $this->mType .
'/';
107 $config = MediaWikiServices::getInstance()->getMainConfig();
109 if ( !$config->get(
'UseFileCache' ) && $mode !== self::MODE_REBUILD ) {
111 } elseif ( $config->get(
'DebugToolbar' ) ) {
112 wfDebug(
"HTML file cache skipped. \$wgDebugToolbar on\n" );
118 $queryVals = $context->
getRequest()->getValues();
119 foreach ( $queryVals
as $query => $val ) {
123 } elseif (
$query ===
'action' && in_array( $val, self::cacheablePageActions() ) ) {
126 } elseif (
$query ===
'maxage' ||
$query ===
'smaxage' ) {
139 if (
$user->getId() || $ulang->getCode() !== $config->get(
'LanguageCode' ) ) {
143 if ( $mode === self::MODE_NORMAL ) {
144 if (
$user->getNewtalk() ) {
150 return Hooks::run(
'HTMLFileCache::useFileCache', [ $context ] );
161 $config = MediaWikiServices::getInstance()->getMainConfig();
163 wfDebug( __METHOD__ .
"()\n" );
166 if ( $mode === self::MODE_OUTAGE ) {
168 $context->
getTitle()->resetArticleID( 0 );
171 $context->
getOutput()->sendCacheControl();
172 header(
"Content-Type: {$config->get( 'MimeType' )}; charset=UTF-8" );
173 header(
"Content-Language: {$wgContLang->getHtmlCode()}" );
176 header(
'Content-Encoding: gzip' );
177 readfile( $filename );
180 wfDebug( __METHOD__ .
" uncompressing cache file and sending it\n" );
181 readgzfile( $filename );
184 readfile( $filename );
203 if ( strlen( $text ) < 512 ) {
208 wfDebug( __METHOD__ .
"()\n",
'private' );
213 '</html>',
'<!-- Cached/compressed ' . $now .
" -->\n</html>", $text );
216 '</html>',
'<!-- Cached ' . $now .
" -->\n</html>", $text );
220 $compressed = $this->
saveText( $text );
221 if ( $compressed ===
false ) {
229 header(
'Content-Encoding: gzip' );
246 $config = MediaWikiServices::getInstance()->getMainConfig();
248 if ( !$config->get(
'UseFileCache' ) ) {
252 foreach ( self::cacheablePageActions()
as $type ) {
saveText($text)
Save and compress text to the cache.
Interface for objects which can provide a MediaWiki context on request.
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
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static useFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Check if pages can be cached for this request/user.
static newFromTitle($title, $action)
Construct an HTMLFileCache object from a Title and an action.
baseCacheDirectory()
Get the base file cache directory.
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
Page view caching in the file system.
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
when a variable name is used in a it is silently declared as a new local masking the global
static cacheablePageActions()
Cacheable actions.
loadFromFileCache(IContextSource $context, $mode=self::MODE_NORMAL)
Read from cache to context output.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
getUser()
Get the User object.
typeSubdirectory()
Get the cache type subdirectory (with the trailing slash) or the empty string Alter the type -> direc...
static clearFileCache(Title $title)
Clear the file caches for a page for all actions.
wfClientAcceptsGzip($force=false)
Base class for data storage in the file system.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
namespace and then decline to actually register it file or subcat img or subcat $title
cachePath()
Get the path to the cache file.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
getLanguage()
Get the Language object.
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
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 local account $user
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
saveToFileCache($text)
Save this cache object with the given text.
useGzip()
Check if the cache is gzipped.
__construct($title, $action)
getTitle()
Get the Title object.
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
cacheDirectory()
Get the base file cache directory.
getOutput()
Get the OutputPage object.
getRequest()
Get the WebRequest object.
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