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
This commit is contained in:
C. Scott Ananian 2021-02-18 12:10:16 -05:00 committed by James D. Forrester
parent f6e4f7280b
commit e99cf5c98d
4 changed files with 57 additions and 2 deletions

View file

@ -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().

View file

@ -38,6 +38,7 @@ class MWTidy {
* <body> or <html> 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 );

View file

@ -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;
}

View file

@ -288,10 +288,59 @@ class RemexDriverTest extends MediaWikiUnitTestCase {
'foo <link rel="foo" href="bar" /> bar',
'<p>foo <link rel="foo" href="bar" /> bar</p>',
],
// From the old TidyTest class
[
'<mw:editsection> should survive tidy',
'<mw:editsection page="foo" section="bar">foo</mw:editsection>',
'<mw:editsection page="foo" section="bar">foo</mw:editsection>',
],
[
'<editsection> should survive tidy',
'<editsection page="foo" section="bar">foo</editsection>',
'<editsection page="foo" section="bar">foo</editsection>',
],
[
'<mw:toc> should survive tidy',
'<mw:toc>foo</mw:toc>',
'<mw:toc>foo</mw:toc>',
],
[
'<link> should survive tidy',
'<link foo="bar"/>foo',
"<link foo=\"bar\" /><p>foo</p>",
],
[
'<meta> should survive tidy',
'<meta foo="bar"/>foo',
"<meta foo=\"bar\" /><p>foo</p>",
],
];
public function provider() {
return self::$remexTidyTestData;
$testMathML = <<<'MathML'
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mi>a</mi>
<mo>&InvisibleTimes;</mo>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<mi>b</mi>
<mo>&InvisibleTimes; </mo>
<mi>x</mi>
<mo>+</mo>
<mi>c</mi>
</mrow>
</math>
MathML;
$testMathML = Sanitizer::normalizeCharReferences( $testMathML );
return array_merge( self::$remexTidyTestData, [ [
'<math> should survive tidy',
$testMathML,
$testMathML,
] ] );
}
/**