jenkins-bot has submitted this change and it was merged.

Change subject: Add a hook to allow extensions to prevent HTML file caching
......................................................................


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
---
M docs/hooks.txt
M includes/cache/HTMLFileCache.php
2 files changed, 9 insertions(+), 1 deletion(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/docs/hooks.txt b/docs/hooks.txt
index 9ac2271..f1f70f3 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -1376,6 +1376,10 @@
 $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 91580f9..b8dbdf7 100644
--- a/includes/cache/HTMLFileCache.php
+++ b/includes/cache/HTMLFileCache.php
@@ -120,7 +120,11 @@
                $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 ) );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/160563
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I01a76c571d9186b325f19a00cec136459707c791
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to