From: C. Scott Ananian Date: Wed, 19 Jun 2019 15:57:36 +0000 (-0400) Subject: Remove OutputPage::addWikitext()* functions, hard-deprecated in 1.32 X-Git-Tag: 1.34.0-rc.0~1325^2~2 X-Git-Url: https://git.cyclocoop.org/%20%27.%28%24debut%20%20%20%24par_page%29.%27?a=commitdiff_plain;h=8a80f58cefbbc5884ce6baf259c842d9cc51e317;p=lhc%2Fweb%2Fwiklou.git Remove OutputPage::addWikitext()* functions, hard-deprecated in 1.32 This starts cleaning up the programmer-visible API for OutputPage and removed some deprecated untidy parser modes. Change-Id: Ib464b57248f114b68424ec1175d36ad86d1319ad --- diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index 819c202e64..0e4081cfe5 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -211,6 +211,9 @@ because of Phabricator reports. * The constant DB_SLAVE, deprecated in 1.28, has been removed. Use DB_REPLICA. * Replacer, DoubleReplacer, HashtableReplacer and RegexlikeReplacer (deprecated in 1.32) have been removed. Closures should be used instead. +* OutputPage::addWikiText(), ::addWikiTextWithTitle(), ::addWikiTextTitleTidy(), + ::addWikiTextTidy(), ::addWikiTextTitle(), deprecated in 1.32, have been + removed. * … === Deprecations in 1.34 === diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2023d9183c..95073c0a4c 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1730,27 +1730,6 @@ class OutputPage extends ContextSource { return $this->mImageTimeKeys; } - /** - * Convert wikitext to HTML and add it to the buffer - * Default assumes that the current page title will be used. - * - * @param string $text - * @param bool $linestart Is this the start of a line? - * @param bool $interface Is this text in the user interface language? - * @throws MWException - * @deprecated since 1.32 due to untidy output; use - * addWikiTextAsInterface() if $interface is default value or true, - * or else addWikiTextAsContent() if $interface is false. - */ - public function addWikiText( $text, $linestart = true, $interface = true ) { - wfDeprecated( __METHOD__, '1.32' ); - $title = $this->getTitle(); - if ( !$title ) { - throw new MWException( 'Title is null' ); - } - $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/false, $interface ); - } - /** * Convert wikitext *in the user interface language* to HTML and * add it to the buffer. The result will not be @@ -1776,7 +1755,7 @@ class OutputPage extends ContextSource { if ( !$title ) { throw new MWException( 'Title is null' ); } - $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/true ); + $this->addWikiTextTitleInternal( $text, $title, $linestart, /*interface*/true ); } /** @@ -1797,7 +1776,7 @@ class OutputPage extends ContextSource { ) { $this->addWikiTextTitleInternal( $text, $this->getTitle(), - /*linestart*/true, /*tidy*/true, /*interface*/true, + /*linestart*/true, /*interface*/true, $wrapperClass ); } @@ -1826,79 +1805,7 @@ class OutputPage extends ContextSource { if ( !$title ) { throw new MWException( 'Title is null' ); } - $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/false ); - } - - /** - * Add wikitext with a custom Title object - * - * @param string $text Wikitext - * @param Title $title - * @param bool $linestart Is this the start of a line? - * @deprecated since 1.32 due to untidy output; use - * addWikiTextAsInterface() - */ - public function addWikiTextWithTitle( $text, Title $title, $linestart = true ) { - wfDeprecated( __METHOD__, '1.32' ); - $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/false, /*interface*/false ); - } - - /** - * Add wikitext *in content language* with a custom Title object. - * Output will be tidy. - * - * @param string $text Wikitext in content language - * @param Title $title - * @param bool $linestart Is this the start of a line? - * @deprecated since 1.32 to rename methods consistently; use - * addWikiTextAsContent() - */ - function addWikiTextTitleTidy( $text, Title $title, $linestart = true ) { - wfDeprecated( __METHOD__, '1.32' ); - $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/false ); - } - - /** - * Add wikitext *in content language*. Output will be tidy. - * - * @param string $text Wikitext in content language - * @param bool $linestart Is this the start of a line? - * @deprecated since 1.32 to rename methods consistently; use - * addWikiTextAsContent() - */ - public function addWikiTextTidy( $text, $linestart = true ) { - wfDeprecated( __METHOD__, '1.32' ); - $title = $this->getTitle(); - if ( !$title ) { - throw new MWException( 'Title is null' ); - } - $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/false ); - } - - /** - * Add wikitext with a custom Title object. - * Output is unwrapped. - * - * @param string $text Wikitext - * @param Title $title - * @param bool $linestart Is this the start of a line? - * @param bool $tidy Whether to use tidy. - * Setting this to false (or omitting it) is deprecated - * since 1.32; all wikitext should be tidied. - * For backwards-compatibility with prior MW releases, - * you may wish to invoke this method but set $tidy=true; - * this will result in equivalent output to the non-deprecated - * addWikiTextAsContent()/addWikiTextAsInterface() methods. - * @param bool $interface Whether it is an interface message - * (for example disables conversion) - * @deprecated since 1.32, use addWikiTextAsContent() or - * addWikiTextAsInterface() (depending on $interface) - */ - public function addWikiTextTitle( $text, Title $title, $linestart, - $tidy = false, $interface = false - ) { - wfDeprecated( __METHOD__, '1.32' ); - return $this->addWikiTextTitleInternal( $text, $title, $linestart, $tidy, $interface ); + $this->addWikiTextTitleInternal( $text, $title, $linestart, /*interface*/false ); } /** @@ -1918,14 +1825,10 @@ class OutputPage extends ContextSource { * @private */ private function addWikiTextTitleInternal( - $text, Title $title, $linestart, $tidy, $interface, $wrapperClass = null + $text, Title $title, $linestart, $interface, $wrapperClass = null ) { - if ( !$tidy ) { - wfDeprecated( 'disabling tidy', '1.32' ); - } - $parserOutput = $this->parseInternal( - $text, $title, $linestart, $tidy, $interface, /*language*/null + $text, $title, $linestart, true, $interface, /*language*/null ); $this->addParserOutput( $parserOutput, [ diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index f073f6ecf6..32ce08c0ad 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -1570,34 +1570,15 @@ class OutputPageTest extends MediaWikiTestCase { /** * @dataProvider provideAddWikiText - * @covers OutputPage::addWikiText * @covers OutputPage::addWikiTextAsInterface * @covers OutputPage::wrapWikiTextAsInterface * @covers OutputPage::addWikiTextAsContent - * @covers OutputPage::addWikiTextWithTitle - * @covers OutputPage::addWikiTextTitle - * @covers OutputPage::addWikiTextTidy - * @covers OutputPage::addWikiTextTitleTidy * @covers OutputPage::getHTML */ public function testAddWikiText( $method, array $args, $expected ) { $op = $this->newInstance(); $this->assertSame( '', $op->getHTML() ); - $this->hideDeprecated( 'OutputPage::addWikiText' ); - $this->hideDeprecated( 'OutputPage::addWikiTextTitle' ); - $this->hideDeprecated( 'OutputPage::addWikiTextWithTitle' ); - $this->hideDeprecated( 'OutputPage::addWikiTextTidy' ); - $this->hideDeprecated( 'OutputPage::addWikiTextTitleTidy' ); - $this->hideDeprecated( 'disabling tidy' ); - - if ( in_array( - $method, - [ 'addWikiTextWithTitle', 'addWikiTextTitleTidy', 'addWikiTextTitle' ] - ) && count( $args ) >= 2 && $args[1] === null ) { - // Special placeholder because we can't get the actual title in the provider - $args[1] = $op->getTitle(); - } if ( in_array( $method, [ 'addWikiTextAsInterface', 'addWikiTextAsContent' ] @@ -1612,37 +1593,7 @@ class OutputPageTest extends MediaWikiTestCase { public function provideAddWikiText() { $tests = [ - 'addWikiText' => [ - // Not tidied; this API is deprecated. - 'Simple wikitext' => [ - [ "'''Bold'''" ], - "

