Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -929,8 +929,6 @@ |
930 | 930 | |
931 | 931 | 'RevisionInsertComplete': called after a revision is inserted into the DB |
932 | 932 | $revision: the Revision |
933 | | -$edit: was this a new edit? |
934 | | -$baseID: what revision ID was this revision based off? (false if none) |
935 | 933 | |
936 | 934 | 'SavePreferences': called at the end of PreferencesForm::savePreferences; |
937 | 935 | returning false prevents the preferences from being saved. |
Index: trunk/phase3/includes/SpecialImport.php |
— | — | @@ -218,7 +218,7 @@ |
219 | 219 | $dbw = wfGetDB( DB_MASTER ); |
220 | 220 | $nullRevision = Revision::newNullRevision( |
221 | 221 | $dbw, $title->getArticleId(), $comment, true ); |
222 | | - $nullRevision->insertOn( $dbw, true ); |
| 222 | + $nullRevision->insertOn( $dbw ); |
223 | 223 | # Update page record |
224 | 224 | $article = new Article( $title ); |
225 | 225 | $article->updateRevisionOn( $dbw, $nullRevision ); |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -1362,11 +1362,10 @@ |
1363 | 1363 | * EDIT_NEW is specified and the article does exist, a duplicate key error will cause an exception |
1364 | 1364 | * to be thrown from the Database. These two conditions are also possible with auto-detection due |
1365 | 1365 | * to MediaWiki's performance-optimised locking strategy. |
1366 | | - * @param integer $baseRevID, the revision ID this is based off |
1367 | 1366 | * |
1368 | 1367 | * @return bool success |
1369 | 1368 | */ |
1370 | | - function doEdit( $text, $summary, $flags = 0, $baseRevID = false ) { |
| 1369 | + function doEdit( $text, $summary, $flags = 0 ) { |
1371 | 1370 | global $wgUser, $wgDBtransactions; |
1372 | 1371 | |
1373 | 1372 | wfProfileIn( __METHOD__ ); |
— | — | @@ -1445,7 +1444,7 @@ |
1446 | 1445 | ) ); |
1447 | 1446 | |
1448 | 1447 | $dbw->begin(); |
1449 | | - $revisionId = $revision->insertOn( $dbw, true, $baseRevID ); |
| 1448 | + $revisionId = $revision->insertOn( $dbw ); |
1450 | 1449 | |
1451 | 1450 | # Update page |
1452 | 1451 | $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision ); |
— | — | @@ -1513,7 +1512,7 @@ |
1514 | 1513 | 'minor_edit' => $isminor, |
1515 | 1514 | 'text' => $text |
1516 | 1515 | ) ); |
1517 | | - $revisionId = $revision->insertOn( $dbw, true ); |
| 1516 | + $revisionId = $revision->insertOn( $dbw ); |
1518 | 1517 | |
1519 | 1518 | $this->mTitle->resetArticleID( $newid ); |
1520 | 1519 | |
— | — | @@ -2525,7 +2524,7 @@ |
2526 | 2525 | |
2527 | 2526 | if( $bot && ($wgUser->isAllowed('markbotedits') || $wgUser->isAllowed('bot')) ) |
2528 | 2527 | $flags |= EDIT_FORCE_BOT; |
2529 | | - $this->doEdit( $target->getText(), $summary, $flags, $target->getId() ); |
| 2528 | + $this->doEdit( $target->getText(), $summary, $flags ); |
2530 | 2529 | |
2531 | 2530 | wfRunHooks( 'ArticleRollbackComplete', array( $this, $wgUser, $target ) ); |
2532 | 2531 | |
Index: trunk/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -858,7 +858,7 @@ |
859 | 859 | if( $descTitle->exists() ) { |
860 | 860 | # Create a null revision |
861 | 861 | $nullRevision = Revision::newNullRevision( $dbw, $descTitle->getArticleId(), $log->getRcComment(), false ); |
862 | | - $nullRevision->insertOn( $dbw, true ); |
| 862 | + $nullRevision->insertOn( $dbw ); |
863 | 863 | $article->updateRevisionOn( $dbw, $nullRevision ); |
864 | 864 | |
865 | 865 | # Invalidate the cache for the description page |
Index: trunk/phase3/includes/filerepo/ICRepo.php |
— | — | @@ -285,7 +285,7 @@ |
286 | 286 | if( $descTitle->exists() ) { |
287 | 287 | # Create a null revision |
288 | 288 | $nullRevision = Revision::newNullRevision( $dbw, $descTitle->getArticleId(), $log->getRcComment(), false ); |
289 | | - $nullRevision->insertOn( $dbw, true ); |
| 289 | + $nullRevision->insertOn( $dbw ); |
290 | 290 | $article->updateRevisionOn( $dbw, $nullRevision ); |
291 | 291 | |
292 | 292 | # Invalidate the cache for the description page |
Index: trunk/phase3/includes/Revision.php |
— | — | @@ -707,11 +707,9 @@ |
708 | 708 | * number on success and dies horribly on failure. |
709 | 709 | * |
710 | 710 | * @param Database $dbw |
711 | | - * @param bool $edit, was this a new edit? (optional) |
712 | | - * @param integer $baseID, what revision was this based on? (optional) |
713 | 711 | * @return int |
714 | 712 | */ |
715 | | - public function insertOn( &$dbw, $edit = false, $baseID = false ) { |
| 713 | + public function insertOn( &$dbw ) { |
716 | 714 | global $wgDefaultExternalStore; |
717 | 715 | |
718 | 716 | wfProfileIn( __METHOD__ ); |
— | — | @@ -774,7 +772,7 @@ |
775 | 773 | |
776 | 774 | $this->mId = !is_null($rev_id) ? $rev_id : $dbw->insertId(); |
777 | 775 | |
778 | | - wfRunHooks( 'RevisionInsertComplete', array( &$this, $edit, $baseID ) ); |
| 776 | + wfRunHooks( 'RevisionInsertComplete', array( &$this ) ); |
779 | 777 | |
780 | 778 | wfProfileOut( __METHOD__ ); |
781 | 779 | return $this->mId; |
Index: trunk/phase3/includes/SpecialUndelete.php |
— | — | @@ -514,7 +514,7 @@ |
515 | 515 | 'deleted' => $unsuppress ? 0 : $row->ar_deleted, |
516 | 516 | 'len' => $row->ar_len |
517 | 517 | ) ); |
518 | | - $revision->insertOn( $dbw, false ); |
| 518 | + $revision->insertOn( $dbw ); |
519 | 519 | $restored++; |
520 | 520 | |
521 | 521 | wfRunHooks( 'ArticleRevisionUndeleted', array( &$this->title, $revision, $row->ar_page_id ) ); |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -2598,7 +2598,7 @@ |
2599 | 2599 | |
2600 | 2600 | # Save a null revision in the page's history notifying of the move |
2601 | 2601 | $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true ); |
2602 | | - $nullRevId = $nullRevision->insertOn( $dbw, true ); |
| 2602 | + $nullRevId = $nullRevision->insertOn( $dbw ); |
2603 | 2603 | |
2604 | 2604 | # Change the name of the target page: |
2605 | 2605 | $dbw->update( 'page', |
— | — | @@ -2624,7 +2624,7 @@ |
2625 | 2625 | 'page' => $newid, |
2626 | 2626 | 'comment' => $comment, |
2627 | 2627 | 'text' => $redirectText ) ); |
2628 | | - $redirectRevision->insertOn( $dbw, true ); |
| 2628 | + $redirectRevision->insertOn( $dbw ); |
2629 | 2629 | $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); |
2630 | 2630 | |
2631 | 2631 | # Now, we record the link from the redirect to the new title. |
— | — | @@ -2685,7 +2685,7 @@ |
2686 | 2686 | |
2687 | 2687 | # Save a null revision in the page's history notifying of the move |
2688 | 2688 | $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true ); |
2689 | | - $nullRevId = $nullRevision->insertOn( $dbw, true ); |
| 2689 | + $nullRevId = $nullRevision->insertOn( $dbw ); |
2690 | 2690 | |
2691 | 2691 | # Rename page entry |
2692 | 2692 | $dbw->update( 'page', |
— | — | @@ -2711,7 +2711,7 @@ |
2712 | 2712 | 'page' => $newid, |
2713 | 2713 | 'comment' => $comment, |
2714 | 2714 | 'text' => $redirectText ) ); |
2715 | | - $redirectRevision->insertOn( $dbw, true ); |
| 2715 | + $redirectRevision->insertOn( $dbw ); |
2716 | 2716 | $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); |
2717 | 2717 | |
2718 | 2718 | # Record the just-created redirect's linking to the page |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -285,6 +285,7 @@ |
286 | 286 | # Auto-reviewing |
287 | 287 | $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevs::autoMarkPatrolled'; |
288 | 288 | $wgHooks['RevisionInsertComplete'][] = 'FlaggedRevs::maybeMakeEditReviewed'; |
| 289 | + $wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevs::maybeMakeRollbackReviewed'; |
289 | 290 | # Disallow moves of stable pages |
290 | 291 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanMove'; |
291 | 292 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanView'; |
— | — | @@ -1933,10 +1934,40 @@ |
1934 | 1935 | } |
1935 | 1936 | |
1936 | 1937 | /** |
| 1938 | + * Was this request an edit to said title? |
| 1939 | + * @param Title $title |
| 1940 | + * @param Revision $rev |
| 1941 | + */ |
| 1942 | + public static function revSubmitted( $title, $rev ) { |
| 1943 | + global $wgRequest, $wgUser; |
| 1944 | + # Request was submitted |
| 1945 | + if( !$wgRequest->wasPosted() ) { |
| 1946 | + return false; |
| 1947 | + } |
| 1948 | + # Sent to page title or Special:MovePage |
| 1949 | + $move = SpecialPage::getTitleFor( 'MovePage' ); |
| 1950 | + if( !in_array( $wgRequest->getVal('title'), array($title->getPrefixedDBkey(),$move->getPrefixedDBkey()) ) ) { |
| 1951 | + return false; |
| 1952 | + } |
| 1953 | + # Must be by this user |
| 1954 | + if( $wgUser->getId() ) { |
| 1955 | + if( $rev->getUser() != $wgUser->getId() ) { |
| 1956 | + return false; |
| 1957 | + } |
| 1958 | + # Must be by this IP |
| 1959 | + } else { |
| 1960 | + if( $rev->getRawUserText() != $wgUser->getName() ) { |
| 1961 | + return false; |
| 1962 | + } |
| 1963 | + } |
| 1964 | + return true; |
| 1965 | + } |
| 1966 | + |
| 1967 | + /** |
1937 | 1968 | * When an edit is made by a reviewer, if the current revision is the stable |
1938 | 1969 | * version, try to automatically review it. |
1939 | 1970 | */ |
1940 | | - public static function maybeMakeEditReviewed( $rev, $edit, $baseRevID ) { |
| 1971 | + public static function maybeMakeEditReviewed( $rev ) { |
1941 | 1972 | global $wgFlaggedRevsAutoReview, $wgFlaggedArticle, $wgRequest; |
1942 | 1973 | # Get the user |
1943 | 1974 | $user = User::newFromId( $rev->getUser() ); |
— | — | @@ -1950,13 +1981,13 @@ |
1951 | 1982 | return true; |
1952 | 1983 | } |
1953 | 1984 | # For edits from normal form submits only! |
1954 | | - if( !$edit ) { |
| 1985 | + if( !self::revSubmitted( $title, $rev ) ) { |
1955 | 1986 | return true; |
1956 | 1987 | } |
1957 | 1988 | $frev = null; |
1958 | 1989 | $reviewableNewPage = false; |
1959 | | - # Get the revision the incoming one was based off if |
1960 | | - $baseRevID = $baseRevID ? $baseRevID : $wgRequest->getIntOrNull('baseRevId'); |
| 1990 | + # Get the revision the incoming one was based off |
| 1991 | + $baseRevID = $wgRequest->getIntOrNull('baseRevId'); |
1961 | 1992 | # If baseRevId not given, assume the previous |
1962 | 1993 | $baseRevID = $baseRevID ? $baseRevID : $title->getPreviousRevisionId( $rev->getId(), GAID_FOR_UPDATE ); |
1963 | 1994 | if( $baseRevID ) { |
— | — | @@ -1988,6 +2019,33 @@ |
1989 | 2020 | } |
1990 | 2021 | |
1991 | 2022 | /** |
| 2023 | + * When a rollback is made by a reviwer, try to automatically review it. |
| 2024 | + */ |
| 2025 | + public static function maybeMakeRollbackReviewed( $article, $user, $rev ) { |
| 2026 | + global $wgFlaggedRevsAutoReview, $wgFlaggedArticle; |
| 2027 | + if( !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) |
| 2028 | + return true; |
| 2029 | + # Must be in reviewable namespace |
| 2030 | + if( !self::isPageReviewable( $article->getTitle() ) ) |
| 2031 | + return true; |
| 2032 | + # Was this revision flagged? |
| 2033 | + $frev = self::getFlaggedRev( $article->getTitle(), $rev->getId() ); |
| 2034 | + if( !is_null($frev) ) { |
| 2035 | + # Assume basic flagging level |
| 2036 | + $flags = array(); |
| 2037 | + foreach( self::$dimensions as $tag => $minQL ) { |
| 2038 | + $flags[$tag] = 1; |
| 2039 | + } |
| 2040 | + $newRev = Revision::newFromId( $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) ); |
| 2041 | + if( $newRev ) { |
| 2042 | + self::autoReviewEdit( $article, $user, $rev->getText(), $newRev, $flags ); |
| 2043 | + self::articleLinksUpdate( $article ); // lame... |
| 2044 | + } |
| 2045 | + } |
| 2046 | + return true; |
| 2047 | + } |
| 2048 | + |
| 2049 | + /** |
1992 | 2050 | * When an edit is made to a page that can't be reviewed, autopatrol if allowed. |
1993 | 2051 | * This is not loggged for perfomance reasons and no one cares if talk pages and such |
1994 | 2052 | * are autopatrolled. |