From 6f8431c4f540dbbbd9aacdd7a08a727384e3f845 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Tue, 26 Jun 2018 09:35:26 -0400 Subject: [PATCH] Hard-deprecate the $wgUseTidy option This has been soft-deprecated since MW 1.26; this hard-deprecation sets the stage for future removal of this old cruft. Bug: T198214 Depends-On: Idf246d05d116f63a73105b50a1929a7721fbe7b9 Change-Id: I2e7d990da1da378eb6e828d4b3c0f5a41791dd92 --- RELEASE-NOTES-1.32 | 4 ++++ docs/distributors.txt | 2 -- includes/DefaultSettings.php | 16 +++++++++++----- includes/parser/MWTidy.php | 2 ++ maintenance/compareParsers.php | 5 ++--- .../phpunit/includes/content/TextContentTest.php | 2 +- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 5954b872a7..de091ca9be 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -445,6 +445,10 @@ because of Phabricator reports. * Content::getDeletionUpdates has been deprecated in favor of ContentHandler::getDeletionUpdates() for overriding by extensions (T194038). Application logic should call WikiPage::doSecondaryDataUpdates() (T194037). +* (T198214) Old Tidy-related configuration settings, which were soft-deprecated + in MediaWiki 1.26, have now been hard deprecated. This affects $wgUseTidy, + $wgTidyBin, $wgTidyConf, $wgTidyOpts, $wgTidyInternal, and $wgDebugTidy. Use + $wgTidyConfig instead. === Other changes in 1.32 === * (T198811) The following tables have had their UNIQUE indexes turned into diff --git a/docs/distributors.txt b/docs/distributors.txt index 729dffa3a1..f2af458937 100644 --- a/docs/distributors.txt +++ b/docs/distributors.txt @@ -174,8 +174,6 @@ perhaps configure it to use them (see Configuration section of this document): "$wgAntivirus = 'clamav';". * DjVuLibre: Allows processing of DjVu files. To enable this, set "$wgDjvuDump = 'djvudump'; $wgDjvuRenderer = 'ddjvu'; $wgDjvuTxt = 'djvutxt';". - * HTML Tidy: Fixes errors in HTML at runtime. Can be enabled with - "$wgUseTidy = true;". * ImageMagick: For resizing images. "$wgUseImageMagick = true;" will enable it. PHP's GD can also be used, but ImageMagick is preferable. * HTTP cache such as Varnish or Squid: can provide a drastic speedup and a diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ab67225ca5..0fa2a9f01e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4267,10 +4267,13 @@ $wgAllowImageTag = false; * 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: @@ -4278,6 +4281,8 @@ $wgAllowImageTag = false; * - RaggettInternalPHP: Use the PECL extension * - RaggettExternal: Shell out to an external binary (tidyBin) * - RemexHtml: Use the RemexHtml library in PHP + * - disabled: Disable tidy pass and use a hacky pure PHP workaround + * (this is what setting $wgUseTidy to false used to do) * * - tidyConfigFile: Path to configuration file for any of the Raggett drivers * - debugComment: True to add a comment to the output with warning messages @@ -4288,37 +4293,38 @@ $wgTidyConfig = [ 'driver' => 'RemexHtml' ]; /** * Set this to true to use the deprecated tidy configuration parameters. - * @deprecated use $wgTidyConfig + * @deprecated since 1.26, use $wgTidyConfig['driver'] = 'disabled' */ $wgUseTidy = false; /** * The path to the tidy binary. - * @deprecated Use $wgTidyConfig['tidyBin'] + * @deprecated since 1.26, use $wgTidyConfig['tidyBin'] */ $wgTidyBin = 'tidy'; /** * The path to the tidy config file - * @deprecated Use $wgTidyConfig['tidyConfigFile'] + * @deprecated since 1.26, use $wgTidyConfig['tidyConfigFile'] */ $wgTidyConf = $IP . '/includes/tidy/tidy.conf'; /** * The command line options to the tidy binary - * @deprecated Use $wgTidyConfig['tidyCommandLine'] + * @deprecated since 1.26, use $wgTidyConfig['tidyCommandLine'] */ $wgTidyOpts = ''; /** * Set this to true to use the tidy extension - * @deprecated Use $wgTidyConfig['driver'] + * @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; diff --git a/includes/parser/MWTidy.php b/includes/parser/MWTidy.php index 5788986f2e..a73c28cdba 100644 --- a/includes/parser/MWTidy.php +++ b/includes/parser/MWTidy.php @@ -71,6 +71,7 @@ class MWTidy { $config = $wgTidyConfig; } elseif ( $wgUseTidy ) { // b/c configuration + wfDeprecated( '$wgUseTidy', '1.26' ); $config = [ 'tidyConfigFile' => $wgTidyConf, 'debugComment' => $wgDebugTidy, @@ -86,6 +87,7 @@ class MWTidy { $config['driver'] = 'RaggettExternal'; } } else { + wfDeprecated( '$wgTidyConfig = null and $wgUseTidy = false', '1.26' ); return false; } self::$instance = self::factory( $config ); diff --git a/maintenance/compareParsers.php b/maintenance/compareParsers.php index fe6e604d96..b01dde6ee2 100644 --- a/maintenance/compareParsers.php +++ b/maintenance/compareParsers.php @@ -95,9 +95,8 @@ class CompareParsers extends DumpIterator { $this->options = ParserOptions::newFromUser( $user ); if ( $this->hasOption( 'tidy' ) ) { - global $wgUseTidy; - if ( !$wgUseTidy ) { - $this->fatalError( 'Tidy was requested but $wgUseTidy is not set in LocalSettings.php' ); + if ( !MWTidy::isEnabled() ) { + $this->fatalError( 'Tidy was requested but $wgTidyConfig is not set in LocalSettings.php' ); } $this->options->setTidy( true ); } diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php index d69cfd1a86..a8904940f6 100644 --- a/tests/phpunit/includes/content/TextContentTest.php +++ b/tests/phpunit/includes/content/TextContentTest.php @@ -32,7 +32,7 @@ class TextContentTest extends MediaWikiLangTestCase { CONTENT_MODEL_CSS, CONTENT_MODEL_JAVASCRIPT, ], - 'wgUseTidy' => false, + 'wgTidyConfig' => [ 'driver' => 'disabled' ], 'wgCapitalLinks' => true, 'wgHooks' => [], // bypass hook ContentGetParserOutput that force custom rendering ] ); -- 2.20.1