Bold\n

", - ], 'List at start' => [ - [ '* List' ], - "\n", - ], 'List not at start' => [ - [ '* Not a list', false ], - '* Not a list', - ], 'Non-interface' => [ - [ "'''Bold'''", true, false ], - "

Bold\n

", - ], 'No section edit links' => [ - [ '== Title ==' ], - "

Title

", - ], - ], - 'addWikiTextWithTitle' => [ - // Untidied; this API is deprecated - 'With title at start' => [ - [ '* {{PAGENAME}}', Title::newFromText( 'Talk:Some page' ) ], - "\n", - ], 'With title at start' => [ - [ '* {{PAGENAME}}', Title::newFromText( 'Talk:Some page' ), false ], - "* Some page", - ], - ], 'addWikiTextAsInterface' => [ - // Preferred interface: output is tidied 'Simple wikitext' => [ [ "'''Bold'''" ], "

Bold\n

", @@ -1670,7 +1621,6 @@ class OutputPageTest extends MediaWikiTestCase { ], ], 'addWikiTextAsContent' => [ - // Preferred interface: output is tidied 'SpecialNewimages' => [ [ "

\nMy message" ], '

' . "\nMy message

" @@ -1708,41 +1658,6 @@ class OutputPageTest extends MediaWikiTestCase { ], ]; - // Test all the others on addWikiTextTitle as well - foreach ( $tests['addWikiText'] as $key => $val ) { - $args = [ $val[0][0], null, $val[0][1] ?? true, false, $val[0][2] ?? true ]; - $tests['addWikiTextTitle']["$key (addWikiTextTitle)"] = - array_merge( [ $args ], array_slice( $val, 1 ) ); - } - foreach ( $tests['addWikiTextWithTitle'] as $key => $val ) { - $args = [ $val[0][0], $val[0][1], $val[0][2] ?? true ]; - $tests['addWikiTextTitle']["$key (addWikiTextTitle)"] = - array_merge( [ $args ], array_slice( $val, 1 ) ); - } - foreach ( $tests['addWikiTextAsInterface'] as $key => $val ) { - $args = [ $val[0][0], $val[0][2] ?? null, $val[0][1] ?? true, true, true ]; - $tests['addWikiTextTitle']["$key (addWikiTextTitle)"] = - array_merge( [ $args ], array_slice( $val, 1 ) ); - } - foreach ( $tests['addWikiTextAsContent'] as $key => $val ) { - $args = [ $val[0][0], $val[0][2] ?? null, $val[0][1] ?? true, true, false ]; - $tests['addWikiTextTitle']["$key (addWikiTextTitle)"] = - array_merge( [ $args ], array_slice( $val, 1 ) ); - } - // addWikiTextTidy / addWikiTextTitleTidy were old aliases of - // addWikiTextAsContent - foreach ( $tests['addWikiTextAsContent'] as $key => $val ) { - if ( count( $val[0] ) > 2 ) { - $args = [ $val[0][0], $val[0][2], $val[0][1] ?? true ]; - $tests['addWikiTextTitleTidy']["$key (addWikiTextTitleTidy)"] = - array_merge( [ $args ], array_slice( $val, 1 ) ); - } else { - $args = [ $val[0][0], $val[0][1] ?? true ]; - $tests['addWikiTextTidy']["$key (addWikiTextTidy)"] = - array_merge( [ $args ], array_slice( $val, 1 ) ); - } - } - // We have to reformat our array to match what PHPUnit wants $ret = []; foreach ( $tests as $key => $subarray ) { @@ -1755,17 +1670,6 @@ class OutputPageTest extends MediaWikiTestCase { return $ret; } - /** - * @covers OutputPage::addWikiText - */ - public function testAddWikiTextNoTitle() { - $this->hideDeprecated( 'OutputPage::addWikiText' ); - $this->setExpectedException( MWException::class, 'Title is null' ); - - $op = $this->newInstance( [], null, 'notitle' ); - $op->addWikiText( 'a' ); - } - /** * @covers OutputPage::addWikiTextAsInterface */