Add a hook to allow extensions to prevent HTML file caching
authorMax Semenik <maxsem.wiki@gmail.com>
Mon, 15 Sep 2014 23:52:14 +0000 (16:52 -0700)
committerMax Semenik <maxsem.wiki@gmail.com>
Fri, 19 Sep 2014 00:00:39 +0000 (17:00 -0700)
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
includes/cache/HTMLFileCache.php

index 9ac2271..f1f70f3 100644 (file)
@@ -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.
index 91580f9..b8dbdf7 100644 (file)
@@ -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 ) );
        }
 
        /**