Merge "Move condition to not show form one level up"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 9 Nov 2016 16:18:51 +0000 (16:18 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 9 Nov 2016 16:18:51 +0000 (16:18 +0000)
1  2 
includes/EditPage.php

diff --combined includes/EditPage.php
@@@ -1044,6 -1044,7 +1044,6 @@@ class EditPage 
  
                // Allow extensions to modify form data
                Hooks::run( 'EditPage::importFormData', [ $this, $request ] );
 -
        }
  
        /**
                                // being set. This is used by ConfirmEdit to display a captcha
                                // without any error message cruft.
                        } else {
 -                              $this->hookError = $this->formatStatusErrors( $status );
 +                              $this->hookError = $status->getWikiText();
                        }
                        // Use the existing $status->value if the hook set it
                        if ( !$status->value ) {
                } elseif ( !$status->isOK() ) {
                        # ...or the hook could be expecting us to produce an error
                        // FIXME this sucks, we should just use the Status object throughout
 -                      $this->hookError = $this->formatStatusErrors( $status );
 +                      $this->hookError = $status->getWikiText();
                        $status->fatal( 'hookaborted' );
                        $status->value = self::AS_HOOK_ERROR_EXPECTED;
                        return false;
                return true;
        }
  
 -      /**
 -       * Wrap status errors in an errorbox for increased visiblity
 -       *
 -       * @param Status $status
 -       * @return string
 -       */
 -      private function formatStatusErrors( Status $status ) {
 -              $errmsg = $status->getHTML(
 -                      'edit-error-short',
 -                      'edit-error-long',
 -                      $this->context->getLanguage()
 -              );
 -              return <<<ERROR
 -<div class="errorbox">
 -{$errmsg}
 -</div>
 -<br clear="all" />
 -ERROR;
 -      }
 -
        /**
         * Return the summary to be used for a new section.
         *
         * @return bool
         */
        private function mergeChangesIntoContent( &$editContent ) {
 -
                $db = wfGetDB( DB_MASTER );
  
                // This is the revision the editor started from
  
                $this->setHeaders();
  
-               if ( $this->showHeader() === false ) {
+               $this->addTalkPageText();
+               $this->addEditNotices();
+               if ( !$this->isConflict &&
+                       $this->section != '' &&
+                       !$this->isSectionEditSupported() ) {
+                       // We use $this->section to much before this and getVal('wgSection') directly in other places
+                       // at this point we can't reset $this->section to '' to fallback to non-section editing.
+                       // Someone is welcome to try refactoring though
+                       $wgOut->showErrorPage( 'sectioneditnotsupported-title', 'sectioneditnotsupported-text' );
                        return;
                }
  
+               $this->showHeader();
                $wgOut->addHTML( $this->editFormPageTop );
  
                if ( $wgUser->getOption( 'previewontop' ) ) {
                if ( !$wgUser->getOption( 'previewontop' ) ) {
                        $this->displayPreviewArea( $previewOutput, false );
                }
 -
        }
  
        /**
                return Html::rawElement( 'div', [ 'class' => 'templatesUsed' ],
                        $templateListFormatter->format( $templates, $type )
                );
 -
        }
  
        /**
                }
        }
  
-       /**
-        * @return bool
-        */
        protected function showHeader() {
                global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
                global $wgAllowUserCss, $wgAllowUserJs;
  
-               $this->addTalkPageText();
-               $this->addEditNotices();
                if ( $this->isConflict ) {
                        $wgOut->wrapWikiMsg( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );
                        $this->editRevId = $this->page->getLatest();
                } else {
-                       if ( $this->section != '' && !$this->isSectionEditSupported() ) {
-                               // We use $this->section to much before this and getVal('wgSection') directly in other places
-                               // at this point we can't reset $this->section to '' to fallback to non-section editing.
-                               // Someone is welcome to try refactoring though
-                               $wgOut->showErrorPage( 'sectioneditnotsupported-title', 'sectioneditnotsupported-text' );
-                               return false;
-                       }
                        if ( $this->section != '' && $this->section != 'new' ) {
                                if ( !$this->summary && !$this->preview && !$this->diff ) {
                                        $sectionTitle = self::extractSectionTitle( $this->textbox1 ); // FIXME: use Content object
                }
                # Add header copyright warning
                $this->showHeaderCopyrightWarning();
-               return true;
        }
  
        /**
                ] ) .
                        Html::openElement( 'tbody' );
  
 -              foreach ( $output->getLimitReportData()['limitreport'] as $key => $value ) {
 +              foreach ( $output->getLimitReportData() as $key => $value ) {
                        if ( Hooks::run( 'ParserLimitReportFormat',
                                [ $key, &$value, &$limitReport, true, true ]
                        ) ) {
 -                              $keyMsg = wfMessage( "limitreport-$key" );
 -                              $valueMsg = wfMessage(
 -                                      [ "limitreport-$key-value-html", "limitreport-$key-value" ]
 -                              );
 +                              $keyMsg = wfMessage( $key );
 +                              $valueMsg = wfMessage( [ "$key-value-html", "$key-value" ] );
                                if ( !$valueMsg->exists() ) {
                                        $valueMsg = new RawMessage( '$1' );
                                }
                                if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) {
 -                                      // If it's a value/limit array, convert it for $1/$2
 -                                      if ( is_array( $value ) && isset( $value['value'] ) ) {
 -                                              $value = [ $value['value'], $value['limit'] ];
 -                                      }
                                        $limitReport .= Html::openElement( 'tr' ) .
                                                Html::rawElement( 'th', null, $keyMsg->parse() ) .
                                                Html::rawElement( 'td', null, $valueMsg->params( $value )->parse() ) .
                return strtr( $result, [ "&#x0" => "&#x" ] );
        }
  
 +      /**
 +       * @since 1.29
 +       */
        protected function addEditNotices() {
                global $wgOut;
  
                }
        }
  
 +      /**
 +       * @since 1.29
 +       */
        protected function addTalkPageText() {
                global $wgOut;