Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -920,6 +920,7 @@ |
921 | 921 | 'RevisionInsertComplete': called after a revision is inserted into the DB |
922 | 922 | $revision: the Revision |
923 | 923 | $edit: was this a new edit? |
| 924 | +$baseID: what revision ID was this revision based off? (false if none) |
924 | 925 | |
925 | 926 | 'SavePreferences': called at the end of PreferencesForm::savePreferences; |
926 | 927 | returning false prevents the preferences from being saved. |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -1362,10 +1362,11 @@ |
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 |
1366 | 1367 | * |
1367 | 1368 | * @return bool success |
1368 | 1369 | */ |
1369 | | - function doEdit( $text, $summary, $flags = 0 ) { |
| 1370 | + function doEdit( $text, $summary, $flags = 0, $baseRevID = false ) { |
1370 | 1371 | global $wgUser, $wgDBtransactions; |
1371 | 1372 | |
1372 | 1373 | wfProfileIn( __METHOD__ ); |
— | — | @@ -1444,7 +1445,7 @@ |
1445 | 1446 | ) ); |
1446 | 1447 | |
1447 | 1448 | $dbw->begin(); |
1448 | | - $revisionId = $revision->insertOn( $dbw, true ); |
| 1449 | + $revisionId = $revision->insertOn( $dbw, true, $baseRevID ); |
1449 | 1450 | |
1450 | 1451 | # Update page |
1451 | 1452 | $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision ); |
— | — | @@ -2524,7 +2525,7 @@ |
2525 | 2526 | |
2526 | 2527 | if( $bot && ($wgUser->isAllowed('markbotedits') || $wgUser->isAllowed('bot')) ) |
2527 | 2528 | $flags |= EDIT_FORCE_BOT; |
2528 | | - $this->doEdit( $target->getText(), $summary, $flags ); |
| 2529 | + $this->doEdit( $target->getText(), $summary, $flags, $target->getId() ); |
2529 | 2530 | |
2530 | 2531 | wfRunHooks( 'ArticleRollbackComplete', array( $this, $wgUser, $target ) ); |
2531 | 2532 | |
Index: trunk/phase3/includes/Revision.php |
— | — | @@ -708,9 +708,10 @@ |
709 | 709 | * |
710 | 710 | * @param Database $dbw |
711 | 711 | * @param bool $edit, was this a new edit? (optional) |
| 712 | + * @param integer $baseID, what revision was this based on? (optional) |
712 | 713 | * @return int |
713 | 714 | */ |
714 | | - public function insertOn( &$dbw, $edit=false ) { |
| 715 | + public function insertOn( &$dbw, $edit = false, $baseID = false ) { |
715 | 716 | global $wgDefaultExternalStore; |
716 | 717 | |
717 | 718 | wfProfileIn( __METHOD__ ); |
— | — | @@ -773,7 +774,7 @@ |
774 | 775 | |
775 | 776 | $this->mId = !is_null($rev_id) ? $rev_id : $dbw->insertId(); |
776 | 777 | |
777 | | - wfRunHooks( 'RevisionInsertComplete', array( &$this, $edit ) ); |
| 778 | + wfRunHooks( 'RevisionInsertComplete', array( &$this, $edit, $baseID ) ); |
778 | 779 | |
779 | 780 | wfProfileOut( __METHOD__ ); |
780 | 781 | return $this->mId; |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -285,7 +285,6 @@ |
286 | 286 | # Auto-reviewing |
287 | 287 | $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevs::autoMarkPatrolled'; |
288 | 288 | $wgHooks['RevisionInsertComplete'][] = 'FlaggedRevs::maybeMakeEditReviewed'; |
289 | | - $wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevs::maybeMakeRollbackReviewed'; |
290 | 289 | # Disallow moves of stable pages |
291 | 290 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanMove'; |
292 | 291 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanView'; |
— | — | @@ -1900,35 +1899,10 @@ |
1901 | 1900 | } |
1902 | 1901 | |
1903 | 1902 | /** |
1904 | | - * Was this request an edit to said title? |
1905 | | - * @param Title $title |
1906 | | - * @param Revision $rev |
1907 | | - */ |
1908 | | - public static function revSubmitted( $title, $rev, $edit ) { |
1909 | | - global $wgRequest, $wgUser; |
1910 | | - # Request was submitted |
1911 | | - if( !$edit || !$wgRequest->wasPosted() ) { |
1912 | | - return false; |
1913 | | - } |
1914 | | - # Must be by this user |
1915 | | - if( $wgUser->getId() ) { |
1916 | | - if( $rev->getUser() != $wgUser->getId() ) { |
1917 | | - return false; |
1918 | | - } |
1919 | | - # Must be by this IP |
1920 | | - } else { |
1921 | | - if( $rev->getRawUserText() != $wgUser->getName() ) { |
1922 | | - return false; |
1923 | | - } |
1924 | | - } |
1925 | | - return true; |
1926 | | - } |
1927 | | - |
1928 | | - /** |
1929 | 1903 | * When an edit is made by a reviewer, if the current revision is the stable |
1930 | 1904 | * version, try to automatically review it. |
1931 | 1905 | */ |
1932 | | - public static function maybeMakeEditReviewed( $rev, $edit ) { |
| 1906 | + public static function maybeMakeEditReviewed( $rev, $edit, $baseRevID ) { |
1933 | 1907 | global $wgFlaggedRevsAutoReview, $wgFlaggedArticle, $wgRequest; |
1934 | 1908 | # Get the user |
1935 | 1909 | $user = User::newFromId( $rev->getUser() ); |
— | — | @@ -1942,13 +1916,13 @@ |
1943 | 1917 | return true; |
1944 | 1918 | } |
1945 | 1919 | # For edits from normal form submits only! |
1946 | | - if( !self::revSubmitted( $title, $rev, $edit ) ) { |
| 1920 | + if( !$edit ) { |
1947 | 1921 | return true; |
1948 | 1922 | } |
1949 | 1923 | $frev = null; |
1950 | 1924 | $reviewableNewPage = false; |
1951 | | - # Get the revision the incoming one was based off |
1952 | | - $baseRevID = $wgRequest->getIntOrNull('baseRevId'); |
| 1925 | + # Get the revision the incoming one was based off if |
| 1926 | + $baseRevID = $baseRevID ? $baseRevID : $wgRequest->getIntOrNull('baseRevId'); |
1953 | 1927 | # If baseRevId not given, assume the previous |
1954 | 1928 | $baseRevID = $baseRevID ? $baseRevID : $title->getPreviousRevisionId( $rev->getId(), GAID_FOR_UPDATE ); |
1955 | 1929 | if( $baseRevID ) { |
— | — | @@ -1980,33 +1954,6 @@ |
1981 | 1955 | } |
1982 | 1956 | |
1983 | 1957 | /** |
1984 | | - * When a rollback is made by a reviwer, try to automatically review it. |
1985 | | - */ |
1986 | | - public static function maybeMakeRollbackReviewed( $article, $user, $rev ) { |
1987 | | - global $wgFlaggedRevsAutoReview, $wgFlaggedArticle; |
1988 | | - if( !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) |
1989 | | - return true; |
1990 | | - # Must be in reviewable namespace |
1991 | | - if( !self::isPageReviewable( $article->getTitle() ) ) |
1992 | | - return true; |
1993 | | - # Was this revision flagged? |
1994 | | - $frev = self::getFlaggedRev( $article->getTitle(), $rev->getId() ); |
1995 | | - if( !is_null($frev) ) { |
1996 | | - # Assume basic flagging level |
1997 | | - $flags = array(); |
1998 | | - foreach( self::$dimensions as $tag => $minQL ) { |
1999 | | - $flags[$tag] = 1; |
2000 | | - } |
2001 | | - $newRev = Revision::newFromId( $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE) ); |
2002 | | - if( $newRev ) { |
2003 | | - self::autoReviewEdit( $article, $user, $rev->getText(), $newRev, $flags ); |
2004 | | - self::articleLinksUpdate( $article ); // lame... |
2005 | | - } |
2006 | | - } |
2007 | | - return true; |
2008 | | - } |
2009 | | - |
2010 | | - /** |
2011 | 1958 | * When an edit is made to a page that can't be reviewed, autopatrol if allowed. |
2012 | 1959 | * This is not loggged for perfomance reasons and no one cares if talk pages and such |
2013 | 1960 | * are autopatrolled. |