Merge "In MediaWikiTestCase::stashMwGlobals(), prefer shallow copies"
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index 326f26c..8702156 100644 (file)
  * @file
  */
 
-/**
- * Interface for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
- */
-interface Page {
-}
-
 /**
  * Class representing a MediaWiki article and history.
  *
@@ -100,7 +94,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @param Title $title
         *
         * @throws MWException
-        * @return WikiPage Object of the appropriate type
+        * @return WikiPage|WikiCategoryPage|WikiFilePage
         */
        public static function factory( Title $title ) {
                $ns = $title->getNamespace();
@@ -189,18 +183,12 @@ class WikiPage implements Page, IDBAccessObject {
        }
 
        /**
-        * Returns overrides for action handlers.
-        * Classes listed here will be used instead of the default one when
-        * (and only when) $wgActions[$action] === true. This allows subclasses
-        * to override the default behavior.
-        *
         * @todo Move this UI stuff somewhere else
         *
-        * @return array
+        * @see ContentHandler::getActionOverrides
         */
        public function getActionOverrides() {
-               $content_handler = $this->getContentHandler();
-               return $content_handler->getActionOverrides();
+               return $this->getContentHandler()->getActionOverrides();
        }
 
        /**
@@ -2121,7 +2109,13 @@ class WikiPage implements Page, IDBAccessObject {
                        : '';
                $edit->pst = $edit->pstContent ? $edit->pstContent->serialize( $serialFormat ) : '';
 
+               if ( $edit->output ) {
+                       $edit->output->setCacheTime( wfTimestampNow() );
+               }
+
+               // Process cache the result
                $this->mPreparedEdit = $edit;
+
                return $edit;
        }
 
@@ -3509,6 +3503,8 @@ class WikiPage implements Page, IDBAccessObject {
                        return;
                }
 
+               $config = RequestContext::getMain()->getConfig();
+
                $params = [
                        'isOpportunistic' => true,
                        'rootJobTimestamp' => $parserOutput->getCacheTime()
@@ -3519,7 +3515,7 @@ class WikiPage implements Page, IDBAccessObject {
                        JobQueueGroup::singleton()->lazyPush(
                                RefreshLinksJob::newPrioritized( $this->mTitle, $params )
                        );
-               } elseif ( $parserOutput->hasDynamicContent() ) {
+               } elseif ( !$config->get( 'MiserMode' ) && $parserOutput->hasDynamicContent() ) {
                        // Assume the output contains "dynamic" time/random based magic words.
                        // Only update pages that expired due to dynamic content and NOT due to edits
                        // to referenced templates/files. When the cache expires due to dynamic content,
@@ -3531,7 +3527,8 @@ class WikiPage implements Page, IDBAccessObject {
                                // Although it would be de-duplicated, it would still waste I/O.
                                $cache = ObjectCache::getLocalClusterInstance();
                                $key = $cache->makeKey( 'dynamic-linksupdate', 'last', $this->getId() );
-                               if ( $cache->add( $key, time(), 60 ) ) {
+                               $ttl = max( $parserOutput->getCacheExpiry(), 3600 );
+                               if ( $cache->add( $key, time(), $ttl ) ) {
                                        JobQueueGroup::singleton()->lazyPush(
                                                RefreshLinksJob::newDynamic( $this->mTitle, $params )
                                        );