Remove OutputPage::addWikitext()* functions, hard-deprecated in 1.32
authorC. Scott Ananian <cscott@cscott.net>
Wed, 19 Jun 2019 15:57:36 +0000 (11:57 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Wed, 19 Jun 2019 19:14:54 +0000 (15:14 -0400)
This starts cleaning up the programmer-visible API for OutputPage
and removed some deprecated untidy parser modes.

Change-Id: Ib464b57248f114b68424ec1175d36ad86d1319ad

RELEASE-NOTES-1.34
includes/OutputPage.php
tests/phpunit/includes/OutputPageTest.php

index 819c202..0e4081c 100644 (file)
@@ -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 ===
index 2023d91..95073c0 100644 (file)
@@ -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, [
index f073f6e..32ce08c 100644 (file)
@@ -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'''" ],
-                                       "<p><b>Bold</b>\n</p>",
-                               ], 'List at start' => [
-                                       [ '* List' ],
-                                       "<ul><li>List</li></ul>\n",
-                               ], 'List not at start' => [
-                                       [ '* Not a list', false ],
-                                       '* Not a list',
-                               ], 'Non-interface' => [
-                                       [ "'''Bold'''", true, false ],
-                                       "<p><b>Bold</b>\n</p>",
-                               ], 'No section edit links' => [
-                                       [ '== Title ==' ],
-                                       "<h2><span class=\"mw-headline\" id=\"Title\">Title</span></h2>",
-                               ],
-                       ],
-                       'addWikiTextWithTitle' => [
-                               // Untidied; this API is deprecated
-                               'With title at start' => [
-                                       [ '* {{PAGENAME}}', Title::newFromText( 'Talk:Some page' ) ],
-                                       "<ul><li>Some page</li></ul>\n",
-                               ], 'With title at start' => [
-                                       [ '* {{PAGENAME}}', Title::newFromText( 'Talk:Some page' ), false ],
-                                       "* Some page",
-                               ],
-                       ],
                        'addWikiTextAsInterface' => [
-                               // Preferred interface: output is tidied
                                'Simple wikitext' => [
                                        [ "'''Bold'''" ],
                                        "<p><b>Bold</b>\n</p>",
@@ -1670,7 +1621,6 @@ class OutputPageTest extends MediaWikiTestCase {
                                ],
                        ],
                        'addWikiTextAsContent' => [
-                               // Preferred interface: output is tidied
                                'SpecialNewimages' => [
                                        [ "<p lang='en' dir='ltr'>\nMy message" ],
                                        '<p lang="en" dir="ltr">' . "\nMy message</p>"
@@ -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
         */