jenkins-bot has submitted this change and it was merged.
Change subject: Ensure the parser cache varies on images disabled and 'light'
images
......................................................................
Ensure the parser cache varies on images disabled and 'light' images
Use a PageRenderingHash hook handler to ensure the parser cache lookup key is
updated whenever we are modifying the output to strip or downsample images.
Change-Id: I7b86a5219043809a4934bbf376be477546f73d89
(cherry picked from commit 781f292ab31a096d2958ca621b9ad5f1cc9e2e4f)
---
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
2 files changed, 25 insertions(+), 0 deletions(-)
Approvals:
Ori.livneh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 53d6db9..536d0c0 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -147,6 +147,7 @@
$wgHooks['SkinPreloadExistence'][] =
'MobileFrontendHooks::onSkinPreloadExistence';
$wgHooks['ThumbnailBeforeProduceHTML'][] =
'MobileFrontendHooks::onThumbnailBeforeProduceHTML';
$wgHooks['ImageBeforeProduceHTML'][] =
'MobileFrontendHooks::onImageBeforeProduceHTML';
+$wgHooks['PageRenderingHash'][] = 'MobileFrontendHooks::onPageRenderingHash';
$wgSpecialPages += array(
'History' => 'SpecialMobileHistory',
diff --git a/includes/MobileFrontend.hooks.php
b/includes/MobileFrontend.hooks.php
index cca00a0..1f3183a 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -307,6 +307,30 @@
}
/**
+ * PageRenderingHash hook handler
+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/PageRenderingHash
+ *
+ * @param string &$confstr Reference to a hash key string which can be
modified
+ * @param User $user User object that is requesting the page
+ * @param array &$forOptions Array of options used to generate the
$confstr hash key
+ */
+ public static function onPageRenderingHash( &$confstr, User $user,
&$forOptions ) {
+ $context = MobileContext::singleton();
+
+ if ( !$context->shouldDisplayMobileView() ) {
+ return;
+ }
+
+ if ( $context->getNetSpeed() !== MobileContext::NETSPEED_FAST )
{
+ $confstr .= '!light';
+ }
+
+ if ( $context->imagesDisabled() ) {
+ $confstr .= '!noimg';
+ }
+ }
+
+ /**
* SkinPreloadExistence hook handler
* Disables TOC in output before it grabs HTML
* @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinPreloadExistence
--
To view, visit https://gerrit.wikimedia.org/r/257772
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7b86a5219043809a4934bbf376be477546f73d89
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: wmf/1.27.0-wmf.8
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits