Merge "Removed old HTMLCacheUpdateJob b/c code"
[lhc/web/wiklou.git] / includes / parser / ParserOutput.php
index f155312..f249017 100644 (file)
@@ -53,7 +53,6 @@ class ParserOutput extends CacheTime {
                $mTOCEnabled = true;          # Whether TOC should be shown, can't override __NOTOC__
        private $mIndexPolicy = '';       # 'index' or 'noindex'?  Any other value will result in no change.
        private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
-       private $mSecondaryDataUpdates = null; # List of DataUpdate, used to save info from the page somewhere else.
        private $mExtensionData = array(); # extra data used by extensions
        private $mLimitReportData = array(); # Parser limit report data
        private $mParseStartTime = array(); # Timestamps for getTimeSinceStart()
@@ -70,8 +69,6 @@ class ParserOutput extends CacheTime {
                $this->mCategories = $categoryLinks;
                $this->mContainsOldMagic = $containsOldMagic;
                $this->mTitleText = $titletext;
-
-               $this->mSecondaryDataUpdates = array();
        }
 
        public function getText() {
@@ -490,9 +487,10 @@ class ParserOutput extends CacheTime {
         * Add a tracking category, getting the title from a system message,
         * or print a debug message if the title is invalid.
         *
-        * Please add any message that you use with this function to
-        * $wgTrackingCategories. That way they will be listed on
-        * Special:TrackingCategories.
+        * Any message used with this function should be registered so it will
+        * show up on Special:TrackingCategories. Core messages should be added
+        * to SpecialTrackingCategories::$coreTrackingCategories, and extensions
+        * should add to "TrackingCategories" in their extension.json.
         *
         * @param string $msg Message key
         * @param Title $title title of the page which is being tracked
@@ -677,55 +675,57 @@ class ParserOutput extends CacheTime {
        }
 
        /**
-        * Adds an update job to the output. Any update jobs added to the output will
-        * eventually be executed in order to store any secondary information extracted
-        * from the page's content. This is triggered by calling getSecondaryDataUpdates()
-        * and is used for forward links updates on edit and backlink updates by jobs.
+        * @deprecated since 1.25. Instead, store any relevant data using setExtensionData,
+        *    and implement Content::getSecondaryDataUpdates() if possible, or use the
+        *    'SecondaryDataUpdates' hook to construct the necessary update objects.
+        *
+        * @note Hard deprecation and removal without long deprecation period, since there are no
+        *       known users, but known conceptual issues.
         *
-        * @since 1.20
+        * @todo remove in 1.26
         *
         * @param DataUpdate $update
+        *
+        * @throws MWException
         */
        public function addSecondaryDataUpdate( DataUpdate $update ) {
-               $this->mSecondaryDataUpdates[] = $update;
+               wfDeprecated( __METHOD__, '1.25' );
+               throw new MWException( 'ParserOutput::addSecondaryDataUpdate() is no longer supported. Override Content::getSecondaryDataUpdates() or use the SecondaryDataUpdates hook instead.' );
        }
 
        /**
-        * Returns any DataUpdate jobs to be executed in order to store secondary information
-        * extracted from the page's content, including a LinksUpdate object for all links stored in
-        * this ParserOutput object.
+        * @deprecated since 1.25.
         *
-        * @note Avoid using this method directly, use ContentHandler::getSecondaryDataUpdates()
-        *   instead! The content handler may provide additional update objects.
+        * @note Hard deprecation and removal without long deprecation period, since there are no
+        *       known users, but known conceptual issues.
+        *
+        * @todo remove in 1.26
+        *
+        * @return bool false (since 1.25)
+        */
+       public function hasCustomDataUpdates() {
+               wfDeprecated( __METHOD__, '1.25' );
+               return false;
+       }
+
+       /**
+        * @deprecated since 1.25. Instead, store any relevant data using setExtensionData,
+        *    and implement Content::getSecondaryDataUpdates() if possible, or use the
+        *    'SecondaryDataUpdates' hook to construct the necessary update objects.
         *
-        * @since 1.20
+        * @note Hard deprecation and removal without long deprecation period, since there are no
+        *       known users, but known conceptual issues.
         *
-        * @param Title $title The title of the page we're updating. If not given, a title object will
-        *    be created based on $this->getTitleText()
-        * @param bool $recursive Queue jobs for recursive updates?
+        * @todo remove in 1.26
         *
-        * @throws MWException if called on a ParserOutput instance that was restored from serialization.
-        *         DataUpdates are generally not serializable, so after serialization, they are undefined.
+        * @param Title $title
+        * @param bool $recursive
         *
         * @return array An array of instances of DataUpdate
         */
        public function getSecondaryDataUpdates( Title $title = null, $recursive = true ) {
-               if ( is_null( $title ) ) {
-                       $title = Title::newFromText( $this->getTitleText() );
-               }
-
-               if ( $this->mSecondaryDataUpdates === null ) {
-                       //NOTE: This happens when mSecondaryDataUpdates are lost during serialization
-                       // (see __sleep below). After (un)serialization, getSecondaryDataUpdates()
-                       // has no defined behavior, and should throw an exception.
-                       throw new MWException( 'getSecondaryDataUpdates() must not be called on ParserOutput restored from serialization.' );
-               }
-
-               // NOTE: ApiStashEdit knows about this "magic" update object. If this goes away,
-               // ApiStashEdit::buildStashValue needs to be adjusted.
-               $linksUpdate = new LinksUpdate( $title, $this, $recursive );
-
-               return array_merge( $this->mSecondaryDataUpdates, array( $linksUpdate ) );
+               wfDeprecated( __METHOD__, '1.25' );
+               return array();
        }
 
        /**
@@ -861,6 +861,22 @@ class ParserOutput extends CacheTime {
                $this->mLimitReportData[$key] = $value;
        }
 
+       /**
+        * Check whether the cache TTL was lowered due to dynamic content
+        *
+        * When content is determined by more than hard state (e.g. page edits),
+        * such as template/file transclusions based on the current timestamp or
+        * extension tags that generate lists based on queries, this return true.
+        *
+        * @return bool
+        * @since 1.25
+        */
+       public function hasDynamicContent() {
+               global $wgParserCacheExpireTime;
+
+               return $this->getCacheExpiry() < $wgParserCacheExpireTime;
+       }
+
        /**
         * Get or set the prevent-clickjacking flag
         *
@@ -879,7 +895,7 @@ class ParserOutput extends CacheTime {
        public function __sleep() {
                return array_diff(
                        array_keys( get_object_vars( $this ) ),
-                       array( 'mSecondaryDataUpdates', 'mParseStartTime' )
+                       array( 'mParseStartTime' )
                );
        }
 }