Replace deprecated calls to OutputPage::parse()
authorC. Scott Ananian <cscott@cscott.net>
Fri, 26 Oct 2018 16:55:52 +0000 (12:55 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Mon, 29 Oct 2018 19:34:43 +0000 (15:34 -0400)
Use OutputPage::parseAsInterface() to tidy the output and make the
selection of user interface language explicit.

Bug: T198214
Change-Id: Ifeb1ca6eb8b5c743421b8f9e329f1e3658050e47

includes/EditPage.php
includes/actions/McrUndoAction.php
includes/skins/QuickTemplate.php
includes/skins/Skin.php
includes/specials/SpecialTags.php
includes/specials/SpecialUpload.php

index a79b974..632b38d 100644 (file)
@@ -1302,8 +1302,12 @@ class EditPage {
                                        // Messages: undo-success, undo-failure, undo-main-slot-only, undo-norev,
                                        // undo-nochange.
                                        $class = ( $undoMsg == 'success' ? '' : 'error ' ) . "mw-undo-{$undoMsg}";
-                                       $this->editFormPageTop .= $out->parse( "<div class=\"{$class}\">" .
-                                               $this->context->msg( 'undo-' . $undoMsg )->plain() . '</div>', true, /* interface */true );
+                                       $this->editFormPageTop .= Html::rawElement(
+                                               'div', [ 'class' => $class ],
+                                               $out->parseAsInterface(
+                                                       $this->context->msg( 'undo-' . $undoMsg )->plain()
+                                               )
+                                       );
                                }
 
                                if ( $content === false ) {
@@ -3868,9 +3872,10 @@ ERROR;
                                // Do not put big scary notice, if previewing the empty
                                // string, which happens when you initially edit
                                // a category page, due to automatic preview-on-open.
-                               $parsedNote = $out->parse( "<div class='previewnote'>" .
-                                       $this->context->msg( 'session_fail_preview_html' )->text() . "</div>",
-                                       true, /* interface */true );
+                               $parsedNote = Html::rawElement( 'div', [ 'class' => 'previewnote' ],
+                                       $out->parseAsInterface(
+                                               $this->context->msg( 'session_fail_preview_html' )->plain()
+                                       ) );
                        }
                        $this->incrementEditFailureStats( 'session_loss' );
                        return $parsedNote;
@@ -3984,15 +3989,22 @@ ERROR;
                }
 
                if ( $this->isConflict ) {
-                       $conflict = '<h2 id="mw-previewconflict">'
-                               . $this->context->msg( 'previewconflict' )->escaped() . "</h2>\n";
+                       $conflict = Html::rawElement(
+                               'h2', [ 'id' => 'mw-previewconflict' ],
+                               $this->context->msg( 'previewconflict' )->escaped()
+                       );
                } else {
                        $conflict = '<hr />';
                }
 
-               $previewhead = "<div class='previewnote'>\n" .
-                       '<h2 id="mw-previewheader">' . $this->context->msg( 'preview' )->escaped() . "</h2>" .
-                       $out->parse( $note, true, /* interface */true ) . $conflict . "</div>\n";
+               $previewhead = Html::rawElement(
+                       'div', [ 'class' => 'previewnote' ],
+                       Html::rawElement(
+                               'h2', [ 'id' => 'mw-previewheader' ],
+                               $this->context->msg( 'preview' )->escaped()
+                       ) .
+                       $out->parseAsInterface( $note ) . $conflict
+               );
 
                $pageViewLang = $this->mTitle->getPageViewLanguage();
                $attribs = [ 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(),
index 12fd4f4..b60820c 100644 (file)
@@ -283,9 +283,15 @@ class McrUndoAction extends FormAction {
                        $previewHTML = '';
                }
 
-               $previewhead = "<div class='previewnote'>\n" .
-                       '<h2 id="mw-previewheader">' . $this->context->msg( 'preview' )->escaped() . "</h2>" .
-                       $out->parse( $note, true, /* interface */true ) . "<hr /></div>\n";
+               $previewhead = Html::rawElement(
+                       'div', [ 'class' => 'previewnote' ],
+                       Html::element(
+                               'h2', [ 'id' => 'mw-previewheader' ],
+                               $this->context->msg( 'preview' )->text()
+                       ) .
+                       $out->parseAsInterface( $note ) .
+                       "<hr />"
+               );
 
                $pageViewLang = $this->getTitle()->getPageViewLanguage();
                $attribs = [ 'lang' => $pageViewLang->getHtmlCode(), 'dir' => $pageViewLang->getDir(),
index e4a2476..06d0f7b 100644 (file)
@@ -146,8 +146,8 @@ abstract class QuickTemplate {
        function msgWiki( $msgKey ) {
                global $wgOut;
 
-               $text = wfMessage( $msgKey )->text();
-               echo $wgOut->parse( $text );
+               $text = wfMessage( $msgKey )->plain();
+               echo $wgOut->parseAsInterface( $text );
        }
 
        /**
index 2c71571..fa09347 100644 (file)
@@ -1554,7 +1554,7 @@ abstract class Skin extends ContextSource {
                        // TTL in seconds
                        600,
                        function () use ( $notice ) {
-                               return $this->getOutput()->parse( $notice );
+                               return $this->getOutput()->parseAsInterface( $notice );
                        }
                );
 
index ca8ce89..fd2d46a 100644 (file)
@@ -307,7 +307,7 @@ class SpecialTags extends SpecialPage {
 
                        $headerText = $this->msg( 'tags-create-warnings-above', $tag,
                                count( $status->getWarningsArray() ) )->parseAsBlock() .
-                               $out->parse( $status->getWikiText() ) .
+                               $out->parseAsInterface( $status->getWikiText() ) .
                                $this->msg( 'tags-create-warnings-below' )->parseAsBlock();
 
                        $subform = HTMLForm::factory( 'ooui', $fields, $this->getContext() );
index 836b6df..d3abbc5 100644 (file)
@@ -483,7 +483,7 @@ class SpecialUpload extends SpecialPage {
                // Fetch the file if required
                $status = $this->mUpload->fetchFile();
                if ( !$status->isOK() ) {
-                       $this->showUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
+                       $this->showUploadError( $this->getOutput()->parseAsInterface( $status->getWikiText() ) );
 
                        return;
                }
@@ -553,7 +553,9 @@ class SpecialUpload extends SpecialPage {
                        $changeTagsStatus = ChangeTags::canAddTagsAccompanyingChange(
                                $changeTags, $this->getUser() );
                        if ( !$changeTagsStatus->isOK() ) {
-                               $this->showUploadError( $this->getOutput()->parse( $changeTagsStatus->getWikiText() ) );
+                               $this->showUploadError( $this->getOutput()->parseAsInterface(
+                                       $changeTagsStatus->getWikiText()
+                               ) );
 
                                return;
                        }
@@ -568,7 +570,9 @@ class SpecialUpload extends SpecialPage {
                );
 
                if ( !$status->isGood() ) {
-                       $this->showRecoverableUploadError( $this->getOutput()->parse( $status->getWikiText() ) );
+                       $this->showRecoverableUploadError(
+                               $this->getOutput()->parseAsInterface( $status->getWikiText() )
+                       );
 
                        return;
                }