Hard deprecate non-tidy OutputPage::addWikiText() method
authorC. Scott Ananian <cscott@cscott.net>
Tue, 25 Sep 2018 14:05:55 +0000 (10:05 -0400)
committerJforrester <jforrester@wikimedia.org>
Wed, 24 Oct 2018 20:05:58 +0000 (20:05 +0000)
Tidy will always be enabled with our future parsers.  Hard-deprecate
this method which doesn't tidy the output.

Users of `OutputPage::addWikiText()` will be converted one-by-one to
`OutputPage::addWikiTextAsInterface()` so that any unexpected issues
(deliberately untidy wikitext added, which should be rare) can be
addressed.

Bug: T198214
Depends-On: I778ba9e6efed576605f492c9a073c7203b6c0477
Depends-On: I16529879a3b3aed960c5dc006e2af513d7e91fcd
Change-Id: If8353c37245d9d233d589f82c198668ccb3fce05

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

index 3a0a529..32f46b1 100644 (file)
@@ -1758,6 +1758,7 @@ class OutputPage extends ContextSource {
         *    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' );
@@ -1936,6 +1937,10 @@ class OutputPage extends ContextSource {
        ) {
                global $wgParser;
 
+               if ( !$tidy ) {
+                       wfDeprecated( 'disabling tidy', '1.32' );
+               }
+
                $popts = $this->parserOptions();
                $oldTidy = $popts->setTidy( $tidy );
                $popts->setInterfaceMessage( (bool)$interface );
index 18d2a8a..ba9a94e 100644 (file)
@@ -1442,10 +1442,13 @@ class OutputPageTest extends MediaWikiTestCase {
                $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' ]
@@ -1614,6 +1617,7 @@ class OutputPageTest extends MediaWikiTestCase {
         * @covers OutputPage::addWikiText
         */
        public function testAddWikiTextNoTitle() {
+               $this->hideDeprecated( 'OutputPage::addWikiText' );
                $this->setExpectedException( MWException::class, 'Title is null' );
 
                $op = $this->newInstance( [], null, 'notitle' );