Merge "Use preview content when it transcludes itself"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 31 Dec 2014 16:19:24 +0000 (16:19 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 31 Dec 2014 16:19:24 +0000 (16:19 +0000)
1  2 
includes/EditPage.php

diff --combined includes/EditPage.php
@@@ -1928,15 -1928,11 +1928,15 @@@ class EditPage 
                        && $content->isRedirect()
                        && $content->getRedirectTarget()->equals( $this->getTitle() )
                ) {
 -                      $this->selfRedirect = true;
 -                      $status->fatal( 'selfredirect' );
 -                      $status->value = self::AS_SELF_REDIRECT;
 -                      wfProfileOut( __METHOD__ );
 -                      return $status;
 +                      // If the page already redirects to itself, don't warn.
 +                      $currentTarget = $this->getCurrentContent()->getRedirectTarget();
 +                      if ( !$currentTarget || !$currentTarget->equals( $this->getTitle() ) ) {
 +                              $this->selfRedirect = true;
 +                              $status->fatal( 'selfredirect' );
 +                              $status->value = self::AS_SELF_REDIRECT;
 +                              wfProfileOut( __METHOD__ );
 +                              return $status;
 +                      }
                }
  
                // Check for length errors again now that the section is merged in
                $wgOut->addModules( 'mediawiki.action.edit' );
                $wgOut->addModuleStyles( 'mediawiki.action.edit.styles' );
  
 -              if ( $wgUser->getOption( 'uselivepreview', false ) ) {
 +              if ( $wgUser->getOption( 'showtoolbar' ) ) {
 +                      // The addition of default buttons is handled by getEditToolbar() which
 +                      // has its own dependency on this module. The call here ensures the module
 +                      // is loaded in time (it has position "top") for other modules to register
 +                      // buttons (e.g. extensions, gadgets, user scripts).
 +                      $wgOut->addModules( 'mediawiki.toolbar' );
 +              }
 +
 +              if ( $wgUser->getOption( 'uselivepreview' ) ) {
                        $wgOut->addModules( 'mediawiki.action.edit.preview' );
                }
  
 -              if ( $wgUser->getOption( 'useeditwarning', false ) ) {
 +              if ( $wgUser->getOption( 'useeditwarning' ) ) {
                        $wgOut->addModules( 'mediawiki.action.edit.editWarning' );
                }
  
@@@ -3573,6 -3561,8 +3573,8 @@@ HTM
                        # But it's now deprecated, so never mind
  
                        $pstContent = $content->preSaveTransform( $this->mTitle, $wgUser, $parserOptions );
+                       $scopedCallback = $parserOptions->setupFakeRevision(
+                               $this->mTitle, $pstContent, $wgUser );
                        $parserOutput = $pstContent->getParserOutput( $this->mTitle, null, $parserOptions );
  
                        # Try to stash the edit for the final submission step
                                $tool['id'],
                        );
  
 -                      $script .= Xml::encodeJsCall( 'mw.toolbar.addButton', $params );
 +                      $script .= Xml::encodeJsCall(
 +                              'mw.toolbar.addButton',
 +                              $params,
 +                              ResourceLoader::inDebugMode()
 +                      );
                }
  
                $script .= '});';