From e69ea9b6d25fed035f9ea671add2c883856fbe40 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 25 Dec 2005 11:04:40 +0000 Subject: [PATCH] * Added 'PageRenderingHash' hook for changing the parser cache hash key from an extension that changes rendering based on nonstandard options. --- RELEASE-NOTES | 2 ++ docs/hooks.txt | 5 +++++ includes/User.php | 19 ++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6d6d0ca27e..29f4d0a3c9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -352,6 +352,8 @@ fully support the editing toolbar, but was found to be too confusing. * (bug 4377) "[" is not valid in URLs * Don't delete thumbnails when refreshing exif metadata. This caused thumbs to vanish mysteriously from time to time for files that didn't have metadata. +* Added 'PageRenderingHash' hook for changing the parser cache hash key + from an extension that changes rendering based on nonstandard options. === Caveats === diff --git a/docs/hooks.txt b/docs/hooks.txt index 8ebddc85e7..85c479cc69 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -317,6 +317,11 @@ $typeText: array of strings 'LogPageLogHeader': strings used by wfMsg as a header. $headerText: array of strings +'PageRenderingHash': alter the parser cache option hash key + A parser extension which depends on user options should install + this hook and append its values to the key. +$hash: reference to a hash key string which can be modified + 'TitleMoveComplete': after moving an article (title) $old: old title $nt: new title diff --git a/includes/User.php b/includes/User.php index 07a11b3344..c09d0bb053 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1462,6 +1462,19 @@ class User { } + /** + * Generate a string which will be different for any combination of + * user options which would produce different parser output. + * This will be used as part of the hash key for the parser cache, + * so users will the same options can share the same cached data + * safely. + * + * Extensions which require it should install 'PageRenderingHash' hook, + * which will give them a chance to modify this key based on their own + * settings. + * + * @return string + */ function getPageRenderingHash() { global $wgContLang; if( $this->mHash ){ @@ -1480,9 +1493,13 @@ class User { // add in language specific options, if any $extra = $wgContLang->getExtraHashOptions(); $confstr .= $extra; + + // Give a chance for extensions to modify the hash, if they have + // extra options or other effects on the parser cache. + wfRunHooks( 'PageRenderingHash', array( &$confstr ) ); $this->mHash = $confstr; - return $confstr ; + return $confstr; } function isAllowedToCreateAccount() { -- 2.20.1