Introduce ParserCacheSaveComplete hook.
authordaniel <daniel.kinzler@wikimedia.de>
Wed, 20 May 2015 12:15:17 +0000 (14:15 +0200)
committerTim Starling <tstarling@wikimedia.org>
Mon, 25 May 2015 13:35:23 +0000 (13:35 +0000)
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
docs/hooks.txt
includes/parser/ParserCache.php

index 6f1120e..588dc56 100644 (file)
@@ -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,
index e15520c..131986a 100644 (file)
@@ -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
index dc8bb52..131b7b5 100644 (file)
@@ -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" );
                }