MediaWiki  1.23.2
CacheTime.php
Go to the documentation of this file.
1 <?php
29 class CacheTime {
33  public $mUsedOptions;
34 
35  var $mVersion = Parser::VERSION, # Compatibility check
36  $mCacheTime = '', # Time when this object was generated, or -1 for uncacheable. Used in ParserCache.
37  $mCacheExpiry = null, # Seconds after which the object should expire, use 0 for uncachable. Used in ParserCache.
38  $mContainsOldMagic, # Boolean variable indicating if the input contained variables like {{CURRENTDAY}}
39  $mCacheRevisionId = null; # Revision ID that was parsed
40 
44  function getCacheTime() {
45  return wfTimestamp( TS_MW, $this->mCacheTime );
46  }
47 
51  function containsOldMagic() {
53  }
54 
59  function setContainsOldMagic( $com ) {
60  return wfSetVar( $this->mContainsOldMagic, $com );
61  }
62 
69  function setCacheTime( $t ) {
70  return wfSetVar( $this->mCacheTime, $t );
71  }
72 
77  function getCacheRevisionId() {
79  }
80 
85  function setCacheRevisionId( $id ) {
86  $this->mCacheRevisionId = $id;
87  }
88 
99  function updateCacheExpiry( $seconds ) {
100  $seconds = (int)$seconds;
101 
102  if ( $this->mCacheExpiry === null || $this->mCacheExpiry > $seconds ) {
103  $this->mCacheExpiry = $seconds;
104  }
105 
106  // hack: set old-style marker for uncacheable entries.
107  if ( $this->mCacheExpiry !== null && $this->mCacheExpiry <= 0 ) {
108  $this->mCacheTime = -1;
109  }
110  }
111 
121  function getCacheExpiry() {
122  global $wgParserCacheExpireTime;
123 
124  if ( $this->mCacheTime < 0 ) {
125  return 0;
126  } // old-style marker for "not cachable"
127 
128  $expire = $this->mCacheExpiry;
129 
130  if ( $expire === null ) {
131  $expire = $wgParserCacheExpireTime;
132  } else {
133  $expire = min( $expire, $wgParserCacheExpireTime );
134  }
135 
136  if ( $this->containsOldMagic() ) { //compatibility hack
137  $expire = min( $expire, 3600 ); # 1 hour
138  }
139 
140  if ( $expire <= 0 ) {
141  return 0; // not cachable
142  } else {
143  return $expire;
144  }
145  }
146 
150  function isCacheable() {
151  return $this->getCacheExpiry() > 0;
152  }
153 
162  public function expired( $touched ) {
163  global $wgCacheEpoch;
164  return !$this->isCacheable() || // parser says it's uncacheable
165  $this->getCacheTime() < $touched ||
166  $this->getCacheTime() <= $wgCacheEpoch ||
167  $this->getCacheTime() < wfTimestamp( TS_MW, time() - $this->getCacheExpiry() ) || // expiry period has passed
168  !isset( $this->mVersion ) ||
169  version_compare( $this->mVersion, Parser::VERSION, "lt" );
170  }
171 
184  public function isDifferentRevision( $id ) {
185  $cached = $this->getCacheRevisionId();
186  return $cached !== null && $id !== $cached;
187  }
188 }
CacheTime\setContainsOldMagic
setContainsOldMagic( $com)
Definition: CacheTime.php:58
CacheTime\getCacheExpiry
getCacheExpiry()
Returns the number of seconds after which this object should expire.
Definition: CacheTime.php:120
check
in this case you re responsible for computing and outputting the entire conflict i the difference between revisions and your text headers and sections and Diff overridable Default is either copyrightwarning or copyrightwarning2 overridable Default is editpage tos summary such as anonymity and the real check
Definition: hooks.txt:1038
ID
occurs before session is loaded can be modified ID
Definition: hooks.txt:2818
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
CacheTime
Parser cache specific expiry check.
Definition: CacheTime.php:29
CacheTime\$mCacheTime
$mCacheTime
Definition: CacheTime.php:35
wfSetVar
wfSetVar(&$dest, $source, $force=false)
Sets dest to source and returns the original value of dest If source is NULL, it just returns the val...
Definition: GlobalFunctions.php:2139
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2483
CacheTime\$mContainsOldMagic
$mContainsOldMagic
Definition: CacheTime.php:36
CacheTime\$mVersion
$mVersion
Definition: CacheTime.php:34
CacheTime\getCacheRevisionId
getCacheRevisionId()
Definition: CacheTime.php:76
Revision
Definition: Revision.php:26
CacheTime\setCacheTime
setCacheTime( $t)
setCacheTime() sets the timestamp expressing when the page has been rendered.
Definition: CacheTime.php:68
CacheTime\isDifferentRevision
isDifferentRevision( $id)
Return true if this cached output object is for a different revision of the page.
Definition: CacheTime.php:183
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
CacheTime\$mCacheExpiry
$mCacheExpiry
Definition: CacheTime.php:36
TS_MW
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
Definition: GlobalFunctions.php:2431
variable
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control variable
Definition: memcached.txt:78
CacheTime\$mCacheRevisionId
$mCacheRevisionId
Definition: CacheTime.php:38
like
For a write use something like
Definition: database.txt:26
CacheTime\containsOldMagic
containsOldMagic()
Definition: CacheTime.php:50
in
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning in
Definition: maintenance.txt:1
CacheTime\expired
expired( $touched)
Return true if this cached output object predates the global or per-article cache invalidation timest...
Definition: CacheTime.php:161
CacheTime\setCacheRevisionId
setCacheRevisionId( $id)
Definition: CacheTime.php:84
ParserCache
Definition: ParserCache.php:28
CacheTime\updateCacheExpiry
updateCacheExpiry( $seconds)
Sets the number of seconds after which this object should expire.
Definition: CacheTime.php:98
CacheTime\isCacheable
isCacheable()
Definition: CacheTime.php:149
that
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if that
Definition: deferred.txt:11
$t
$t
Definition: testCompression.php:65
CacheTime\getCacheTime
getCacheTime()
Definition: CacheTime.php:43
CacheTime\$mUsedOptions
array bool $mUsedOptions
ParserOptions which have been taken into account to produce output or false if not available.
Definition: CacheTime.php:32