From: Brion Vibber Date: Sun, 25 May 2003 07:09:23 +0000 (+0000) Subject: Fix rollback to avoid race conditions with multiple people trying to revert after... X-Git-Tag: 1.1.0~516 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=21a6c8751fc0a7408987fcf5a6271a3c8e367b70;p=lhc%2Fweb%2Fwiklou.git Fix rollback to avoid race conditions with multiple people trying to revert after each other --- diff --git a/includes/Article.php b/includes/Article.php index b84ec08c56..f656eb3e27 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1324,19 +1324,19 @@ name=\"wpSummary\" maxlength=200 size=60>
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>
$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) diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index d9e86a79e5..4c0e64029b 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -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) { diff --git a/languages/Language.php b/languages/Language.php index 4cfc5d0e0c..1228ed6fb2 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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" => "Can't roll back last edit by $1; someone else has edited or +rolled back the article already. + +

Last edit was by $2, marked \"$3\".", "revertpage" => "Reverted to last edit by $1", # Undelete