X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fparser%2FCacheTime.php;h=dfe3c800b59bebd2c2e8cbaed0a62a842e05e776;hb=08be87a99b2468c00a20841a3d7f4884e3c83090;hp=e1b3f28deb66dfb32f7243d4492fb1cb908d574c;hpb=55da056f08df570e7a893edf5c9607b819f511df;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/CacheTime.php b/includes/parser/CacheTime.php index e1b3f28deb..dfe3c800b5 100644 --- a/includes/parser/CacheTime.php +++ b/includes/parser/CacheTime.php @@ -27,7 +27,7 @@ * @ingroup Parser */ class CacheTime { - /** @var array|bool ParserOptions which have been taken into account to + /** @var array|bool ParserOptions which have been taken into account to * produce output or false if not available. */ public $mUsedOptions; @@ -35,7 +35,8 @@ class CacheTime { var $mVersion = Parser::VERSION, # Compatibility check $mCacheTime = '', # Time when this object was generated, or -1 for uncacheable. Used in ParserCache. $mCacheExpiry = null, # Seconds after which the object should expire, use 0 for uncachable. Used in ParserCache. - $mContainsOldMagic; # Boolean variable indicating if the input contained variables like {{CURRENTDAY}} + $mContainsOldMagic, # Boolean variable indicating if the input contained variables like {{CURRENTDAY}} + $mCacheRevisionId = null; # Revision ID that was parsed /** * @return string TS_MW timestamp @@ -69,6 +70,22 @@ class CacheTime { return wfSetVar( $this->mCacheTime, $t ); } + /** + * @since 1.23 + * @return int|null Revision id, if any was set + */ + function getCacheRevisionId() { + return $this->mCacheRevisionId; + } + + /** + * @since 1.23 + * @param $id int Revision id + */ + function setCacheRevisionId( $id ) { + $this->mCacheRevisionId = $id; + } + /** * Sets the number of seconds after which this object should expire. * This value is used with the ParserCache. @@ -152,4 +169,20 @@ class CacheTime { version_compare( $this->mVersion, Parser::VERSION, "lt" ); } + /** + * Return true if this cached output object is for a different revision of + * the page. + * + * @todo We always return false if $this->getCacheRevisionId() is null; + * this prevents invalidating the whole parser cache when this change is + * deployed. Someday that should probably be changed. + * + * @since 1.23 + * @param int $id the affected article's current revision id + * @return Boolean + */ + public function isDifferentRevision( $id ) { + $cached = $this->getCacheRevisionId(); + return $cached !== null && $id !== $cached; + } }