From 207dfd2adf815fee446bc096952472279a588aaa Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Mon, 22 Jun 2015 22:09:53 -0700 Subject: [PATCH] Add RejectParserCacheValue hook Add a new hook, 'RejectParserCacheValue', which allows extensions to reject an otherwise-successful parser cache lookup. The intent is to allow extensions to manage the eviction of archaic HTML output from the cache. Change-Id: I660679a48c46608f859bd52b31d6a888aabcc9ac --- RELEASE-NOTES-1.26 | 3 +++ docs/hooks.txt | 6 ++++++ includes/parser/ParserCache.php | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index 852023bfc8..e035de9997 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -21,6 +21,9 @@ production. * Revive the 'SpecialSearchResultsAppend' hook which occurs after the list of search results are rendered. The initial use case is to append a "give us feedback" link beneath the search results. +* Added a new hook, 'RejectParserCacheValue', which allows extensions to + reject an otherwise-successful parser cache lookup. The intent is to allow + extensions to manage the eviction of archaic HTML output from the cache. ==== External libraries ==== diff --git a/docs/hooks.txt b/docs/hooks.txt index 4546f9e81d..8cfdee904f 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2402,6 +2402,12 @@ names such as "oldid" that are preserved when using redirecting special pages such as Special:MyPage and Special:MyTalk. &$redirectParams: An array of parameters preserved by redirecting special pages. +'RejectParserCacheValue': Return false to reject an otherwise usable +cached value from the Parser cache. +$parserOutput: ParserOutput value. +$wikiPage: WikiPage object. +$parserOptions: ParserOptions object. + 'RequestContextCreateSkin': Called when RequestContext::getSkin creates a skin instance. Can be used by an extension override what skin is used in certain contexts. diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index 16dde0d2f1..2919c6c449 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -225,6 +225,10 @@ class ParserCache { $cachedRevId = $value->getCacheRevisionId(); wfDebug( "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n" ); $value = false; + } elseif ( Hooks::run( 'RejectParserCacheValue', array( $value, $article, $popts ) ) === false ) { + wfIncrStats( 'pcache.miss.rejected' ); + wfDebug( "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n" ); + $value = false; } else { wfIncrStats( "pcache.hit" ); } -- 2.20.1