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

Change subject: Upstream: Use core's facilities for disabling TOC
......................................................................


Upstream: Use core's facilities for disabling TOC

This is step 1, using it for most code paths
the rest are mentioned in todo

Change-Id: I9ff919b6b7c139da93398bfea7f9d0c1b6f44e4b
---
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
M includes/api/ApiMobileView.php
3 files changed, 19 insertions(+), 0 deletions(-)

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



diff --git a/MobileFrontend.php b/MobileFrontend.php
index 321b146..f771648 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -129,6 +129,7 @@
 $wgHooks['CentralAuthSilentLoginRedirect'][] = 
'MobileFrontendHooks::onCentralAuthSilentLoginRedirect';
 $wgHooks['UserRequiresHTTPS'][] = 'MobileFrontendHooks::onUserRequiresHTTPS';
 $wgHooks['ResourceLoaderRegisterModules'][] = 
'MobileFrontendHooks::onResourceLoaderRegisterModules';
+$wgHooks['OutputPageParserOutput'][] = 
'MobileFrontendHooks::onOutputPageParserOutput';
 
 $wgSpecialPages['MobileDiff'] = 'SpecialMobileDiff';
 $wgSpecialPages['MobileOptions'] = 'SpecialMobileOptions';
@@ -247,6 +248,8 @@
 $wgMFRemovableClasses = array(
        // These rules will be used for all transformations
        'base' => array(
+               // @todo: remove this when cache made before 
https://gerrit.wikimedia.org/r/91902 dies on WMF
+               // but mind that extracts and action=parse&mobileformat don't 
currently support it
                '.toc',
        ),
        // HTML view
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 635511d..14be328 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -686,4 +686,19 @@
 
                return true;
        }
+
+       /**
+        * OutputPageParserOutput hook handler
+        * Disables TOC in output before it grabs HTML
+        * @see 
https://www.mediawiki.org/wiki/Manual:Hooks/OutputPageParserOutput
+        * @param OutputPage $outputPage
+        *
+        * @return bool
+        */
+       public static function onOutputPageParserOutput( $outputPage ) {
+               if ( MobileContext::singleton()->shouldDisplayMobileView() ) {
+                       $outputPage->enableTOC( false );
+               }
+               return true;
+       }
 }
diff --git a/includes/api/ApiMobileView.php b/includes/api/ApiMobileView.php
index c58573e..a3bb602 100644
--- a/includes/api/ApiMobileView.php
+++ b/includes/api/ApiMobileView.php
@@ -221,6 +221,7 @@
                                wfDebugLog( 'mobile', "Empty parser output on 
'{$title->getPrefixedText()}': rev $latest, time $time, cache key $key" );
                                throw new MWException( __METHOD__ . ": 
PoolCounter didn't return parser output" );
                        }
+                       $parserOutput->setTOCEnabled( false );
                        $html = $parserOutput->getText();
                        $cacheExpiry = $parserOutput->getCacheExpiry();
                        wfProfileOut( __METHOD__ . '-parserOutput' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9ff919b6b7c139da93398bfea7f9d0c1b6f44e4b
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to