Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -800,6 +800,11 @@ |
801 | 801 | instead. |
802 | 802 | $tools: array of tools |
803 | 803 | |
| 804 | +'newRevisionFromEditComplete': called when a revision was inserted due to an edit |
| 805 | +$title: the page title |
| 806 | +$rev: the new revision |
| 807 | +$baseID: the revision ID this was based off, if any |
| 808 | + |
804 | 809 | 'OutputPageBeforeHTML': a page has been processed by the parser and |
805 | 810 | the resulting HTML is about to be displayed. |
806 | 811 | $parserOutput: the parserOutput (object) that corresponds to the page |
Index: trunk/phase3/includes/SpecialImport.php |
— | — | @@ -216,9 +216,9 @@ |
217 | 217 | |
218 | 218 | $comment = $detail; // quick |
219 | 219 | $dbw = wfGetDB( DB_MASTER ); |
220 | | - $nullRevision = Revision::newNullRevision( |
221 | | - $dbw, $title->getArticleId(), $comment, true ); |
| 220 | + $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleId(), $comment, true ); |
222 | 221 | $nullRevision->insertOn( $dbw ); |
| 222 | + wfRunHooks( 'newRevisionFromEditComplete', array($title, $nullRevision, false) ); |
223 | 223 | # Update page record |
224 | 224 | $article = new Article( $title ); |
225 | 225 | $article->updateRevisionOn( $dbw, $nullRevision ); |
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 $baseRevId, the revision ID this edit was based off, if any |
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__ ); |
— | — | @@ -1445,6 +1446,8 @@ |
1446 | 1447 | |
1447 | 1448 | $dbw->begin(); |
1448 | 1449 | $revisionId = $revision->insertOn( $dbw ); |
| 1450 | + |
| 1451 | + wfRunHooks( 'newRevisionFromEditComplete', array($this->mTitle, $revision, $baseRevId) ); |
1449 | 1452 | |
1450 | 1453 | # Update page |
1451 | 1454 | $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision ); |
— | — | @@ -1513,6 +1516,8 @@ |
1514 | 1517 | 'text' => $text |
1515 | 1518 | ) ); |
1516 | 1519 | $revisionId = $revision->insertOn( $dbw ); |
| 1520 | + |
| 1521 | + wfRunHooks( 'newRevisionFromEditComplete', array($this->mTitle, $revision, false) ); |
1517 | 1522 | |
1518 | 1523 | $this->mTitle->resetArticleID( $newid ); |
1519 | 1524 | |
— | — | @@ -1865,6 +1870,8 @@ |
1866 | 1871 | # Insert a null revision |
1867 | 1872 | $nullRevision = Revision::newNullRevision( $dbw, $id, $comment, true ); |
1868 | 1873 | $nullRevId = $nullRevision->insertOn( $dbw ); |
| 1874 | + |
| 1875 | + wfRunHooks( 'newRevisionFromEditComplete', array($this->mTitle, $nullRevision, false) ); |
1869 | 1876 | |
1870 | 1877 | # Update page record |
1871 | 1878 | $dbw->update( 'page', |
— | — | @@ -2524,7 +2531,7 @@ |
2525 | 2532 | |
2526 | 2533 | if( $bot && ($wgUser->isAllowed('markbotedits') || $wgUser->isAllowed('bot')) ) |
2527 | 2534 | $flags |= EDIT_FORCE_BOT; |
2528 | | - $this->doEdit( $target->getText(), $summary, $flags ); |
| 2535 | + $this->doEdit( $target->getText(), $summary, $flags, $target->getId() ); |
2529 | 2536 | |
2530 | 2537 | wfRunHooks( 'ArticleRollbackComplete', array( $this, $wgUser, $target ) ); |
2531 | 2538 | |
— | — | @@ -2967,6 +2974,7 @@ |
2968 | 2975 | 'minor_edit' => $minor ? 1 : 0, |
2969 | 2976 | ) ); |
2970 | 2977 | $revision->insertOn( $dbw ); |
| 2978 | + wfRunHooks( 'newRevisionFromEditComplete', array($this->mTitle, $revision, false) ); |
2971 | 2979 | $this->updateRevisionOn( $dbw, $revision ); |
2972 | 2980 | $dbw->commit(); |
2973 | 2981 | |
Index: trunk/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -859,6 +859,7 @@ |
860 | 860 | # Create a null revision |
861 | 861 | $nullRevision = Revision::newNullRevision( $dbw, $descTitle->getArticleId(), $log->getRcComment(), false ); |
862 | 862 | $nullRevision->insertOn( $dbw ); |
| 863 | + wfRunHooks( 'newRevisionFromEditComplete', array($descTitle, $nullRevision, false) ); |
863 | 864 | $article->updateRevisionOn( $dbw, $nullRevision ); |
864 | 865 | |
865 | 866 | # Invalidate the cache for the description page |
Index: trunk/phase3/includes/filerepo/ICRepo.php |
— | — | @@ -286,6 +286,7 @@ |
287 | 287 | # Create a null revision |
288 | 288 | $nullRevision = Revision::newNullRevision( $dbw, $descTitle->getArticleId(), $log->getRcComment(), false ); |
289 | 289 | $nullRevision->insertOn( $dbw ); |
| 290 | + wfRunHooks( 'newRevisionFromEditComplete', array($descTitle, $nullRevision, false) ); |
290 | 291 | $article->updateRevisionOn( $dbw, $nullRevision ); |
291 | 292 | |
292 | 293 | # Invalidate the cache for the description page |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -2599,6 +2599,7 @@ |
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 | 2602 | $nullRevId = $nullRevision->insertOn( $dbw ); |
| 2603 | + wfRunHooks( 'newRevisionFromEditComplete', array($nt, $nullRevision, false) ); |
2603 | 2604 | |
2604 | 2605 | # Change the name of the target page: |
2605 | 2606 | $dbw->update( 'page', |
— | — | @@ -2625,6 +2626,7 @@ |
2626 | 2627 | 'comment' => $comment, |
2627 | 2628 | 'text' => $redirectText ) ); |
2628 | 2629 | $redirectRevision->insertOn( $dbw ); |
| 2630 | + wfRunHooks( 'newRevisionFromEditComplete', array($this, $redirectRevision, false) ); |
2629 | 2631 | $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); |
2630 | 2632 | |
2631 | 2633 | # Now, we record the link from the redirect to the new title. |
— | — | @@ -2686,6 +2688,7 @@ |
2687 | 2689 | # Save a null revision in the page's history notifying of the move |
2688 | 2690 | $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true ); |
2689 | 2691 | $nullRevId = $nullRevision->insertOn( $dbw ); |
| 2692 | + wfRunHooks( 'newRevisionFromEditComplete', array($nt, $nullRevision, false) ); |
2690 | 2693 | |
2691 | 2694 | # Rename page entry |
2692 | 2695 | $dbw->update( 'page', |
— | — | @@ -2712,6 +2715,7 @@ |
2713 | 2716 | 'comment' => $comment, |
2714 | 2717 | 'text' => $redirectText ) ); |
2715 | 2718 | $redirectRevision->insertOn( $dbw ); |
| 2719 | + wfRunHooks( 'newRevisionFromEditComplete', array($this, $redirectRevision, false) ); |
2716 | 2720 | $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); |
2717 | 2721 | |
2718 | 2722 | # Record the just-created redirect's linking to the page |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -284,8 +284,7 @@ |
285 | 285 | $wgHooks['OutputPageParserOutput'][] = 'FlaggedRevs::outputInjectTimestamps'; |
286 | 286 | # Auto-reviewing |
287 | 287 | $wgHooks['ArticleSaveComplete'][] = 'FlaggedRevs::autoMarkPatrolled'; |
288 | | - $wgHooks['RevisionInsertComplete'][] = 'FlaggedRevs::maybeMakeEditReviewed'; |
289 | | - $wgHooks['ArticleRollbackComplete'][] = 'FlaggedRevs::maybeMakeRollbackReviewed'; |
| 288 | + $wgHooks['newRevisionFromEditComplete'][] = 'FlaggedRevs::maybeMakeEditReviewed'; |
290 | 289 | # Disallow moves of stable pages |
291 | 290 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanMove'; |
292 | 291 | $wgHooks['userCan'][] = 'FlaggedRevs::userCanView'; |
— | — | @@ -477,20 +476,12 @@ |
478 | 477 | $wgParser->fr_isStable = false; |
479 | 478 | $wgParser->fr_includesMatched = false; |
480 | 479 | # Do we need to set the template uses via DB? |
481 | | - if( $reparsed ) { |
| 480 | + if( $reparsed && !$wgUseStableTemplates ) { |
482 | 481 | $dbr = wfGetDB( DB_SLAVE ); |
483 | | - if( $wgUseStableTemplates ) { |
484 | | - $res = $dbr->select( array('flaggedtemplates','page','flaggedpages'), |
485 | | - array( 'ft_namespace', 'ft_title', 'fp_stable AS rev_id', 'page_id' ), |
486 | | - array( 'ft_rev_id' => $id, 'page_namespace = ft_namespace', 'page_title = ft_title', |
487 | | - 'fp_page_id = page_id' ), |
488 | | - __METHOD__ ); |
489 | | - } else { |
490 | | - $res = $dbr->select( array('flaggedtemplates','revision'), |
491 | | - array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id AS rev_id', 'rev_page AS page_id' ), |
492 | | - array( 'ft_rev_id' => $id, 'rev_id = ft_rev_id' ), |
493 | | - __METHOD__ ); |
494 | | - } |
| 482 | + $res = $dbr->select( array('flaggedtemplates','revision'), |
| 483 | + array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id AS rev_id', 'rev_page AS page_id' ), |
| 484 | + array( 'ft_rev_id' => $id, 'rev_id = ft_rev_id' ), |
| 485 | + __METHOD__ ); |
495 | 486 | # Add template metadata to output |
496 | 487 | $maxTempID = 0; |
497 | 488 | while( $row = $res->fetchObject() ) { |
— | — | @@ -1934,64 +1925,31 @@ |
1935 | 1926 | } |
1936 | 1927 | |
1937 | 1928 | /** |
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 | | - /** |
1968 | 1929 | * When an edit is made by a reviewer, if the current revision is the stable |
1969 | 1930 | * version, try to automatically review it. |
1970 | 1931 | */ |
1971 | | - public static function maybeMakeEditReviewed( $rev ) { |
| 1932 | + public static function maybeMakeEditReviewed( $title, $rev, $baseRevId = false ) { |
1972 | 1933 | global $wgFlaggedRevsAutoReview, $wgFlaggedArticle, $wgRequest; |
1973 | 1934 | # Get the user |
1974 | 1935 | $user = User::newFromId( $rev->getUser() ); |
1975 | 1936 | if( !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) |
1976 | 1937 | return true; |
1977 | | - # GetTitle() for revisions uses slaves and wants page_id,rev_id to |
1978 | | - # match...this is bad if we *just* added it. |
1979 | | - $title = $rev->getTitle() ? $rev->getTitle() : Title::newFromID( $rev->getPage(), GAID_FOR_UPDATE ); |
1980 | 1938 | # Must be in reviewable namespace |
1981 | 1939 | if( !$title || !self::isPageReviewable( $title ) ) { |
1982 | 1940 | return true; |
1983 | 1941 | } |
1984 | | - # For edits from normal form submits only! |
1985 | | - if( !self::revSubmitted( $title, $rev ) ) { |
1986 | | - return true; |
1987 | | - } |
1988 | 1942 | $frev = null; |
1989 | 1943 | $reviewableNewPage = false; |
1990 | | - # Get the revision the incoming one was based off |
1991 | | - $baseRevID = $wgRequest->getIntOrNull('baseRevId'); |
1992 | | - # If baseRevId not given, assume the previous |
1993 | | - $baseRevID = $baseRevID ? $baseRevID : $title->getPreviousRevisionId( $rev->getId(), GAID_FOR_UPDATE ); |
| 1944 | + # Get the revision ID the incoming one was based off |
| 1945 | + $baseRevID = $baseRevId ? $baseRevId : $wgRequest->getIntOrNull('baseRevId'); |
| 1946 | + # Get what was just the current revision ID |
| 1947 | + $prevRevID = $title->getPreviousRevisionId( $rev->getId(), GAID_FOR_UPDATE ); |
| 1948 | + # If baseRevId not given, assume the previous revision ID |
| 1949 | + $baseRevID = $baseRevID ? $baseRevID : $prevRevID; |
1994 | 1950 | if( $baseRevID ) { |
1995 | 1951 | $frev = self::getFlaggedRev( $title, $baseRevID, false, true, $rev->getPage() ); |
| 1952 | + # If the base revision was not reviewed, check if the previous one was |
| 1953 | + $frev = $frev ? $frev : self::getFlaggedRev( $title, $prevRevID, false, true, $rev->getPage() ); |
1996 | 1954 | } else { |
1997 | 1955 | $prevRevID = $title->getPreviousRevisionId( $rev->getId(), GAID_FOR_UPDATE ); |
1998 | 1956 | $prevRev = $prevRevID ? Revision::newFromID( $prevRevID ) : null; |
— | — | @@ -2019,33 +1977,6 @@ |
2020 | 1978 | } |
2021 | 1979 | |
2022 | 1980 | /** |
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 | | - /** |
2050 | 1981 | * When an edit is made to a page that can't be reviewed, autopatrol if allowed. |
2051 | 1982 | * This is not loggged for perfomance reasons and no one cares if talk pages and such |
2052 | 1983 | * are autopatrolled. |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -726,18 +726,20 @@ |
727 | 727 | # Make a list of each changed template... |
728 | 728 | $dbr = wfGetDB( DB_SLAVE ); |
729 | 729 | global $wgUseStableTemplates; |
| 730 | + // Get templates where the current and stable are not the same revision |
730 | 731 | if( $wgUseStableTemplates ) { |
731 | 732 | $ret = $dbr->select( array('flaggedtemplates','page','flaggedpages'), |
732 | | - array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id' ), |
| 733 | + array( 'ft_namespace', 'ft_title', 'fp_stable AS rev_id' ), |
733 | 734 | array( 'ft_rev_id' => $frev->getRevId(), |
734 | 735 | 'page_namespace = ft_namespace', |
735 | 736 | 'page_title = ft_title', |
736 | 737 | 'fp_page_id = page_id', |
737 | 738 | 'fp_stable != page_latest' ), |
738 | 739 | __METHOD__ ); |
| 740 | + // Get templates that are newer than the ones of the stable version of this page |
739 | 741 | } else { |
740 | 742 | $ret = $dbr->select( array('flaggedtemplates','page'), |
741 | | - array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id' ), |
| 743 | + array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id AS rev_id' ), |
742 | 744 | array( 'ft_rev_id' => $frev->getRevId(), |
743 | 745 | 'page_namespace = ft_namespace', |
744 | 746 | 'page_title = ft_title', |
— | — | @@ -747,11 +749,12 @@ |
748 | 750 | while( $row = $dbr->fetchObject( $ret ) ) { |
749 | 751 | $title = Title::makeTitle( $row->ft_namespace, $row->ft_title ); |
750 | 752 | $changeList[] = $skin->makeKnownLinkObj( $title, $title->GetPrefixedText(), |
751 | | - "diff=cur&oldid=" . $row->ft_tmp_rev_id ); |
| 753 | + "diff=cur&oldid=" . $row->rev_id ); |
752 | 754 | } |
753 | 755 | |
754 | 756 | # And images... |
755 | 757 | global $wgUseStableImages; |
| 758 | + // Get images where the current and stable are not the same revision |
756 | 759 | if( $wgUseStableImages ) { |
757 | 760 | $ret = $dbr->select( array('flaggedimages','page','flaggedpages','flaggedrevs','image'), |
758 | 761 | array( 'fi_name' ), |
— | — | @@ -764,6 +767,7 @@ |
765 | 768 | 'img_name = fi_name', |
766 | 769 | 'fr_img_sha1 != img_sha1' ), |
767 | 770 | __METHOD__ ); |
| 771 | + // Get images that are newer than the ones of the stable version of this page |
768 | 772 | } else { |
769 | 773 | $ret = $dbr->select( array('flaggedimages','image'), |
770 | 774 | array( 'fi_name' ), |