Fix rollback to avoid race conditions with multiple people trying to revert after...
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 25 May 2003 07:09:23 +0000 (07:09 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 25 May 2003 07:09:23 +0000 (07:09 +0000)
includes/Article.php
includes/SpecialContributions.php
languages/Language.php

index b84ec08..f656eb3 100644 (file)
@@ -1324,19 +1324,19 @@ name=\"wpSummary\" maxlength=200 size=60><br>
 
        function rollback()
        {
-               global $wgUser, $wgTitle, $wgLang, $wgOut;
+               global $wgUser, $wgTitle, $wgLang, $wgOut, $from;
 
                if ( ! $wgUser->isSysop() ) {
                        $wgOut->sysopRequired();
                        return;
                }
-               
+
                # Replace all this user's current edits with the next one down
                $tt = wfStrencode( $wgTitle->getDBKey() );
                $n = $wgTitle->getNamespace();
                
                # Get the last editor
-               $sql = "SELECT cur_id,cur_user,cur_user_text FROM cur WHERE cur_title='{$tt}' AND cur_namespace={$n}";
+               $sql = "SELECT cur_id,cur_user,cur_user_text,cur_comment FROM cur WHERE cur_title='{$tt}' AND cur_namespace={$n}";
                $res = wfQuery( $sql );
                if( ($x = wfNumRows( $res )) != 1 ) {
                        # Something wrong
@@ -1348,6 +1348,15 @@ name=\"wpSummary\" maxlength=200 size=60><br>
                $uid = $s->cur_user;
                $pid = $s->cur_id;
                
+               $from = str_replace( '_', ' ', wfCleanQueryVar( $from ) );
+               if( $from != $s->cur_user_text ) {
+                       $wgOut->addHTML( wfMsg( "alreadyrolled",
+                               htmlspecialchars( $from ),
+                               htmlspecialchars( $s->cur_user_text ),
+                               htmlspecialchars( $s->cur_comment ) ) );
+                       return;
+               }
+               
                # Get the last edit not by this guy
                $sql = "SELECT old_text,old_user,old_user_text
                FROM old USE INDEX (name_title_timestamp)
index d9e86a7..4c0e640 100644 (file)
@@ -110,14 +110,14 @@ function wfSpecialContributions()
 
 function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment )
 {
-       global $wgLang, $wgOut, $wgUser;
+       global $wgLang, $wgOut, $wgUser, $target;
        $page = Title::makeName( $ns, $t );
        $link = $sk->makeKnownLink( $page, "" );
        $topmarktext = $topmark ? wfMsg ( "uctop" ) : "";
        $sysop = $wgUser->isSysop();
        if($sysop && $topmark ) {
                $topmarktext .= " [". $sk->makeKnownLink( $page,
-                 wfMsg( "rollbacklink" ), "action=rollback" ) ."]";
+                 wfMsg( "rollbacklink" ), "action=rollback&from=" . urlencode( $target ) ) ."]";
        }
        if($comment) {
        
index 4cfc5d0..1228ed6 100644 (file)
@@ -917,6 +917,10 @@ All times shown are server time (UTC).
 "rollback"             => "Roll back edits",
 "rollbacklink" => "rollback",
 "cantrollback" => "Can't revert edit; last contributor is only author of this article.",
+"alreadyrolled"        => "<b>Can't roll back last edit by $1; someone else has edited or
+rolled back the article already.</b>
+
+<p>Last edit was by $2, marked \"<i>$3</i>\".",
 "revertpage"   => "Reverted to last edit by $1",
 
 # Undelete