From d39e1e24d1a97c0c063e5b675a898f8ff9faae90 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 20 May 2015 14:15:17 +0200 Subject: [PATCH] Introduce ParserCacheSaveComplete hook. Rationale: give extensions a way to track which "renderings" of a page exist in the cache. This is particularly relevant for multi-lingual wikis that splpit the parser cache by user language on some pages. In that case, hooking into ParserAfterParse or LinksUpdateComplete is insufficient to track all language specific renderings. Bug: T99511 Change-Id: Iebf526098ca837a7df637c650097119495000c81 --- RELEASE-NOTES-1.26 | 1 + docs/hooks.txt | 8 ++++++++ includes/parser/ParserCache.php | 2 ++ 3 files changed, 11 insertions(+) diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index 6f1120e42c..588dc5614b 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -42,6 +42,7 @@ changes to languages because of Bugzilla reports. * ChangeTags::tagDescription() will return false if the interface message for the tag is disabled. * Added PageHistoryPager::doBatchLookups hook. +* Added ParserCacheSaveComplete to ParserCache * supportsDirectEditing and supportsDirectApiEditing methods added to ContentHandler, to provide a way for ApiEditPage and EditPage to check if direct editing of content is allowed. These methods return false, diff --git a/docs/hooks.txt b/docs/hooks.txt index e15520c19a..131986a7a6 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2238,6 +2238,14 @@ $section: the section number, zero-based, but section 0 is usually empty &$sectionContent: ref to the content of the section. modify this. $showEditLinks: boolean describing whether this section has an edit link +'ParserCacheSaveComplete': Called after a ParserOutput has been committed to +the parser cache. +$parserCache: ParserCache object $parserOutput was stored in +$parserOutput: ParserOutput object that was stored +$title: Title of the page that was parsed to generate $parserOutput +$popts: ParserOptions used for generating $parserOutput +$revId: ID of the revision that was parsed to create $parserOutput + 'ParserTestParser': Called when creating a new instance of Parser in tests/parser/parserTest.inc. $parser: Parser object created diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index dc8bb5266a..131b7b5328 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -276,6 +276,8 @@ class ParserCache { // ...and its pointer $this->mMemc->set( $this->getOptionsKey( $page ), $optionsKey, $expire ); + + Hooks::run( 'ParserCacheSaveComplete', array( $this, $parserOutput, $page->getTitle(), $popts, $revId ) ); } else { wfDebug( "Parser output was marked as uncacheable and has not been saved.\n" ); } -- 2.20.1