From bbc92a143346e3f3d52c2c8d5977ef3562f0a565 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Mon, 15 Sep 2014 16:52:14 -0700 Subject: [PATCH] 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 --- docs/hooks.txt | 4 ++++ includes/cache/HTMLFileCache.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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 ) ); } /** -- 2.20.1