Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -1483,27 +1483,39 @@ |
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | /** |
1487 | | - * Add a hidden revision ID field to edit form. |
1488 | | - * Needed for autoreview so it can select the flags from said revision. |
| 1487 | + * (a) Add a hidden field that has the rev ID the text is based off. |
| 1488 | + * (b) If an edit was undone, add a hidden field that has the rev ID of that edit. |
| 1489 | + * Needed for autoreview and user stats (for autopromote). |
| 1490 | + * Note: baseRevId trusted for Reviewers - text checked for others. |
1489 | 1491 | */ |
1490 | | - public function addRevisionIDField( $editPage, $out ) { |
| 1492 | + public function addRevisionIDField( EditPage $editPage, OutputPage $out ) { |
1491 | 1493 | global $wgRequest; |
1492 | 1494 | $this->load(); |
1493 | 1495 | $article = $editPage->getArticle(); // convenience |
1494 | 1496 | $latestId = $article->getLatest(); // current rev |
1495 | | - # Find the ID of the revision being edited |
1496 | | - $revId = $article->getOldID(); |
1497 | | - if( !$revId ) { // zero oldid => current revision |
1498 | | - $revId = $latestId; |
1499 | | - } |
1500 | | - # If undoing a few consecutive top edits, we can treat this |
1501 | | - # like a revert to a base revision...find its ID... |
1502 | 1497 | $undo = $wgRequest->getIntOrNull( 'undo' ); |
1503 | | - if ( $undo === $latestId ) { |
1504 | | - # We are undoing all edits *after* some rev...get that rev's ID |
| 1498 | + # Undoing consecutive top edits... |
| 1499 | + if ( $undo && $undo === $latestId ) { |
| 1500 | + # Treat this like a revert to a base revision. |
| 1501 | + # We are undoing all edits *after* some rev ID (undoafter). |
| 1502 | + # If undoafter is not given, then it is the previous rev ID. |
1505 | 1503 | $revId = $wgRequest->getInt( 'undoafter', |
1506 | 1504 | $article->getTitle()->getPreviousRevisionID( $latestId, GAID_FOR_UPDATE ) ); |
| 1505 | + # Undoing other edits... |
| 1506 | + } elseif ( $undo ) { |
| 1507 | + $revId = $latestId; // current rev is the base rev |
| 1508 | + # Other edits... |
| 1509 | + } else { |
| 1510 | + # If we are editing via oldid=X, then use that rev ID. |
| 1511 | + # Otherwise, check if the client specified the ID (bug 23098). |
| 1512 | + $revId = $article->getOldID() |
| 1513 | + ? $article->getOldID() |
| 1514 | + : $wgRequest->getInt( 'baseRevId' ); // e.g. "show changes"/"preview" |
1507 | 1515 | } |
| 1516 | + # Zero oldid => current revision |
| 1517 | + if ( !$revId ) { |
| 1518 | + $revId = $latestId; |
| 1519 | + } |
1508 | 1520 | $out->addHTML( "\n" . Xml::hidden( 'baseRevId', $revId ) ); |
1509 | 1521 | $out->addHTML( "\n" . Xml::hidden( 'undidRev', |
1510 | 1522 | empty( $editPage->undidRev ) ? 0 : $editPage->undidRev ) |