From 54ac31f94d3245e5e1e040a4fe4b3e35c44dbb20 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Tue, 26 Jun 2018 09:53:12 -0400 Subject: [PATCH] Hard deprecate codepaths where tidy is disabled Future parsers will not support the output generated with tidy disabled. Parser tests using untidied output will also be deprecated (and rewritten) in a follow-up patch. No new release notes necessary since user-visible tidy configuration was deprecated previously (in 1.32), and individual methods which had disabled tidy during execution were individually release-noted as they were updated. Bug: T198214 Depends-On: I0f417f75a49dfea873e9a2f44d81796a48b9f428 Depends-On: If5c619cdd3e7f786687cfc2ca166074d9197ca11 Change-Id: I592e0e0dfef7d929f05c60ffe4d60e09725b39cc --- includes/parser/Parser.php | 2 ++ includes/parser/Sanitizer.php | 1 + includes/specials/SpecialExpandTemplates.php | 2 ++ tests/parser/ParserTestRunner.php | 6 ++++++ tests/phpunit/includes/parser/SanitizerTest.php | 2 ++ 5 files changed, 13 insertions(+) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 3dc2eebda2..b2097a96a9 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1452,6 +1452,8 @@ class Parser { } else { # attempt to sanitize at least some nesting problems # (T4702 and quite a few others) + # This code path is buggy and deprecated! + wfDeprecated( 'disabling tidy', '1.33' ); $tidyregs = [ # ''Something [http://www.cool.com cool''] --> # Somethingcool> diff --git a/includes/parser/Sanitizer.php b/includes/parser/Sanitizer.php index 85c71eeb44..84f8083db5 100644 --- a/includes/parser/Sanitizer.php +++ b/includes/parser/Sanitizer.php @@ -495,6 +495,7 @@ class Sanitizer { $bits = explode( '<', $text ); $text = str_replace( '>', '>', array_shift( $bits ) ); if ( !MWTidy::isEnabled() ) { + wfDeprecated( 'disabling tidy', '1.33' ); $tagstack = $tablestack = []; foreach ( $bits as $x ) { $regs = []; diff --git a/includes/specials/SpecialExpandTemplates.php b/includes/specials/SpecialExpandTemplates.php index 4587d40609..619665bdb4 100644 --- a/includes/specials/SpecialExpandTemplates.php +++ b/includes/specials/SpecialExpandTemplates.php @@ -117,6 +117,8 @@ class SpecialExpandTemplates extends SpecialPage { $config = $this->getConfig(); if ( MWTidy::isEnabled() && $options->getTidy() ) { $tmp = MWTidy::tidy( $tmp ); + } else { + wfDeprecated( 'disabling tidy', '1.33' ); } $out->addHTML( $tmp ); diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 12c60a7e30..3dee52136d 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -1136,6 +1136,12 @@ class ParserTestRunner { } else { $tidy = false; } + + # Suppress warnings about running tests without tidy + Wikimedia\suppressWarnings(); + wfDeprecated( 'disabling tidy' ); + Wikimedia\restoreWarnings(); + MWTidy::setInstance( $tidy ); $teardown[] = function () { MWTidy::destroySingleton(); diff --git a/tests/phpunit/includes/parser/SanitizerTest.php b/tests/phpunit/includes/parser/SanitizerTest.php index a8b0f90a3a..f6061b8cc6 100644 --- a/tests/phpunit/includes/parser/SanitizerTest.php +++ b/tests/phpunit/includes/parser/SanitizerTest.php @@ -100,6 +100,7 @@ class SanitizerTest extends MediaWikiTestCase { * @param bool $escaped Whether sanitizer let the tag in or escape it (ie: '<video>') */ public function testRemovehtmltagsOnHtml5Tags( $tag, $escaped ) { + $this->hideDeprecated( 'disabling tidy' ); MWTidy::setInstance( false ); if ( $escaped ) { @@ -162,6 +163,7 @@ class SanitizerTest extends MediaWikiTestCase { * @covers Sanitizer::removeHTMLtags */ public function testRemoveHTMLtags( $input, $output, $msg = null ) { + $this->hideDeprecated( 'disabling tidy' ); MWTidy::setInstance( false ); $this->assertEquals( $output, Sanitizer::removeHTMLtags( $input ), $msg ); } -- 2.20.1