Merge "Introduce mediawiki.router for handling hash fragment navigation"
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index 48f2a7f..040a6f3 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();
@@ -1351,38 +1345,6 @@ class WikiPage implements Page, IDBAccessObject {
                return $handler->getUndoContent( $this->getRevision(), $undo, $undoafter );
        }
 
-       /**
-        * Get the text that needs to be saved in order to undo all revisions
-        * between $undo and $undoafter. Revisions must belong to the same page,
-        * must exist and must not be deleted
-        * @param Revision $undo
-        * @param Revision $undoafter Must be an earlier revision than $undo
-        * @return string|bool String on success, false on failure
-        * @deprecated since 1.21: use ContentHandler::getUndoContent() instead.
-        */
-       public function getUndoText( Revision $undo, Revision $undoafter = null ) {
-               ContentHandler::deprecated( __METHOD__, '1.21' );
-
-               $this->loadLastEdit();
-
-               if ( $this->mLastRevision ) {
-                       if ( is_null( $undoafter ) ) {
-                               $undoafter = $undo->getPrevious();
-                       }
-
-                       $handler = $this->getContentHandler();
-                       $undone = $handler->getUndoContent( $this->mLastRevision, $undo, $undoafter );
-
-                       if ( !$undone ) {
-                               return false;
-                       } else {
-                               return ContentHandler::getContentText( $undone );
-                       }
-               }
-
-               return false;
-       }
-
        /**
         * Returns true if this page's content model supports sections.
         *
@@ -2153,7 +2115,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;
        }
 
@@ -3541,6 +3509,8 @@ class WikiPage implements Page, IDBAccessObject {
                        return;
                }
 
+               $config = RequestContext::getMain()->getConfig();
+
                $params = [
                        'isOpportunistic' => true,
                        'rootJobTimestamp' => $parserOutput->getCacheTime()
@@ -3551,7 +3521,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,
@@ -3563,7 +3533,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 )
                                        );