Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -1868,14 +1868,35 @@ |
1869 | 1869 | } |
1870 | 1870 | |
1871 | 1871 | /** |
| 1872 | + * Was this request an edit to said title? |
| 1873 | + * @param Title $title |
| 1874 | + * @param Revision $rev |
| 1875 | + */ |
| 1876 | + public static function revSubmitted( $title, $rev ) { |
| 1877 | + global $wgRequest, $wgUser; |
| 1878 | + if( !$wgRequest->wasPosted() || !$wgRequest->getVal('wpSave') || $wgRequest->getVal('title') !== $title->getPrefixedDBkey() ) { |
| 1879 | + return false; |
| 1880 | + } |
| 1881 | + # Must be by this user |
| 1882 | + if( $wgUser->getId() ) { |
| 1883 | + if( $rev->getUser() != $wgUser->getId() ) { |
| 1884 | + return false; |
| 1885 | + } |
| 1886 | + # Must be by this IP |
| 1887 | + } else { |
| 1888 | + if( $rev->getRawUserText() != $wgUser->getName() ) { |
| 1889 | + return false; |
| 1890 | + } |
| 1891 | + } |
| 1892 | + return true; |
| 1893 | + } |
| 1894 | + |
| 1895 | + /** |
1872 | 1896 | * When an edit is made by a reviewer, if the current revision is the stable |
1873 | 1897 | * version, try to automatically review it. |
1874 | 1898 | */ |
1875 | 1899 | public static function maybeMakeEditReviewed( $rev ) { |
1876 | | - global $wgFlaggedRevsAutoReview, $wgFlaggedArticle, $wgRequest; |
1877 | | - # For edits from form submits only |
1878 | | - if( !$wgRequest->getVal('wpSave') || !$wgRequest->wasPosted() ) |
1879 | | - return true; |
| 1900 | + global $wgFlaggedRevsAutoReview, $wgFlaggedArticle, $wgRequest, $wgUser; |
1880 | 1901 | # Get the user |
1881 | 1902 | $user = User::newFromId( $rev->getUser() ); |
1882 | 1903 | if( !$wgFlaggedRevsAutoReview || !$user->isAllowed('autoreview') ) |
— | — | @@ -1887,41 +1908,39 @@ |
1888 | 1909 | if( !$title || !self::isPageReviewable( $title ) ) { |
1889 | 1910 | return true; |
1890 | 1911 | } |
| 1912 | + # For edits from normal form submits only! |
| 1913 | + if( !self::revSubmitted( $title, $rev ) ) { |
| 1914 | + return true; |
| 1915 | + } |
1891 | 1916 | $article = new Article( $title ); |
1892 | | - # Revision will be null for null edits |
1893 | | - if( $rev ) { |
1894 | | - $frev = null; |
1895 | | - $reviewableNewPage = false; |
1896 | | - # Get the revision the incoming one was based off |
1897 | | - $baseRevID = $wgRequest->getVal('baseRevId'); |
1898 | | - if( $baseRevID ) { |
1899 | | - $frev = self::getFlaggedRev( $article->getTitle(), $baseRevID ); |
1900 | | - } else { |
1901 | | - $prevRevID = $article->getTitle()->getPreviousRevisionId( $rev->getId() ); |
1902 | | - $prevRev = $prevRevID ? Revision::newFromID( $prevRevID ) : null; |
1903 | | - # Check for null edits |
1904 | | - if( $prevRev && $prevRev->getTextId() == $rev->getTextId() ) { |
1905 | | - $frev = self::getFlaggedRev( $title, $prevRev->getId() ); |
1906 | | - # Check for new pages |
1907 | | - } else if( !$prevRev ) { |
1908 | | - global $wgFlaggedRevsAutoReviewNew; |
1909 | | - $reviewableNewPage = $wgFlaggedRevsAutoReviewNew; |
1910 | | - } |
| 1917 | + $frev = null; |
| 1918 | + $reviewableNewPage = false; |
| 1919 | + # Get the revision the incoming one was based off |
| 1920 | + $baseRevID = $wgRequest->getVal('baseRevId'); |
| 1921 | + if( $baseRevID ) { |
| 1922 | + $frev = self::getFlaggedRev( $article->getTitle(), $baseRevID ); |
| 1923 | + } else { |
| 1924 | + $prevRevID = $article->getTitle()->getPreviousRevisionId( $rev->getId() ); |
| 1925 | + $prevRev = $prevRevID ? Revision::newFromID( $prevRevID ) : null; |
| 1926 | + # Check for null edits |
| 1927 | + if( $prevRev && $prevRev->getTextId() == $rev->getTextId() ) { |
| 1928 | + $frev = self::getFlaggedRev( $title, $prevRev->getId() ); |
| 1929 | + # Check for new pages |
| 1930 | + } else if( !$prevRev ) { |
| 1931 | + global $wgFlaggedRevsAutoReviewNew; |
| 1932 | + $reviewableNewPage = $wgFlaggedRevsAutoReviewNew; |
1911 | 1933 | } |
1912 | | - # Is this an edit directly to the stable version? |
1913 | | - if( $reviewableNewPage || !is_null($frev) ) { |
1914 | | - # Assume basic flagging level |
1915 | | - $flags = array(); |
1916 | | - foreach( self::$dimensions as $tag => $minQL ) { |
1917 | | - $flags[$tag] = 1; |
1918 | | - } |
1919 | | - # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit... |
1920 | | - self::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags, false ); |
| 1934 | + } |
| 1935 | + # Is this an edit directly to the stable version? |
| 1936 | + if( $reviewableNewPage || !is_null($frev) ) { |
| 1937 | + # Assume basic flagging level |
| 1938 | + $flags = array(); |
| 1939 | + foreach( self::$dimensions as $tag => $minQL ) { |
| 1940 | + $flags[$tag] = 1; |
1921 | 1941 | } |
| 1942 | + # Review this revision of the page. Let articlesavecomplete hook do rc_patrolled bit... |
| 1943 | + self::autoReviewEdit( $article, $user, $rev->getText(), $rev, $flags, false ); |
1922 | 1944 | } |
1923 | | - if( $wgFlaggedArticle ) { |
1924 | | - $wgFlaggedArticle->skipReviewDiff = true; // Don't jump to diff... |
1925 | | - } |
1926 | 1945 | return true; |
1927 | 1946 | } |
1928 | 1947 | |
— | — | @@ -1949,9 +1968,6 @@ |
1950 | 1969 | self::articleLinksUpdate( $article ); // lame... |
1951 | 1970 | } |
1952 | 1971 | } |
1953 | | - if( $wgFlaggedArticle ) { |
1954 | | - $wgFlaggedArticle->skipReviewDiff = true; // Don't jump to diff... |
1955 | | - } |
1956 | 1972 | return true; |
1957 | 1973 | } |
1958 | 1974 | |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -2,7 +2,6 @@ |
3 | 3 | |
4 | 4 | class FlaggedArticle extends Article { |
5 | 5 | public $isDiffFromStable = false; |
6 | | - public $skipReviewDiff = false; |
7 | 6 | public $stableRev = null; |
8 | 7 | public $pageconfig = null; |
9 | 8 | public $flags = null; |
— | — | @@ -849,17 +848,15 @@ |
850 | 849 | # Don't show this for the talk page |
851 | 850 | if( !$this->isReviewable() || $article->getTitle()->isTalkPage() ) |
852 | 851 | return true; |
853 | | - # Get the stable version and flags |
854 | | - $frev = $this->getStableRev(); |
855 | | - $flags = $frev ? $frev->getTags() : array(); |
| 852 | + # Get the stable version, from master |
| 853 | + $frev = $this->getStableRev( false, true ); |
| 854 | + if( !$frev ) |
| 855 | + return true; |
| 856 | + $latest = $article->getTitle()->getLatestRevID(GAID_FOR_UPDATE); |
856 | 857 | // If we are supposed to review after edit, and it was not autoreviewed, |
857 | 858 | // and the user can actually make new stable version, take us to the diff... |
858 | | - if( $wgReviewChangesAfterEdit && !$this->skipReviewDiff && $frev && RevisionReview::userCanSetFlags($flags) ) { |
859 | | - $flags = $frev->getTags(); |
860 | | - # If the user can update the stable version, jump to it... |
861 | | - if( RevisionReview::userCanSetFlags( $flags ) ) { |
862 | | - $extraq .= "oldid={$frev->getRevId()}&diff=cur"; |
863 | | - } |
| 859 | + if( $wgReviewChangesAfterEdit && $frev && $latest > $frev->getRevId() && $frev->userCanSetFlags() ) { |
| 860 | + $extraq .= "oldid={$frev->getRevId()}&diff=cur"; |
864 | 861 | // ...otherwise, go to the current revision after completing an edit. |
865 | 862 | } else { |
866 | 863 | if( $frev ){ |
— | — | @@ -869,7 +866,6 @@ |
870 | 867 | } |
871 | 868 | } |
872 | 869 | } |
873 | | - |
874 | 870 | return true; |
875 | 871 | } |
876 | 872 | |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | * @returns String revision timestamp in MW format |
63 | 63 | */ |
64 | 64 | public function getTimestamp() { |
65 | | - return wfTimestamp(TS_MW, $this->mTimestamp); |
| 65 | + return wfTimestamp( TS_MW, $this->mTimestamp ); |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
— | — | @@ -116,6 +116,13 @@ |
117 | 117 | public function getTags() { |
118 | 118 | return $this->mTags; |
119 | 119 | } |
| 120 | + |
| 121 | + /** |
| 122 | + * @returns bool |
| 123 | + */ |
| 124 | + public function userCanSetFlags() { |
| 125 | + return RevisionReview::userCanSetFlags( $this->mTags ); |
| 126 | + } |
120 | 127 | |
121 | 128 | /** |
122 | 129 | * @returns mixed (string/false) expanded text |