Remove most support for configuring Tidy, including Raggett
authorC. Scott Ananian <cscott@cscott.net>
Wed, 17 Oct 2018 14:05:02 +0000 (10:05 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Thu, 15 Nov 2018 17:22:06 +0000 (12:22 -0500)
Remex is pure PHP so there is no reason to use an external tidy any
more. Configuration variables and implementation classes were
deprecated in 1.32 or earlier.  We've kept only $wgTidyConfig
which can be used for experimental features or debugging Remex.

Bug: T198214
Change-Id: I99d48f858d97b6e1d1e6cd76a42c960cc2c61f9f

15 files changed:
.phpcs.xml
RELEASE-NOTES-1.33
includes/DefaultSettings.php
includes/parser/MWTidy.php
includes/tidy/RaggettBase.php [deleted file]
includes/tidy/RaggettExternal.php [deleted file]
includes/tidy/RaggettInternalHHVM.php [deleted file]
includes/tidy/RaggettInternalPHP.php [deleted file]
includes/tidy/RaggettWrapper.php [deleted file]
includes/tidy/tidy.conf [deleted file]
maintenance/dictionary/mediawiki.dic
tests/common/TestsAutoLoader.php
tests/parser/ParserTestRunner.php
tests/parser/TidySupport.php [deleted file]
tests/phpunit/includes/parser/SanitizerTest.php

index 2bce5b2..c0154c7 100644 (file)
                <exclude-pattern>includes/export/DumpPipeOutput\.php</exclude-pattern>
                <exclude-pattern>includes/resourceloader/ResourceLoaderImage\.php</exclude-pattern>
                <exclude-pattern>includes/shell/Command\.php</exclude-pattern>
-               <exclude-pattern>includes/tidy/RaggettExternal\.php</exclude-pattern>
                <exclude-pattern>maintenance/dumpTextPass\.php</exclude-pattern>
                <exclude-pattern>maintenance/mysql\.php</exclude-pattern>
                <exclude-pattern>maintenance/storage/recompressTracked\.php</exclude-pattern>
index c573a59..1b9b723 100644 (file)
@@ -26,6 +26,11 @@ production.
 * (T199334) $wgTagStatisticsNewTable — This temporary setting, added in
   MediaWiki 1.32, has now been removed. When loading Special:Tags, MediaWiki
   will now always use the `change_tag_def` instead of the `change_tag` table.
+* MediaWiki now always tidies user output, and most related
+  configuration has been removed. Thus $wgUseTidy, $wgTidyBin,
+  $wgTidyConf, $wgTidyOpts, $wgTidyInternal, and $wgDebugTidy, all
+  deprecated since 1.26, have now all been removed. The $wgTidyConfig
+  setting remains only for Remex experimental features or debugging.
 * …
 
 === New features in 1.33 ===
@@ -92,6 +97,9 @@ because of Phabricator reports.
 * ParserOptions defaults 'tidy' to true now, since the untidy modes of the
   parser are being deprecated and ParserOptions::getCanonicalOverrides()
   has always been true at any rate.
+* Support for disabling tidy and external tidy implementations has been removed.
+  This was deprecated in 1.32. The pure PHP Remex tidy implementation is now
+  used and no configuration is necessary.
 * A number of deprecated methods for API documentation, intended for overriding
   by extensions, are no longer called by MediaWiki, and will emit deprecation
   notices if your extension attempts to use them:
index 15cb5bf..2104a78 100644 (file)
@@ -4281,74 +4281,24 @@ $wgAllowImageTag = false;
 /**
  * Configuration for HTML postprocessing tool. Set this to a configuration
  * array to enable an external tool. By default, we now use the RemexHtml
- * library; historically, Dave Raggett's "HTML Tidy" was typically used.
- * See https://www.w3.org/People/Raggett/tidy/
- *
- * Setting this to null is deprecated.
- *
- * If this is null and $wgUseTidy is true, the deprecated configuration
- * parameters will be used instead.
- *
- * If this is null and $wgUseTidy is false, a pure PHP fallback will be used.
- * (Equivalent to setting `$wgTidyConfig['driver'] = 'disabled'`.)
- *
- * Keys are:
- *  - driver: May be:
- *    - RemexHtml: Use the RemexHtml library in PHP
- *    - RaggettInternalHHVM: Use the limited-functionality HHVM extension
- *      Deprecated since 1.32.
- *    - RaggettInternalPHP: Use the PECL extension
- *      Deprecated since 1.32.
- *    - RaggettExternal: Shell out to an external binary (tidyBin)
- *      Deprecated since 1.32.
- *    - disabled: Disable tidy pass and use a hacky pure PHP workaround
- *      (this is what setting $wgUseTidy to false used to do)
- *      Deprecated since 1.32.
- *
- *  - tidyConfigFile: Path to configuration file for any of the Raggett drivers
- *  - debugComment: True to add a comment to the output with warning messages
- *  - tidyBin: For RaggettExternal, the path to the tidy binary.
- *  - tidyCommandLine: For RaggettExternal, additional command line options.
+ * library; historically, other postprocessors were used.
+ *
+ * Setting this to null will use default settings.
+ *
+ * Keys include:
+ *  - driver: formerly used to select a postprocessor; now ignored.
+ *  - treeMutationTrace: a boolean to turn on Remex tracing
+ *  - serializerTrace: a boolean to turn on Remex tracing
+ *  - mungerTrace: a boolean to turn on Remex tracing
+ *  - pwrap: whether <p> wrapping should be done (default true)
+ *
+ * See includes/tidy/RemexDriver.php for detail on configuration.
+ *
+ * Overriding the default configuration is strongly discouraged in
+ * production.
  */
 $wgTidyConfig = [ 'driver' => 'RemexHtml' ];
 
-/**
- * Set this to true to use the deprecated tidy configuration parameters.
- * @deprecated since 1.26, use $wgTidyConfig['driver'] = 'disabled'
- */
-$wgUseTidy = false;
-
-/**
- * The path to the tidy binary.
- * @deprecated since 1.26, use $wgTidyConfig['tidyBin']
- */
-$wgTidyBin = 'tidy';
-
-/**
- * The path to the tidy config file
- * @deprecated since 1.26, use $wgTidyConfig['tidyConfigFile']
- */
-$wgTidyConf = $IP . '/includes/tidy/tidy.conf';
-
-/**
- * The command line options to the tidy binary
- * @deprecated since 1.26, use $wgTidyConfig['tidyCommandLine']
- */
-$wgTidyOpts = '';
-
-/**
- * Set this to true to use the tidy extension
- * @deprecated since 1.26, use $wgTidyConfig['driver']
- */
-$wgTidyInternal = extension_loaded( 'tidy' );
-
-/**
- * Put tidy warnings in HTML comments
- * Only works for internal tidy.
- * @deprecated since 1.26, use $wgTidyConfig['debugComment']
- */
-$wgDebugTidy = false;
-
 /**
  * Allow raw, unchecked HTML in "<html>...</html>" sections.
  * THIS IS VERY DANGEROUS on a publicly editable site, so USE wgGroupPermissions
index 8881786..fce67fd 100644 (file)
  */
 
 /**
- * Class to interact with HTML tidy
- *
- * Either the external tidy program or the in-process tidy extension
- * will be used depending on availability. Override the default
- * $wgTidyInternal setting to disable the internal if it's not working.
+ * Class to interact with and configure Remex tidy
  *
  * @ingroup Parser
  */
@@ -34,7 +30,7 @@ class MWTidy {
        private static $instance;
 
        /**
-        * Interface with html tidy.
+        * Interface with Remex tidy.
         * If tidy isn't able to correct the markup, the original will be
         * returned in all its glory with a warning comment appended.
         *
@@ -63,34 +59,9 @@ class MWTidy {
         * @return bool|\MediaWiki\Tidy\TidyDriverBase
         */
        public static function singleton() {
-               global $wgUseTidy, $wgTidyInternal, $wgTidyConf, $wgDebugTidy, $wgTidyConfig,
-                       $wgTidyBin, $wgTidyOpts;
-
+               global $wgTidyConfig;
                if ( self::$instance === null ) {
-                       if ( $wgTidyConfig !== null ) {
-                               $config = $wgTidyConfig;
-                       } elseif ( $wgUseTidy ) {
-                               // b/c configuration
-                               wfDeprecated( '$wgUseTidy', '1.26' );
-                               $config = [
-                                       'tidyConfigFile' => $wgTidyConf,
-                                       'debugComment' => $wgDebugTidy,
-                                       'tidyBin' => $wgTidyBin,
-                                       'tidyCommandLine' => $wgTidyOpts ];
-                               if ( $wgTidyInternal ) {
-                                       if ( wfIsHHVM() ) {
-                                               $config['driver'] = 'RaggettInternalHHVM';
-                                       } else {
-                                               $config['driver'] = 'RaggettInternalPHP';
-                                       }
-                               } else {
-                                       $config['driver'] = 'RaggettExternal';
-                               }
-                       } else {
-                               wfDeprecated( '$wgTidyConfig = null and $wgUseTidy = false', '1.26' );
-                               return false;
-                       }
-                       self::$instance = self::factory( $config );
+                       self::$instance = self::factory( $wgTidyConfig );
                }
                return self::$instance;
        }
@@ -98,38 +69,21 @@ class MWTidy {
        /**
         * Create a new Tidy driver object from configuration.
         * @see $wgTidyConfig
-        * @param array $config
+        * @param array|null $config Optional since 1.33
         * @return bool|\MediaWiki\Tidy\TidyDriverBase
         * @throws MWException
         */
-       public static function factory( array $config ) {
-               switch ( $config['driver'] ) {
-                       case 'RaggettInternalHHVM':
-                               $instance = new MediaWiki\Tidy\RaggettInternalHHVM( $config );
-                               break;
-                       case 'RaggettInternalPHP':
-                               $instance = new MediaWiki\Tidy\RaggettInternalPHP( $config );
-                               break;
-                       case 'RaggettExternal':
-                               $instance = new MediaWiki\Tidy\RaggettExternal( $config );
-                               break;
-                       case 'RemexHtml':
-                               $instance = new MediaWiki\Tidy\RemexDriver( $config );
-                               break;
-                       case 'disabled':
-                               wfDeprecated( '"disabled" tidy driver', '1.32' );
-                               return false;
-                       default:
-                               throw new MWException( "Invalid tidy driver: \"{$config['driver']}\"" );
-               }
-               return $instance;
+       public static function factory( array $config = null ) {
+               return new MediaWiki\Tidy\RemexDriver( $config ?? [] );
        }
 
        /**
         * Set the driver to be used. This is for testing.
         * @param MediaWiki\Tidy\TidyDriverBase|false|null $instance
+        * @deprecated Since 1.33
         */
        public static function setInstance( $instance ) {
+               wfDeprecated( __METHOD__, '1.33' );
                self::$instance = $instance;
        }
 
diff --git a/includes/tidy/RaggettBase.php b/includes/tidy/RaggettBase.php
deleted file mode 100644 (file)
index 878099f..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-namespace MediaWiki\Tidy;
-
-use MWException;
-
-/**
- * @deprecated since 1.32, use RemexDriver
- */
-abstract class RaggettBase extends TidyDriverBase {
-
-       function __construct( $config ) {
-               parent::__construct( $config );
-
-               // All tidy modes other than remex are deprecated.
-               wfDeprecated( __METHOD__, '1.32' );
-       }
-
-       /**
-        * Generic interface for wrapping and unwrapping HTML for Dave Raggett's tidy.
-        *
-        * @param string $text Hideous HTML input
-        * @return string Corrected HTML output
-        */
-       public function tidy( $text ) {
-               $wrapper = new RaggettWrapper;
-               $wrappedtext = $wrapper->getWrapped( $text );
-
-               $retVal = null;
-               $correctedtext = $this->cleanWrapped( $wrappedtext, false, $retVal );
-
-               if ( $retVal < 0 ) {
-                       wfDebug( "Possible tidy configuration error!\n" );
-                       return $text . "\n<!-- Tidy was unable to run -->\n";
-               } elseif ( is_null( $correctedtext ) ) {
-                       wfDebug( "Tidy error detected!\n" );
-                       return $text . "\n<!-- Tidy found serious XHTML errors -->\n";
-               }
-
-               $correctedtext = $wrapper->postprocess( $correctedtext ); // restore any hidden tokens
-
-               return $correctedtext;
-       }
-
-       public function validate( $text, &$errorStr ) {
-               $retval = 0;
-               $errorStr = $this->cleanWrapped( $text, true, $retval );
-               return ( $retval < 0 && $errorStr == '' ) || $retval == 0;
-       }
-
-       /**
-        * Perform a clean/repair operation
-        * @param string $text HTML to check
-        * @param bool $stderr Whether to read result from STDERR rather than STDOUT
-        * @param int|null &$retval Exit code (-1 on internal error)
-        * @return null|string
-        * @throws MWException
-        */
-       abstract protected function cleanWrapped( $text, $stderr = false, &$retval = null );
-}
diff --git a/includes/tidy/RaggettExternal.php b/includes/tidy/RaggettExternal.php
deleted file mode 100644 (file)
index 0b485c7..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-
-namespace MediaWiki\Tidy;
-
-/**
- * @deprecated since 1.32, use RemexDriver
- */
-class RaggettExternal extends RaggettBase {
-       /**
-        * Spawn an external HTML tidy process and get corrected markup back from it.
-        * Also called in OutputHandler.php for full page validation
-        *
-        * @param string $text HTML to check
-        * @param bool $stderr Whether to read result from STDERR rather than STDOUT
-        * @param int|null &$retval Exit code (-1 on internal error)
-        * @return string|null
-        */
-       protected function cleanWrapped( $text, $stderr = false, &$retval = null ) {
-               $cleansource = '';
-               $opts = ' -utf8';
-
-               if ( $stderr ) {
-                       $descriptorspec = [
-                               0 => [ 'pipe', 'r' ],
-                               1 => [ 'file', wfGetNull(), 'a' ],
-                               2 => [ 'pipe', 'w' ]
-                       ];
-               } else {
-                       $descriptorspec = [
-                               0 => [ 'pipe', 'r' ],
-                               1 => [ 'pipe', 'w' ],
-                               2 => [ 'file', wfGetNull(), 'a' ]
-                       ];
-               }
-
-               $readpipe = $stderr ? 2 : 1;
-               $pipes = [];
-
-               $process = proc_open(
-                       "{$this->config['tidyBin']} -config {$this->config['tidyConfigFile']} " .
-                       $this->config['tidyCommandLine'] . $opts, $descriptorspec, $pipes );
-
-               // NOTE: At least on linux, the process will be created even if tidy is not installed.
-               //      This means that missing tidy will be treated as a validation failure.
-
-               if ( is_resource( $process ) ) {
-                       // Theoretically, this style of communication could cause a deadlock
-                       // here. If the stdout buffer fills up, then writes to stdin could
-                       // block. This doesn't appear to happen with tidy, because tidy only
-                       // writes to stdout after it's finished reading from stdin. Search
-                       // for tidyParseStdin and tidySaveStdout in console/tidy.c
-                       fwrite( $pipes[0], $text );
-                       fclose( $pipes[0] );
-                       while ( !feof( $pipes[$readpipe] ) ) {
-                               $cleansource .= fgets( $pipes[$readpipe], 1024 );
-                       }
-                       fclose( $pipes[$readpipe] );
-                       $retval = proc_close( $process );
-               } else {
-                       wfWarn( "Unable to start external tidy process" );
-                       $retval = -1;
-               }
-
-               if ( !$stderr && $cleansource == '' && $text != '' ) {
-                       // Some kind of error happened, so we couldn't get the corrected text.
-                       // Just give up; we'll use the source text and append a warning.
-                       $cleansource = null;
-               }
-
-               return $cleansource;
-       }
-
-       public function supportsValidate() {
-               return true;
-       }
-}
diff --git a/includes/tidy/RaggettInternalHHVM.php b/includes/tidy/RaggettInternalHHVM.php
deleted file mode 100644 (file)
index 1681dc4..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-namespace MediaWiki\Tidy;
-
-/**
- * @deprecated since 1.32, use RemexDriver
- */
-class RaggettInternalHHVM extends RaggettBase {
-       /**
-        * Use the HTML tidy extension to use the tidy library in-process,
-        * saving the overhead of spawning a new process.
-        *
-        * @param string $text HTML to check
-        * @param bool $stderr Whether to read result from error status instead of output
-        * @param int|null &$retval Exit code (-1 on internal error)
-        * @return string|null
-        */
-       protected function cleanWrapped( $text, $stderr = false, &$retval = null ) {
-               if ( $stderr ) {
-                       throw new \Exception( "\$stderr cannot be used with RaggettInternalHHVM" );
-               }
-               $cleansource = tidy_repair_string( $text, $this->config['tidyConfigFile'], 'utf8' );
-               if ( $cleansource === false ) {
-                       $cleansource = null;
-                       $retval = -1;
-               } else {
-                       $retval = 0;
-               }
-
-               return $cleansource;
-       }
-}
diff --git a/includes/tidy/RaggettInternalPHP.php b/includes/tidy/RaggettInternalPHP.php
deleted file mode 100644 (file)
index c1050cc..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-namespace MediaWiki\Tidy;
-
-/**
- * @deprecated since 1.32, use RemexDriver
- */
-class RaggettInternalPHP extends RaggettBase {
-       /**
-        * Use the HTML tidy extension to use the tidy library in-process,
-        * saving the overhead of spawning a new process.
-        *
-        * @param string $text HTML to check
-        * @param bool $stderr Whether to read result from error status instead of output
-        * @param int|null &$retval Exit code (-1 on internal error)
-        * @return string|null
-        */
-       protected function cleanWrapped( $text, $stderr = false, &$retval = null ) {
-               if ( !class_exists( 'tidy' ) ) {
-                       wfWarn( "Unable to load internal tidy class." );
-                       $retval = -1;
-
-                       return null;
-               }
-
-               $tidy = new \tidy;
-               $tidy->parseString( $text, $this->config['tidyConfigFile'], 'utf8' );
-
-               if ( $stderr ) {
-                       $retval = $tidy->getStatus();
-                       return $tidy->errorBuffer;
-               }
-
-               $tidy->cleanRepair();
-               $retval = $tidy->getStatus();
-               if ( $retval == 2 ) {
-                       // 2 is magic number for fatal error
-                       // https://secure.php.net/manual/en/tidy.getstatus.php
-                       $cleansource = null;
-               } else {
-                       $cleansource = tidy_get_output( $tidy );
-                       if ( !empty( $this->config['debugComment'] ) && $retval > 0 ) {
-                               $cleansource .= "<!--\nTidy reports:\n" .
-                                       str_replace( '-->', '--&gt;', $tidy->errorBuffer ) .
-                                       "\n-->";
-                       }
-               }
-
-               return $cleansource;
-       }
-
-       public function supportsValidate() {
-               return true;
-       }
-}
diff --git a/includes/tidy/RaggettWrapper.php b/includes/tidy/RaggettWrapper.php
deleted file mode 100644 (file)
index 855282d..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-namespace MediaWiki\Tidy;
-
-use ParserOutput;
-use Parser;
-
-/**
- * Class used to hide mw:editsection tokens from Tidy so that it doesn't break them
- * or break on them. This is a bit of a hack for now, but hopefully in the future
- * we may create a real postprocessor or something that will replace this.
- * It's called wrapper because for now it basically takes over MWTidy::tidy's task
- * of wrapping the text in a xhtml block
- *
- * This re-uses some of the parser's UNIQ tricks, though some of it is private so it's
- * duplicated. Perhaps we should create an abstract marker hiding class.
- *
- * @ingroup Parser
- * @deprecated since 1.32
- */
-class RaggettWrapper {
-
-       /**
-        * @var array
-        */
-       protected $mTokens;
-
-       /**
-        * @var int
-        */
-       protected $mMarkerIndex;
-
-       /**
-        * @param string $text
-        * @return string
-        */
-       public function getWrapped( $text ) {
-               $this->mTokens = [];
-               $this->mMarkerIndex = 0;
-
-               // Replace <mw:editsection> elements with placeholders
-               $wrappedtext = preg_replace_callback( ParserOutput::EDITSECTION_REGEX,
-                       [ $this, 'replaceCallback' ], $text );
-               // ...and <mw:toc> markers
-               $wrappedtext = preg_replace_callback( '/\<\\/?mw:toc\>/',
-                       [ $this, 'replaceCallback' ], $wrappedtext );
-               // ... and <math> tags
-               $wrappedtext = preg_replace_callback( '/\<math(.*?)\<\\/math\>/s',
-                       [ $this, 'replaceCallback' ], $wrappedtext );
-               // Modify inline Microdata <link> and <meta> elements so they say <html-link> and <html-meta> so
-               // we can trick Tidy into not stripping them out by including them in tidy's new-empty-tags config
-               $wrappedtext = preg_replace( '!<(link|meta)([^>]*?)(/{0,1}>)!', '<html-$1$2$3', $wrappedtext );
-               // Similar for inline <style> tags, but those aren't empty.
-               $wrappedtext = preg_replace_callback( '!<style([^>]*)>(.*?)</style>!s', function ( $m ) {
-                       return '<html-style' . $m[1] . '>'
-                               . $this->replaceCallback( [ $m[2] ] )
-                               . '</html-style>';
-               }, $wrappedtext );
-
-               // Preserve empty li elements (T49673) by abusing Tidy's datafld hack
-               // The whitespace class is as in TY_(InitMap)
-               $wrappedtext = preg_replace( "!<li>([ \r\n\t\f]*)</li>!",
-                       '<li datafld="" class="mw-empty-elt">\1</li>', $wrappedtext );
-
-               // Wrap the whole thing in a doctype and body for Tidy.
-               $wrappedtext = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' .
-                       ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>' .
-                       '<head><title>test</title></head><body>' . $wrappedtext . '</body></html>';
-
-               return $wrappedtext;
-       }
-
-       /**
-        * @param array $m
-        * @return string
-        */
-       private function replaceCallback( array $m ) {
-               $marker = Parser::MARKER_PREFIX . "-item-{$this->mMarkerIndex}" . Parser::MARKER_SUFFIX;
-               $this->mMarkerIndex++;
-               $this->mTokens[$marker] = $m[0];
-               return $marker;
-       }
-
-       /**
-        * @param string $text
-        * @return string
-        */
-       public function postprocess( $text ) {
-               // Revert <html-{link,meta,style}> back to <{link,meta,style}>
-               $text = preg_replace( '!<html-(link|meta)([^>]*?)(/{0,1}>)!', '<$1$2$3', $text );
-               $text = preg_replace( '!<(/?)html-(style)([^>]*)>!', '<$1$2$3>', $text );
-
-               // Remove datafld
-               $text = str_replace( '<li datafld=""', '<li', $text );
-
-               // Restore the contents of placeholder tokens
-               $text = strtr( $text, $this->mTokens );
-
-               return $text;
-       }
-
-}
diff --git a/includes/tidy/tidy.conf b/includes/tidy/tidy.conf
deleted file mode 100644 (file)
index d4a3199..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# html tidy (http://tidy.sf.net) configuration
-# tidy - validate, correct, and pretty-print HTML files
-# see: man 1 tidy, http://tidy.sourceforge.net/docs/quickref.html
-
-show-body-only: yes
-force-output: yes
-tidy-mark: no
-wrap: 0
-wrap-attributes: no
-literal-attributes: yes
-output-xhtml: yes
-numeric-entities: yes
-enclose-text: yes
-enclose-block-text: yes
-quiet: yes
-quote-nbsp: yes
-fix-backslash: no
-fix-uri: no
-# Don't strip html5 elements we support
-# html-{meta,link} is a hack we use to prevent Tidy from stripping <meta> and <link> used in the body for Microdata
-new-empty-tags: html-meta, html-link, wbr, source, track
-new-inline-tags: video, audio, bdi, data, time, mark
-# html-style is a hack we use to prevent pre-HTML5 versions of Tidy from stripping <style> used in the body for TemplateStyles
-new-blocklevel-tags: html-style
index 0345ad6..eca58cd 100644 (file)
@@ -3306,7 +3306,6 @@ qvalues
 rabdiff
 radic
 radius
-raggett
 raii
 raimond
 random
index de8ddbf..0245572 100644 (file)
@@ -48,7 +48,6 @@ $wgAutoloadClasses += [
        'TestFileEditor' => "$testDir/parser/TestFileEditor.php",
        'TestFileReader' => "$testDir/parser/TestFileReader.php",
        'TestRecorder' => "$testDir/parser/TestRecorder.php",
-       'TidySupport' => "$testDir/parser/TidySupport.php",
 
        # tests/phpunit
        'EmptyResourceLoader' => "$testDir/phpunit/ResourceLoaderTestCase.php",
index bc5f1fc..b6c7b03 100644 (file)
@@ -75,11 +75,6 @@ class ParserTestRunner {
         */
        private $dbClone;
 
-       /**
-        * @var TidySupport
-        */
-       private $tidySupport;
-
        /**
         * @var TidyDriverBase
         */
@@ -167,12 +162,6 @@ class ParserTestRunner {
 
                $this->disableSaveParse = !empty( $options['disable-save-parse'] );
 
-               $this->tidySupport = new TidySupport( !empty( $options['use-tidy-config'] ) );
-               if ( !$this->tidySupport->isEnabled() ) {
-                       $this->recorder->warning(
-                               "Warning: tidy is not installed, skipping some tests\n" );
-               }
-
                if ( isset( $options['upload-dir'] ) ) {
                        $this->uploadDir = $options['upload-dir'];
                }
@@ -833,12 +822,7 @@ class ParserTestRunner {
                $options->setTimestamp( $this->getFakeTimestamp() );
 
                if ( isset( $opts['tidy'] ) ) {
-                       if ( !$this->tidySupport->isEnabled() ) {
-                               $this->recorder->skipped( $test, 'tidy extension is not installed' );
-                               return false;
-                       } else {
-                               $options->setTidy( true );
-                       }
+                       $options->setTidy( true );
                }
 
                if ( isset( $opts['title'] ) ) {
@@ -1130,7 +1114,7 @@ class ParserTestRunner {
                if ( isset( $opts['tidy'] ) ) {
                        // Cache a driver instance
                        if ( $this->tidyDriver === null ) {
-                               $this->tidyDriver = MWTidy::factory( $this->tidySupport->getConfig() );
+                               $this->tidyDriver = MWTidy::factory();
                        }
                        $tidy = $this->tidyDriver;
                } else {
@@ -1140,6 +1124,7 @@ class ParserTestRunner {
                # Suppress warnings about running tests without tidy
                Wikimedia\suppressWarnings();
                wfDeprecated( 'disabling tidy' );
+               wfDeprecated( 'MWTidy::setInstance' );
                Wikimedia\restoreWarnings();
 
                MWTidy::setInstance( $tidy );
diff --git a/tests/parser/TidySupport.php b/tests/parser/TidySupport.php
deleted file mode 100644 (file)
index 559960d..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Testing
- */
-
-/**
- * Initialize and detect the tidy support
- */
-class TidySupport {
-       private $enabled;
-       private $config;
-
-       /**
-        * Determine if there is a usable tidy.
-        * @param bool $useConfiguration
-        */
-       public function __construct( $useConfiguration = false ) {
-               global $wgUseTidy, $wgTidyBin, $wgTidyInternal, $wgTidyConfig,
-                       $wgTidyConf, $wgTidyOpts;
-
-               $this->enabled = true;
-               if ( $useConfiguration ) {
-                       if ( $wgTidyConfig !== null ) {
-                               $this->config = $wgTidyConfig;
-                       } elseif ( $wgUseTidy ) {
-                               $this->config = [
-                                       'tidyConfigFile' => $wgTidyConf,
-                                       'debugComment' => false,
-                                       'tidyBin' => $wgTidyBin,
-                                       'tidyCommandLine' => $wgTidyOpts
-                               ];
-                               if ( $wgTidyInternal ) {
-                                       $this->config['driver'] = wfIsHHVM() ? 'RaggettInternalHHVM' : 'RaggettInternalPHP';
-                               } else {
-                                       $this->config['driver'] = 'RaggettExternal';
-                               }
-                       } else {
-                               $this->enabled = false;
-                       }
-               } else {
-                       $this->config = [ 'driver' => 'RemexHtml' ];
-               }
-               if ( !$this->enabled ) {
-                       $this->config = [ 'driver' => 'disabled' ];
-               }
-       }
-
-       /**
-        * Returns true if tidy is usable
-        *
-        * @return bool
-        */
-       public function isEnabled() {
-               return $this->enabled;
-       }
-
-       public function getConfig() {
-               return $this->config;
-       }
-}
index f6061b8..ad8aa1e 100644 (file)
@@ -101,6 +101,7 @@ class SanitizerTest extends MediaWikiTestCase {
         */
        public function testRemovehtmltagsOnHtml5Tags( $tag, $escaped ) {
                $this->hideDeprecated( 'disabling tidy' );
+               $this->hideDeprecated( 'MWTidy::setInstance' );
                MWTidy::setInstance( false );
 
                if ( $escaped ) {
@@ -164,6 +165,7 @@ class SanitizerTest extends MediaWikiTestCase {
         */
        public function testRemoveHTMLtags( $input, $output, $msg = null ) {
                $this->hideDeprecated( 'disabling tidy' );
+               $this->hideDeprecated( 'MWTidy::setInstance' );
                MWTidy::setInstance( false );
                $this->assertEquals( $output, Sanitizer::removeHTMLtags( $input ), $msg );
        }