MediaWiki  master
Go to the documentation of this file.
1 <?php
30  protected $mCacheWorthy;
32  /* @todo configurable? */
33  const MISS_THRESHOLD = 360; // 6/min * 60 min
40  public static function newFromContext( ResourceLoaderContext $context ) {
41  $cache = new self();
43  if ( $context->getImage() ) {
44  $cache->mType = 'image';
45  } elseif ( $context->getOnly() === 'styles' ) {
46  $cache->mType = 'css';
47  } else {
48  $cache->mType = 'js';
49  }
50  $modules = array_unique( $context->getModules() ); // remove duplicates
51  sort( $modules ); // normalize the order (permutation => combination)
52  $cache->mKey = sha1( $context->getHash() . implode( '|', $modules ) );
53  if ( count( $modules ) == 1 ) {
54  $cache->mCacheWorthy = true; // won't take up much space
55  }
57  return $cache;
58  }
66  public static function useFileCache( ResourceLoaderContext $context ) {
68  if ( !$wgUseFileCache ) {
69  return false;
70  }
71  // Get all query values
72  $queryVals = $context->getRequest()->getValues();
73  foreach ( $queryVals as $query => $val ) {
74  if ( in_array( $query, [ 'modules', 'image', 'variant', 'version', '*' ] ) ) {
75  // Use file cache regardless of the value of this parameter
76  continue; // note: &* added as IE fix
77  } elseif ( $query === 'skin' && $val === $wgDefaultSkin ) {
78  continue;
79  } elseif ( $query === 'lang' && $val === $wgLanguageCode ) {
80  continue;
81  } elseif ( $query === 'only' && in_array( $val, [ 'styles', 'scripts' ] ) ) {
82  continue;
83  } elseif ( $query === 'debug' && $val === 'false' ) {
84  continue;
85  } elseif ( $query === 'format' && $val === 'rasterized' ) {
86  continue;
87  }
89  return false;
90  }
92  return true; // cacheable
93  }
99  protected function cacheDirectory() {
100  return $this->baseCacheDirectory() . '/resources';
101  }
107  public function isCacheWorthy() {
108  if ( $this->mCacheWorthy === null ) {
109  $this->mCacheWorthy = (
110  $this->isCached() || // even stale cache indicates it was cache worthy
111  $this->getMissesRecent() >= self::MISS_THRESHOLD // many misses
112  );
113  }
115  return $this->mCacheWorthy;
116  }
117 }
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used $groups Array of ChangesListFilterGroup objects(added in 1.34) 'FileDeleteComplete' 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
Definition: hooks.txt:1529
Get the base file cache directory.
static newFromContext(ResourceLoaderContext $context)
Construct an ResourceFileCache from a context.
Site language code.
Check if the cache file exists.
This will cache static pages for non-logged-in users to reduce database traffic on public sites...
ResourceLoader request result caching in the file system.
Base class for data storage in the file system.
Definition: mcc.php:33
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:767
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
Definition: distributors.txt:9
Roughly gets the cache misses in the last hour by unique visitors.
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
Definition: injection.txt:35
Default skin, for new users and anonymous visitors.
static useFileCache(ResourceLoaderContext $context)
Check if an RL request can be cached.
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
Definition: hooks.txt:2621
Item has many recent cache misses.
All factors that uniquely identify this request, except &#39;modules&#39;.
Object passed around to modules which contains information about the state of a specific loader reque...
Get the base file cache directory.