Hard deprecate codepaths where tidy is disabled
authorC. Scott Ananian <cscott@cscott.net>
Tue, 26 Jun 2018 13:53:12 +0000 (09:53 -0400)
committerC. Scott Ananian <cananian@wikimedia.org>
Mon, 5 Nov 2018 18:49:16 +0000 (18:49 +0000)
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
includes/parser/Sanitizer.php
includes/specials/SpecialExpandTemplates.php
tests/parser/ParserTestRunner.php
tests/phpunit/includes/parser/SanitizerTest.php

index 3dc2eeb..b2097a9 100644 (file)
@@ -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''] -->
                                # <i>Something</i><a href="http://www.cool.com"..><i>cool></i></a>
index 85c71ee..84f8083 100644 (file)
@@ -495,6 +495,7 @@ class Sanitizer {
                $bits = explode( '<', $text );
                $text = str_replace( '>', '&gt;', array_shift( $bits ) );
                if ( !MWTidy::isEnabled() ) {
+                       wfDeprecated( 'disabling tidy', '1.33' );
                        $tagstack = $tablestack = [];
                        foreach ( $bits as $x ) {
                                $regs = [];
index 4587d40..619665b 100644 (file)
@@ -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 );
index 12c60a7..3dee521 100644 (file)
@@ -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();
index a8b0f90..f6061b8 100644 (file)
@@ -100,6 +100,7 @@ class SanitizerTest extends MediaWikiTestCase {
         * @param bool $escaped Whether sanitizer let the tag in or escape it (ie: '&lt;video&gt;')
         */
        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 );
        }