Index: trunk/extensions/FlaggedRevs/dataclasses/FRUserCounters.php |
— | — | @@ -81,6 +81,21 @@ |
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
| 85 | + * Increments a count for a user |
| 86 | + * @param int $uid User id |
| 87 | + * @param string $param Count name |
| 88 | + * @return string |
| 89 | + */ |
| 90 | + public static function incCount( $uid, $param ) { |
| 91 | + $p = self::getUserParams( $uid, FR_FOR_UPDATE ); |
| 92 | + if ( !isset( $p[$param] ) ) { |
| 93 | + $p[$param] = 0; |
| 94 | + } |
| 95 | + $p[$param]++; |
| 96 | + FRUserCounters::saveUserParams( $uid, $p ); |
| 97 | + } |
| 98 | + |
| 99 | + /** |
85 | 100 | * Flatten params for a user for DB storage |
86 | 101 | * Note: param values must be integers |
87 | 102 | * @param array $params |
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php |
— | — | @@ -658,16 +658,10 @@ |
659 | 659 | if ( $rev && $undid && $user->isAllowed( 'autoreview' ) ) { |
660 | 660 | // Note: $rev->getTitle() might be undefined (no rev id?) |
661 | 661 | $badRev = Revision::newFromTitle( $article->getTitle(), $undid ); |
662 | | - # Don't count self-reverts |
663 | | - if ( $badRev && $badRev->getRawUser() |
664 | | - && $badRev->getRawUser() != $rev->getRawUser() ) |
| 662 | + if ( $badRev && $badRev->getRawUser() // by logged-in user |
| 663 | + && $badRev->getRawUser() != $rev->getRawUser() ) // no self-reverts |
665 | 664 | { |
666 | | - $p = FRUserCounters::getUserParams( $badRev->getRawUser(), FR_FOR_UPDATE ); |
667 | | - if ( !isset( $p['revertedEdits'] ) ) { |
668 | | - $p['revertedEdits'] = 0; |
669 | | - } |
670 | | - $p['revertedEdits']++; |
671 | | - FRUserCounters::saveUserParams( $badRev->getRawUser(), $p ); |
| 665 | + FRUserCounters::incCount( $badRev->getRawUser(), 'revertedEdits' ); |
672 | 666 | } |
673 | 667 | } |
674 | 668 | return true; |
Index: trunk/extensions/FlaggedRevs/dataclasses/FRParserCacheStable.php |
— | — | @@ -10,7 +10,7 @@ |
11 | 11 | static $instance; |
12 | 12 | if ( !isset( $instance ) ) { |
13 | 13 | global $parserMemc; |
14 | | - $instance = new FRParserCacheStable( $parserMemc ); |
| 14 | + $instance = new self( $parserMemc ); |
15 | 15 | } |
16 | 16 | return $instance; |
17 | 17 | } |
— | — | @@ -23,8 +23,7 @@ |
24 | 24 | */ |
25 | 25 | protected function getParserOutputKey( $article, $hash ) { |
26 | 26 | $key = parent::getParserOutputKey( $article, $hash ); // call super! |
27 | | - $key = str_replace( ':pcache:', ':stable-pcache:', $key ); |
28 | | - return $key; |
| 27 | + return str_replace( ':pcache:', ':stable-pcache:', $key ); |
29 | 28 | } |
30 | 29 | |
31 | 30 | /** |
— | — | @@ -34,7 +33,6 @@ |
35 | 34 | */ |
36 | 35 | protected function getOptionsKey( $article ) { |
37 | 36 | $key = parent::getOptionsKey( $article ); // call super! |
38 | | - $key = str_replace( ':pcache:', ':stable-pcache:', $key ); |
39 | | - return $key; |
| 37 | + return str_replace( ':pcache:', ':stable-pcache:', $key ); |
40 | 38 | } |
41 | 39 | } |
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php |
— | — | @@ -306,6 +306,12 @@ |
307 | 307 | } |
308 | 308 | $baseRevId = $newRev->isCurrent() ? $oldRev->getId() : 0; |
309 | 309 | $article->doEdit( $new_text, $this->getComment(), 0, $baseRevId, $this->user ); |
| 310 | + # If this undid one edit by another logged-in user, update user tallies |
| 311 | + if ( $newRev->getParentId() == $oldRev->getId() && $newRev->getRawUser() ) { |
| 312 | + if ( $newRev->getRawUser() != $this->user->getId() ) { // no self-reverts |
| 313 | + FRUserCounters::incCount( $newRev->getRawUser(), 'revertedEdits' ); |
| 314 | + } |
| 315 | + } |
310 | 316 | } |
311 | 317 | # Watch page if set to do so |
312 | 318 | if ( $status === true ) { |