From e99cf5c98d3eaf9bf7ac700650b1361f3da75fd6 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Thu, 18 Feb 2021 12:10:16 -0500 Subject: [PATCH] Deprecate MWTidy and TidyDriverBase::supportsValidate() Also copied the tests that used to be in TidyTest into RemexDriverTest, so that we're not losing coverage when MWTidy is eventually removed. Bug: T198214 Change-Id: I0b301f6c98d0943ce4b6dc224f1066cb7bf244d1 --- RELEASE-NOTES-1.36 | 5 +- includes/parser/MWTidy.php | 1 + includes/tidy/TidyDriverBase.php | 2 + .../unit/includes/tidy/RemexDriverTest.php | 51 ++++++++++++++++++- 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.36 b/RELEASE-NOTES-1.36 index 01f675fc548..2c80f968ad8 100644 --- a/RELEASE-NOTES-1.36 +++ b/RELEASE-NOTES-1.36 @@ -401,7 +401,7 @@ because of Phabricator reports. doDeleteArticleReal(), doRollback(), and doEditContent(). * The ParserTestRunner no longer invokes the ParserTestTables hook. Instead, it clones all database tables before running tests, like MediaWikiIntegrationTest - does. If an extension was mis-using the hook to *exclude* tables from the + does. If an extension was mis-using the hook to *exclude* tables from the clone, that will no longer occur, and tests may fail. * The following classes, which were only loaded for tests and had no uses found in public MediaWiki-related git, were removed: @@ -595,6 +595,9 @@ because of Phabricator reports. * Command::cgroup() is deprecated and no longer functional. $wgShellCgroup is now implemented as an Executor option. * Command::restrict() is deprecated. Instead use the new separate accessors. +* MWTidy::tidy() is deprecated. Use MediaWikiServices::getTidy()-tidy() instead. +* TidyDriverBase::supportsValidate() is deprecated; it has always returned + false since 1.33. * WatchedItem::getUser hard-deprecated in favor of ::getUserIdentity since 1.36 * LogEntry::getPerformer() and its implementations have been hard-deprecated, in favor of ::getPerformerIdentity(). diff --git a/includes/parser/MWTidy.php b/includes/parser/MWTidy.php index 8859ca29303..ef533bc233c 100644 --- a/includes/parser/MWTidy.php +++ b/includes/parser/MWTidy.php @@ -38,6 +38,7 @@ class MWTidy { * or tag. * @return string Corrected HTML output * @throws MWException + * @deprecated since 1.36; use MediaWikiServices::getTidy()->tidy() instead */ public static function tidy( $text ) { return MediaWikiServices::getInstance()->getTidy()->tidy( $text ); diff --git a/includes/tidy/TidyDriverBase.php b/includes/tidy/TidyDriverBase.php index 449a19816d3..09fb49dc689 100644 --- a/includes/tidy/TidyDriverBase.php +++ b/includes/tidy/TidyDriverBase.php @@ -15,8 +15,10 @@ abstract class TidyDriverBase { /** * Return true if validate() can be used * @return bool + * @deprecated since 1.36, always returns false */ public function supportsValidate() { + wfDeprecated( __METHOD__, '1.36' ); return false; } diff --git a/tests/phpunit/unit/includes/tidy/RemexDriverTest.php b/tests/phpunit/unit/includes/tidy/RemexDriverTest.php index 2b710a4a71c..5dc1e571aa5 100644 --- a/tests/phpunit/unit/includes/tidy/RemexDriverTest.php +++ b/tests/phpunit/unit/includes/tidy/RemexDriverTest.php @@ -288,10 +288,59 @@ class RemexDriverTest extends MediaWikiUnitTestCase { 'foo bar', '

foo bar

', ], + // From the old TidyTest class + [ + ' should survive tidy', + 'foo', + 'foo', + ], + [ + ' should survive tidy', + 'foo', + 'foo', + ], + [ + ' should survive tidy', + 'foo', + 'foo', + ], + [ + ' should survive tidy', + 'foo', + "

foo

", + ], + [ + ' should survive tidy', + 'foo', + "

foo

", + ], ]; public function provider() { - return self::$remexTidyTestData; + $testMathML = <<<'MathML' + + + a + + + x + 2 + + + + b + + x + + + c + + +MathML; + $testMathML = Sanitizer::normalizeCharReferences( $testMathML ); + return array_merge( self::$remexTidyTestData, [ [ + ' should survive tidy', + $testMathML, + $testMathML, + ] ] ); } /**