Merge "Use {{int:}} on MediaWiki:Blockedtext and MediaWiki:Autoblockedtext"
[lhc/web/wiklou.git] / includes / parser / CacheTime.php
index c450689..26d5bdd 100644 (file)
  * @ingroup Parser
  */
 class CacheTime {
-       /** @var array|bool ParserOptions which have been taken into account to
-        * produce output or false if not available.
+       /**
+        * @var string[] ParserOptions which have been taken into account to produce output.
         */
        public $mUsedOptions;
 
-       public $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 uncacheable. Used in ParserCache.
-               $mCacheRevisionId = null;     # Revision ID that was parsed
+       /**
+        * @var string|null Compatibility check
+        */
+       public $mVersion = Parser::VERSION;
+
+       /**
+        * @var string|int TS_MW timestamp when this object was generated, or -1 for uncacheable. Used
+        * in ParserCache.
+        */
+       public $mCacheTime = '';
+
+       /**
+        * @var int|null Seconds after which the object should expire, use 0 for uncacheable. Used in
+        * ParserCache.
+        */
+       public $mCacheExpiry = null;
+
+       /**
+        * @var int|null Revision ID that was parsed
+        */
+       public $mCacheRevisionId = null;
 
        /**
         * @return string TS_MW timestamp
@@ -64,7 +81,7 @@ class CacheTime {
 
        /**
         * @since 1.23
-        * @param int $id Revision id
+        * @param int|null $id Revision ID
         */
        public function setCacheRevisionId( $id ) {
                $this->mCacheRevisionId = $id;
@@ -72,12 +89,15 @@ class CacheTime {
 
        /**
         * Sets the number of seconds after which this object should expire.
+        *
         * This value is used with the ParserCache.
         * If called with a value greater than the value provided at any previous call,
         * the new call has no effect. The value returned by getCacheExpiry is smaller
         * or equal to the smallest number that was provided as an argument to
         * updateCacheExpiry().
         *
+        * Avoid using 0 if at all possible. Consider JavaScript for highly dynamic content.
+        *
         * @param int $seconds
         */
        public function updateCacheExpiry( $seconds ) {
@@ -86,11 +106,6 @@ class CacheTime {
                if ( $this->mCacheExpiry === null || $this->mCacheExpiry > $seconds ) {
                        $this->mCacheExpiry = $seconds;
                }
-
-               // hack: set old-style marker for uncacheable entries.
-               if ( $this->mCacheExpiry !== null && $this->mCacheExpiry <= 0 ) {
-                       $this->mCacheTime = -1;
-               }
        }
 
        /**
@@ -100,7 +115,7 @@ class CacheTime {
         * The value returned by getCacheExpiry is smaller or equal to the smallest number
         * that was provided to a call of updateCacheExpiry(), and smaller or equal to the
         * value of $wgParserCacheExpireTime.
-        * @return int|mixed|null
+        * @return int
         */
        public function getCacheExpiry() {
                global $wgParserCacheExpireTime;