Cenarium has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/277945

Change subject: Set stable revision as cached revision for stable parser cache
......................................................................

Set stable revision as cached revision for stable parser cache

This sets the stable revision id as the revision id that gets cached by
the stable parser cache (FRParserCacheStable). Consequently, the check
for the validity of the cached revision is made against the stable
revision, not the latest revision. To avoid massive invalidation of
parser caches, the latest revision is also allowed for now.

Depends-On: I251a08cd8c7a51ad9b58234fd6e8692d40ae79d4
Change-Id: Ibb6e1c35ff08302ef7af4572010123b8caaa1980
---
M backend/FRParserCacheStable.php
1 file changed, 36 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs 
refs/changes/45/277945/1

diff --git a/backend/FRParserCacheStable.php b/backend/FRParserCacheStable.php
index c3d9b03..0399e7e 100644
--- a/backend/FRParserCacheStable.php
+++ b/backend/FRParserCacheStable.php
@@ -35,4 +35,40 @@
                $key = parent::getOptionsKey( $article ); // call super!
                return str_replace( ':pcache:', ':stable-pcache:', $key );
        }
+
+       /**
+        * @param CacheTime $optionsKey
+        * @param WikiPage $article
+        * @param int &$revId
+        * @return bool
+        */
+       protected function isInvalidRevision( CacheTime $optionsKey, WikiPage 
$article, &$revId ) {
+               if ( $article instanceof FlaggableWikiPage ) {
+                       $page = $article;
+               } else {
+                       $page = FlaggableWikiPage::getTitleInstance( 
$article->getTitle() );
+               }
+               $revId = $page->getStable();
+               return $optionsKey->isDifferentRevision( $revId ) &&
+                       // avoid mass invalidation of old parser caches
+                       // @todo remove this when it's safe
+                       $optionsKey->isDifferentRevision( $page->getLatest() );
+       }
+
+       /**
+        * Like ParserCache::save() but saving with stable revision id by 
default instead of latest
+        * @warning $page must be a FlaggableWikiPage
+        *
+        * @param ParserOutput $parserOutput
+        * @param FlaggableWikiPage $page
+        * @param ParserOptions $popts
+        * @param string $cacheTime Time when the cache was generated
+        * @param int $revId Revision ID that was parsed
+        */
+       public function save( $parserOutput, $page, $popts, $cacheTime = null, 
$revId = null ) {
+               if ( $revId === null ) {
+                       $revId = $page->getStable();
+               }
+               return parent::save( $parserOutput, $page, $popts, $cacheTime, 
$revId );
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/277945
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb6e1c35ff08302ef7af4572010123b8caaa1980
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Cenarium <cenarium.sy...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to