* When undoing an edit, make sure it wasn't deleted.
authorRotem Liss <rotem@users.mediawiki.org>
Wed, 23 Apr 2008 16:08:16 +0000 (16:08 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Wed, 23 Apr 2008 16:08:16 +0000 (16:08 +0000)
* Show a proper error message for non-existant or deleted revisions when undoing.

includes/Article.php
includes/EditPage.php
languages/messages/MessagesEn.php
languages/messages/MessagesHe.php
maintenance/language/messages.inc

index 51d5a82..d458d94 100644 (file)
@@ -660,7 +660,7 @@ class Article {
         * This is the default action of the script: just view the page of
         * the given title.
        */
-       function view() {
+       function view() {
                global $wgUser, $wgOut, $wgRequest, $wgContLang;
                global $wgEnableParserCache, $wgStylePath, $wgParser;
                global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies;
index a4218d5..8103abf 100644 (file)
@@ -153,39 +153,43 @@ class EditPage {
                                        $oldrev = $undorev ? $undorev->getPrevious() : null;
                                }
 
-                               #Sanity check, make sure it's the right page.
+                               # Sanity check, make sure it's the right page,
+                               # the revisions exist and they were not deleted.
                                # Otherwise, $text will be left as-is.
-                               if ( !is_null($undorev) && !is_null($oldrev) && $undorev->getPage()==$oldrev->getPage() && $undorev->getPage()==$this->mArticle->getID() ) {
+                               if( !is_null( $undorev ) && !is_null( $oldrev ) &&
+                                       $undorev->getPage() == $oldrev->getPage() &&
+                                       $undorev->getPage() == $this->mArticle->getID() &&
+                                       !$undorev->isDeleted( Revision::DELETED_TEXT ) &&
+                                       !$oldrev->isDeleted( Revision::DELETED_TEXT ) ) {
                                        $undorev_text = $undorev->getText();
                                        $oldrev_text = $oldrev->getText();
                                        $currev_text = $text;
 
-                                       #No use doing a merge if it's just a straight revert.
                                        if ( $currev_text != $undorev_text ) {
-                                               $result = wfMerge($undorev_text, $oldrev_text, $currev_text, $text);
+                                               $result = wfMerge( $undorev_text, $oldrev_text, $currev_text, $text );
                                        } else {
+                                               # No use doing a merge if it's just a straight revert.
                                                $text = $oldrev_text;
                                                $result = true;
                                        }
+                                       if( $result ) {
+                                               # Inform the user of our success and set an automatic edit summary
+                                               $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-success' ) );
+                                               $firstrev = $oldrev->getNext();
+                                               # If we just undid one rev, use an autosummary
+                                               if( $firstrev->mId == $undo ) {
+                                                       $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText());
+                                               }
+                                               $this->formtype = 'diff';
+                                       } else {
+                                               # Warn the user that something went wrong
+                                               $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-failure' ) );
+                                       }
                                } else {
                                        // Failed basic sanity checks.
                                        // Older revisions may have been removed since the link
                                        // was created, or we may simply have got bogus input.
-                                       $result = false;
-                               }
-
-                               if( $result ) {
-                                       # Inform the user of our success and set an automatic edit summary
-                                       $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-success' ) );
-                                       $firstrev = $oldrev->getNext();
-                                       # If we just undid one rev, use an autosummary
-                                       if ( $firstrev->mId == $undo ) {
-                                               $this->summary = wfMsgForContent('undo-summary', $undo, $undorev->getUserText());
-                                       }
-                                       $this->formtype = 'diff';
-                               } else {
-                                       # Warn the user that something went wrong
-                                       $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-failure' ) );
+                                       $this->editFormPageTop .= $wgOut->parse( wfMsgNoTrans( 'undo-norev' ) );
                                }
                        } else if( $section != '' ) {
                                if( $section == 'new' ) {
index 35b1619..fd053ff 100644 (file)
@@ -1145,6 +1145,7 @@ It should have less than $2, there are now $1.',
 # "Undo" feature
 'undo-success' => 'The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.',
 'undo-failure' => 'The edit could not be undone due to conflicting intermediate edits.',
+'undo-norev'   => 'The edit could not be undone because it does not exist or was deleted.',
 'undo-summary' => 'Undo revision $1 by [[Special:Contributions/$2|$2]] ([[User talk:$2|Talk]])',
 
 # Account creation failure
index c8936ca..542ea25 100644 (file)
@@ -923,6 +923,7 @@ $2',
 # "Undo" feature
 'undo-success' => 'ניתן לבטל את העריכה. אנא בידקו את השוואת הגרסאות למטה כדי לוודא שזה מה שאתם רוצים לעשות, ואז שמרו את השינויים למטה כדי לבצע את ביטול העריכה.',
 'undo-failure' => 'לא ניתן היה לבטל את העריכה עקב התנגשות עם עריכות מאוחרות יותר.',
+'undo-norev'   => 'לא ניתן היה לבטל את העריכה כיוון שהיא אינה קיימת או שהיא נמחקה.',
 'undo-summary' => 'ביטול גרסה $1 של [[Special:Contributions/$2|$2]] ([[User talk:$2|שיחה]])',
 
 # Account creation failure
index 8b4ed22..e61c22a 100644 (file)
@@ -565,6 +565,7 @@ $wgMessageStructure = array(
        'undo' => array(
                'undo-success',
                'undo-failure',
+               'undo-norev',
                'undo-summary',
        ),
        'cantcreateaccount' => array(