Merge "Add ParserOutputStashForEdit hook for extension cache warming"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 28 Jan 2016 23:13:06 +0000 (23:13 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 28 Jan 2016 23:13:06 +0000 (23:13 +0000)
docs/hooks.txt
includes/api/ApiStashEdit.php

index b516122..bc03714 100644 (file)
@@ -2347,6 +2347,11 @@ run. Use when page save hooks require the presence of custom tables to ensure
 that tests continue to run properly.
 &$tables: array of table names
 
+'ParserOutputStashForEdit': Called when an edit stash parse finishes, before the output is cached.
+$page: the WikiPage of the candidate edit
+$content: the Content object of the candidate edit
+$output: the ParserOutput result of the candidate edit
+
 'PasswordPoliciesForUser': Alter the effective password policy for a user.
 $user: User object whose policy you are modifying
 &$effectivePolicy: Array of policy statements that apply to this user
index 8822750..00675f4 100644 (file)
@@ -141,6 +141,9 @@ class ApiStashEdit extends ApiBase {
                if ( $editInfo && $editInfo->output ) {
                        $key = self::getStashKey( $page->getTitle(), $content, $user );
 
+                       // Let extensions add ParserOutput metadata or warm other caches
+                       Hooks::run( 'ParserOutputStashForEdit', array( $page, $content, $editInfo->output ) );
+
                        list( $stashInfo, $ttl ) = self::buildStashValue(
                                $editInfo->pstContent, $editInfo->output, $editInfo->timestamp
                        );
@@ -148,6 +151,7 @@ class ApiStashEdit extends ApiBase {
                        if ( $stashInfo ) {
                                $ok = $cache->set( $key, $stashInfo, $ttl );
                                if ( $ok ) {
+
                                        $logger->debug( "Cached parser output for key '$key'." );
                                        return self::ERROR_NONE;
                                } else {