Merge "Use OutputPage::addWikiTextAsInterface() instead of untidy addWikiText()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 22 Oct 2018 01:49:58 +0000 (01:49 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 22 Oct 2018 01:49:58 +0000 (01:49 +0000)
1  2 
includes/OutputPage.php
includes/page/Article.php
includes/page/ImagePage.php

diff --combined includes/OutputPage.php
@@@ -2460,7 -2460,6 +2460,7 @@@ class OutputPage extends ContextSource 
                                !$this->haveCacheVaryCookies()
                        ) {
                                if ( $config->get( 'UseESI' ) ) {
 +                                      wfDeprecated( '$wgUseESI = true', '1.33' );
                                        # We'll purge the proxy cache explicitly, but require end user agents
                                        # to revalidate against the proxy on each visit.
                                        # Surrogate-Control controls our CDN, Cache-Control downstream caches
                        }
                } else {
                        $this->prepareErrorPage( $this->msg( 'permissionserrors' ) );
-                       $this->addWikiText( $this->formatPermissionsErrorMessage( $errors, $action ) );
+                       $this->addWikiTextAsInterface( $this->formatPermissionsErrorMessage( $errors, $action ) );
                }
        }
  
         *
         * Is equivalent to:
         *
-        *    $wgOut->addWikiText( "<div class='error'>\n"
+        *    $wgOut->addWikiTextAsInterface( "<div class='error'>\n"
         *        . wfMessage( 'some-error' )->plain() . "\n</div>" );
         *
         * The newline after the opening div is needed in some wikitext. See T21226.
                        }
                        $s = str_replace( '$' . ( $n + 1 ), $this->msg( $name, $args )->plain(), $s );
                }
-               $this->addWikiText( $s );
+               $this->addWikiTextAsInterface( $s );
        }
  
        /**
@@@ -120,7 -120,7 +120,7 @@@ class Article implements Page 
         * here, there doesn't seem to be any other way to stop calling
         * OutputPage::enableSectionEditLinks() and still have it work as it did before.
         */
 -      private $disableSectionEditForRender = false;
 +      protected $viewIsRenderAction = false;
  
        /**
         * Constructor and clear the article
                if ( $outputPage->isPrintable() ) {
                        $parserOptions->setIsPrintable( true );
                        $poOptions['enableSectionEditLinks'] = false;
 -              } elseif ( $this->disableSectionEditForRender
 +              } elseif ( $this->viewIsRenderAction
                        || !$this->isCurrent() || !$this->getTitle()->quickUserCan( 'edit', $user )
                ) {
                        $poOptions['enableSectionEditLinks'] = false;
                                                        $outputPage->setRobotPolicy( 'noindex,nofollow' );
  
                                                        $errortext = $error->getWikiText( false, 'view-pool-error' );
-                                                       $outputPage->addWikiText( Html::errorBox( $errortext ) );
+                                                       $outputPage->addWikiTextAsInterface( Html::errorBox( $errortext ) );
                                                }
                                                # Connection or timeout error
                                                return;
  
                        $dir = $this->getContext()->getLanguage()->getDir();
                        $lang = $this->getContext()->getLanguage()->getHtmlCode();
-                       $outputPage->addWikiText( Xml::openElement( 'div', [
+                       $outputPage->addWikiTextAsInterface( Xml::openElement( 'div', [
                                'class' => "noarticletext mw-content-$dir",
                                'dir' => $dir,
                                'lang' => $lang,
        public function render() {
                $this->getContext()->getRequest()->response()->header( 'X-Robots-Tag: noindex' );
                $this->getContext()->getOutput()->setArticleBodyOnly( true );
 -              $this->disableSectionEditForRender = true;
 +              // We later set 'enableSectionEditLinks=false' based on this; also used by ImagePage
 +              $this->viewIsRenderAction = true;
                $this->view();
        }
  
                        );
  
                        if ( $error == '' ) {
-                               $outputPage->addWikiText(
+                               $outputPage->addWikiTextAsInterface(
                                        "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
                                );
                                $deleteLogPage = new LogPage( 'delete' );
@@@ -86,15 -86,18 +86,15 @@@ class ImagePage extends Article 
                $this->repo = $img->getRepo();
        }
  
 -      /**
 -       * Handler for action=render
 -       * Include body text only; none of the image extras
 -       */
 -      public function render() {
 -              $this->getContext()->getOutput()->setArticleBodyOnly( true );
 -              parent::view();
 -      }
 -
        public function view() {
                global $wgShowEXIF;
  
 +              // For action=render, include body text only; none of the image extras
 +              if ( $this->viewIsRenderAction ) {
 +                      parent::view();
 +                      return;
 +              }
 +
                $out = $this->getContext()->getOutput();
                $request = $this->getContext()->getRequest();
                $diff = $request->getVal( 'diff' );
                if ( $this->mExtraDescription ) {
                        $fol = $this->getContext()->msg( 'shareddescriptionfollows' );
                        if ( !$fol->isDisabled() ) {
-                               $out->addWikiText( $fol->plain() );
+                               $out->addWikiTextAsInterface( $fol->plain() );
                        }
                        $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
                }
                                'h2',
                                [ 'id' => 'metadata' ],
                                        $this->getContext()->msg( 'metadata' )->text() ) . "\n" );
-                       $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
+                       $out->addWikiTextAsInterface( $this->makeMetadataTable( $formattedMetadata ) );
                        $out->addModules( [ 'mediawiki.action.view.metadata' ] );
                }
  
                                // to the filename, because it can get copied with it.
                                // See T27277.
                                // phpcs:disable Generic.Files.LineLength
-                               $out->addWikiText( <<<EOT
+                               $out->addWikiTextAsInterface( <<<EOT
  <div class="fullMedia"><span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span></div>
  <div class="mediaWarning">$warning</div>
  EOT
                                );
                                // phpcs:enable
                        } else {
-                               $out->addWikiText( <<<EOT
+                               $out->addWikiTextAsInterface( <<<EOT
  <div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
  </div>
  EOT
                                        'file-no-thumb-animation'
                                )->plain();
  
-                               $out->addWikiText( <<<EOT
+                               $out->addWikiTextAsInterface( <<<EOT
  <div class="mw-noanimatethumb">{$noAnimMesg}</div>
  EOT
                                );
                $out->setRobotPolicy( 'noindex,nofollow' );
                $out->setArticleRelated( false );
                $out->enableClientCache( false );
-               $out->addWikiText( $description );
+               $out->addWikiTextAsInterface( $description );
        }
  
        /**