Avoid parser cache miss that often occurs post-save
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index 59e8731..5e72151 100644 (file)
@@ -1086,10 +1086,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @return bool
         */
        public function isParserCacheUsed( ParserOptions $parserOptions, $oldid ) {
-               global $wgEnableParserCache;
-
-               return $wgEnableParserCache
-                       && $parserOptions->getStubThreshold() == 0
+               return $parserOptions->getStubThreshold() == 0
                        && $this->exists()
                        && ( $oldid === null || $oldid === 0 || $oldid === $this->getLatest() )
                        && $this->getContentHandler()->isParserCacheSupported();
@@ -1267,10 +1264,9 @@ class WikiPage implements Page, IDBAccessObject {
                        $conditions['page_latest'] = $lastRevision;
                }
 
-               $now = wfTimestampNow();
                $row = array( /* SET */
                        'page_latest'      => $revision->getId(),
-                       'page_touched'     => $dbw->timestamp( $now ),
+                       'page_touched'     => $dbw->timestamp( $revision->getTimestamp() ),
                        'page_is_new'      => ( $lastRevision === 0 ) ? 1 : 0,
                        'page_is_redirect' => $rt !== null ? 1 : 0,
                        'page_len'         => $len,
@@ -1868,7 +1864,7 @@ class WikiPage implements Page, IDBAccessObject {
                                $revision = null;
                                // Update page_touched, this is usually implicit in the page update
                                // Other cache updates are done in onArticleEdit()
-                               $this->mTitle->invalidateCache();
+                               $this->mTitle->invalidateCache( $now );
                        }
                } else {
                        // Create new article
@@ -2152,8 +2148,6 @@ class WikiPage implements Page, IDBAccessObject {
         *   - 'no-change': don't update the article count, ever
         */
        public function doEditUpdates( Revision $revision, User $user, array $options = array() ) {
-               global $wgEnableParserCache;
-
                $options += array(
                        'changed' => true,
                        'created' => false,
@@ -2173,13 +2167,12 @@ class WikiPage implements Page, IDBAccessObject {
                        $editInfo = $this->mPreparedEdit;
                }
 
-               // Save it to the parser cache
-               if ( $wgEnableParserCache ) {
-                       $parserCache = ParserCache::singleton();
-                       $parserCache->save(
-                               $editInfo->output, $this, $editInfo->popts, $editInfo->timestamp, $editInfo->revid
-                       );
-               }
+               // Save it to the parser cache.
+               // Make sure the cache time matches page_touched to avoid double parsing.
+               ParserCache::singleton()->save(
+                       $editInfo->output, $this, $editInfo->popts,
+                       $revision->getTimestamp(), $editInfo->revid
+               );
 
                // Update the links tables and other secondary data
                if ( $content ) {
@@ -3167,7 +3160,6 @@ class WikiPage implements Page, IDBAccessObject {
                // Update existence markers on article/talk tabs...
                $other = $title->getOtherPage();
 
-               $other->invalidateCache();
                $other->purgeSquid();
 
                $title->touchLinks();
@@ -3184,7 +3176,6 @@ class WikiPage implements Page, IDBAccessObject {
                // Update existence markers on article/talk tabs...
                $other = $title->getOtherPage();
 
-               $other->invalidateCache();
                $other->purgeSquid();
 
                $title->touchLinks();