Hard deprecate unused OutputPage::addWikiText* methods
authorC. Scott Ananian <cscott@cscott.net>
Fri, 21 Sep 2018 17:16:42 +0000 (13:16 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Wed, 10 Oct 2018 18:54:27 +0000 (14:54 -0400)
Codesearch shows no users of `OutputPage::addWikiTextWithTitle()`,
and no users of `OutputPage::addWikiTextTitle()` (other than the
implicit uses by the other `OutputPage::addWikiText*()` methods).

These methods produce untidy output, which future parsers won't
support.

Bug: T198214
Change-Id: Id5ee3bdfa6c464e3a92af82af7bc7317ca9d07a9

includes/OutputPage.php
tests/phpunit/includes/OutputPageTest.php

index 5801a29..f2b343e 100644 (file)
@@ -1757,7 +1757,7 @@ class OutputPage extends ContextSource {
                if ( !$title ) {
                        throw new MWException( 'Title is null' );
                }
-               $this->addWikiTextTitle( $text, $title, $linestart, /*tidy*/false, $interface );
+               $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/false, $interface );
        }
 
        /**
@@ -1785,7 +1785,7 @@ class OutputPage extends ContextSource {
                if ( !$title ) {
                        throw new MWException( 'Title is null' );
                }
-               $this->addWikiTextTitle( $text, $title, $linestart, /*tidy*/true, /*interface*/true );
+               $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/true );
        }
 
        /**
@@ -1812,7 +1812,7 @@ class OutputPage extends ContextSource {
                if ( !$title ) {
                        throw new MWException( 'Title is null' );
                }
-               $this->addWikiTextTitle( $text, $title, $linestart, /*tidy*/true, /*interface*/false );
+               $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/false );
        }
 
        /**
@@ -1825,7 +1825,8 @@ class OutputPage extends ContextSource {
         *   addWikiTextAsInterface()
         */
        public function addWikiTextWithTitle( $text, Title $title, $linestart = true ) {
-               $this->addWikiTextTitle( $text, $title, $linestart );
+               wfDeprecated( __METHOD__, '1.32' );
+               $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/false, /*interface*/false );
        }
 
        /**
@@ -1839,7 +1840,7 @@ class OutputPage extends ContextSource {
         *   addWikiTextAsContent()
         */
        function addWikiTextTitleTidy( $text, Title $title, $linestart = true ) {
-               $this->addWikiTextTitle( $text, $title, $linestart, true );
+               $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/false );
        }
 
        /**
@@ -1855,7 +1856,7 @@ class OutputPage extends ContextSource {
                if ( !$title ) {
                        throw new MWException( 'Title is null' );
                }
-               $this->addWikiTextTitleTidy( $text, $title, $linestart );
+               $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/false );
        }
 
        /**
@@ -1879,6 +1880,27 @@ class OutputPage extends ContextSource {
         */
        public function addWikiTextTitle( $text, Title $title, $linestart,
                $tidy = false, $interface = false
+       ) {
+               wfDeprecated( __METHOD__, '1.32' );
+               return $this->addWikiTextTitleInternal( $text, $title, $linestart, $tidy, $interface );
+       }
+
+       /**
+        * 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.
+        * @param bool $interface Whether it is an interface message
+        *   (for example disables conversion)
+        * @private
+        */
+       private function addWikiTextTitleInternal(
+               $text, Title $title, $linestart, $tidy, $interface
        ) {
                global $wgParser;
 
index f9c293c..8a4b5c3 100644 (file)
@@ -1404,6 +1404,8 @@ class OutputPageTest extends MediaWikiTestCase {
                $op = $this->newInstance();
                $this->assertSame( '', $op->getHTML() );
 
+               $this->hideDeprecated( 'OutputPage::addWikiTextTitle' );
+               $this->hideDeprecated( 'OutputPage::addWikiTextWithTitle' );
                if ( in_array(
                        $method,
                        [ 'addWikiTextWithTitle', 'addWikiTextTitleTidy', 'addWikiTextTitle' ]