Fix documentation of wfDebugLog()
[lhc/web/wiklou.git] / includes / EditPage.php
index 06bdadd..d4b06fe 100644 (file)
@@ -772,8 +772,7 @@ class EditPage {
                                $this->sectiontitle = $request->getVal( 'preloadtitle' );
                                // Once wpSummary isn't being use for setting section titles, we should delete this.
                                $this->summary = $request->getVal( 'preloadtitle' );
-                       }
-                       elseif ( $this->section != 'new' && $request->getVal( 'summary' ) ) {
+                       } elseif ( $this->section != 'new' && $request->getVal( 'summary' ) ) {
                                $this->summary = $request->getText( 'summary' );
                                if ( $this->summary !== '' ) {
                                        $this->hasPresetSummary = true;
@@ -892,7 +891,7 @@ class EditPage {
         * @since 1.21
         */
        protected function getContentObject( $def_content = null ) {
-               global $wgOut, $wgRequest;
+               global $wgOut, $wgRequest, $wgUser, $wgContLang;
 
                wfProfileIn( __METHOD__ );
 
@@ -930,10 +929,6 @@ class EditPage {
                                $undo = $wgRequest->getInt( 'undo' );
 
                                if ( $undo > 0 && $undoafter > 0 ) {
-                                       if ( $undo < $undoafter ) {
-                                               # If they got undoafter and undo round the wrong way, switch them
-                                               list( $undo, $undoafter ) = array( $undoafter, $undo );
-                                       }
 
                                        $undorev = Revision::newFromId( $undo );
                                        $oldrev = Revision::newFromId( $undoafter );
@@ -942,8 +937,6 @@ class EditPage {
                                        # the revisions exist and they were not deleted.
                                        # Otherwise, $content will be left as-is.
                                        if ( !is_null( $undorev ) && !is_null( $oldrev ) &&
-                                               $undorev->getPage() == $oldrev->getPage() &&
-                                               $undorev->getPage() == $this->mTitle->getArticleID() &&
                                                !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
                                                !$oldrev->isDeleted( Revision::DELETED_TEXT ) ) {
 
@@ -953,34 +946,45 @@ class EditPage {
                                                        # Warn the user that something went wrong
                                                        $undoMsg = 'failure';
                                                } else {
-                                                       # Inform the user of our success and set an automatic edit summary
-                                                       $undoMsg = 'success';
-
-                                                       # If we just undid one rev, use an autosummary
-                                                       $firstrev = $oldrev->getNext();
-                                                       if ( $firstrev && $firstrev->getId() == $undo ) {
-                                                               $userText = $undorev->getUserText();
-                                                               if ( $userText === '' ) {
-                                                                       $undoSummary = wfMessage(
-                                                                               'undo-summary-username-hidden',
-                                                                               $undo
-                                                                       )->inContentLanguage()->text();
-                                                               } else {
-                                                                       $undoSummary = wfMessage(
-                                                                               'undo-summary',
-                                                                               $undo,
-                                                                               $userText
-                                                                       )->inContentLanguage()->text();
-                                                               }
-                                                               if ( $this->summary === '' ) {
-                                                                       $this->summary = $undoSummary;
-                                                               } else {
-                                                                       $this->summary = $undoSummary . wfMessage( 'colon-separator' )
-                                                                               ->inContentLanguage()->text() . $this->summary;
+                                                       $oldContent = $this->mArticle->getPage()->getContent( Revision::RAW );
+                                                       $popts = ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
+                                                       $newContent = $content->preSaveTransform( $this->mTitle, $wgUser, $popts );
+
+                                                       if ( $newContent->equals( $oldContent ) ) {
+                                                               # Tell the user that the undo results in no change,
+                                                               # i.e. the revisions were already undone.
+                                                               $undoMsg = 'nochange';
+                                                               $content = false;
+                                                       } else {
+                                                               # Inform the user of our success and set an automatic edit summary
+                                                               $undoMsg = 'success';
+
+                                                               # If we just undid one rev, use an autosummary
+                                                               $firstrev = $oldrev->getNext();
+                                                               if ( $firstrev && $firstrev->getId() == $undo ) {
+                                                                       $userText = $undorev->getUserText();
+                                                                       if ( $userText === '' ) {
+                                                                               $undoSummary = wfMessage(
+                                                                                       'undo-summary-username-hidden',
+                                                                                       $undo
+                                                                               )->inContentLanguage()->text();
+                                                                       } else {
+                                                                               $undoSummary = wfMessage(
+                                                                                       'undo-summary',
+                                                                                       $undo,
+                                                                                       $userText
+                                                                               )->inContentLanguage()->text();
+                                                                       }
+                                                                       if ( $this->summary === '' ) {
+                                                                               $this->summary = $undoSummary;
+                                                                       } else {
+                                                                               $this->summary = $undoSummary . wfMessage( 'colon-separator' )
+                                                                                       ->inContentLanguage()->text() . $this->summary;
+                                                                       }
+                                                                       $this->undidRev = $undo;
                                                                }
-                                                               $this->undidRev = $undo;
+                                                               $this->formtype = 'diff';
                                                        }
-                                                       $this->formtype = 'diff';
                                                }
                                        } else {
                                                // Failed basic sanity checks.
@@ -989,7 +993,7 @@ class EditPage {
                                                $undoMsg = 'norev';
                                        }
 
-                                       // Messages: undo-success, undo-failure, undo-norev
+                                       // Messages: undo-success, undo-failure, undo-norev, undo-nochange
                                        $class = ( $undoMsg == 'success' ? '' : 'error ' ) . "mw-undo-{$undoMsg}";
                                        $this->editFormPageTop .= $wgOut->parse( "<div class=\"{$class}\">" .
                                                wfMessage( 'undo-' . $undoMsg )->plain() . '</div>', true, /* interface */true );
@@ -2078,10 +2082,27 @@ class EditPage {
                }
                # Try to add a custom edit intro, or use the standard one if this is not possible.
                if ( !$this->showCustomIntro() && !$this->mTitle->exists() ) {
+                       $helpLink = Skin::makeInternalOrExternalUrl(
+                               wfMessage( 'helppage' )->inContentLanguage()->text()
+                       );
                        if ( $wgUser->isLoggedIn() ) {
-                               $wgOut->wrapWikiMsg( "<div class=\"mw-newarticletext\">\n$1\n</div>", 'newarticletext' );
+                               $wgOut->wrapWikiMsg(
+                                       // Suppress the external link icon, consider the help url an internal one
+                                       "<div class=\"mw-newarticletext plainlinks\">\n$1\n</div>",
+                                       array(
+                                               'newarticletext',
+                                               $helpLink
+                                       )
+                               );
                        } else {
-                               $wgOut->wrapWikiMsg( "<div class=\"mw-newarticletextanon\">\n$1\n</div>", 'newarticletextanon' );
+                               $wgOut->wrapWikiMsg(
+                                       // Suppress the external link icon, consider the help url an internal one
+                                       "<div class=\"mw-newarticletextanon plainlinks\">\n$1\n</div>",
+                                       array(
+                                               'newarticletextanon',
+                                               $helpLink
+                                       )
+                               );
                        }
                }
                # Give a notice if the user is editing a deleted/moved page...
@@ -3442,16 +3463,16 @@ HTML
                        }
 
                        $params = array(
-                               $image = $wgStylePath . '/common/images/' . $tool['image'],
+                               $wgStylePath . '/common/images/' . $tool['image'],
                                // Note that we use the tip both for the ALT tag and the TITLE tag of the image.
                                // Older browsers show a "speedtip" type message only for ALT.
                                // Ideally these should be different, realistically they
                                // probably don't need to be.
-                               $tip = $tool['tip'],
-                               $open = $tool['open'],
-                               $close = $tool['close'],
-                               $sample = $tool['sample'],
-                               $cssId = $tool['id'],
+                               $tool['tip'],
+                               $tool['open'],
+                               $tool['close'],
+                               $tool['sample'],
+                               $tool['id'],
                        );
 
                        $script .= Xml::encodeJsCall( 'mw.toolbar.addButton', $params );