From: Max Semenik Date: Mon, 15 Sep 2014 23:52:14 +0000 (-0700) Subject: Add a hook to allow extensions to prevent HTML file caching X-Git-Tag: 1.31.0-rc.0~13936^2 X-Git-Url: http://git.cyclocoop.org/%27%2C%20%20%20quote_amp%28%24url%29%2C%20%20%20%27?a=commitdiff_plain;h=bbc92a143346e3f3d52c2c8d5977ef3562f0a565;p=lhc%2Fweb%2Fwiklou.git Add a hook to allow extensions to prevent HTML file caching Needed for MobileFrontend on third-party sites that use this feature. Ideally, there should be a way to cache mobile requests too, but that's a different issue requiring much more effort to do properly. Bug: 68106 Change-Id: I01a76c571d9186b325f19a00cec136459707c791 --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 9ac2271d54..f1f70f34e5 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1376,6 +1376,10 @@ page history view, i.e. undo, rollback, etc. $rev: Revision object &$links: Array of HTML links +'HTMLFileCache::useFileCache': Override whether a page should be cached in file +cache. +$context: An IContextSource object with information about the request being served. + 'ImageBeforeProduceHTML': Called before producing the HTML created by a wiki image insertion. You can skip the default logic entirely by returning false, or just modify a few things using call-by-reference. diff --git a/includes/cache/HTMLFileCache.php b/includes/cache/HTMLFileCache.php index 91580f978f..b8dbdf7109 100644 --- a/includes/cache/HTMLFileCache.php +++ b/includes/cache/HTMLFileCache.php @@ -120,7 +120,11 @@ class HTMLFileCache extends FileCacheBase { $clang = $wgContLang->getCode(); // Check that there are no other sources of variation - return !$user->getId() && !$user->getNewtalk() && $ulang == $clang; + if ( $user->getId() || $user->getNewtalk() || $ulang != $clang ) { + return false; + } + // Allow extensions to disable caching + return wfRunHooks( 'HTMLFileCache::useFileCache', array( $context ) ); } /**