From: Aaron Schulz Date: Wed, 27 Jan 2016 01:23:53 +0000 (-0800) Subject: Add ParserOutputStashForEdit hook for extension cache warming X-Git-Tag: 1.31.0-rc.0~8168^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=d478d4a15450c8c2c51ce5b634ffcdd22b872622;p=lhc%2Fweb%2Fwiklou.git Add ParserOutputStashForEdit hook for extension cache warming This can pre-cache slow queries by extensions that happen on edit submission. Bug: T116557 Change-Id: I803f69013f68e80a53dd3c466bddff3ebe2b659b --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 2b5e1e0d7e..a2524384fe 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2346,6 +2346,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 diff --git a/includes/api/ApiStashEdit.php b/includes/api/ApiStashEdit.php index 8822750ac9..00675f4f0c 100644 --- a/includes/api/ApiStashEdit.php +++ b/includes/api/ApiStashEdit.php @@ -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 {