r86431 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86430‎ | r86431 | r86432 >
Date:20:00, 19 April 2011
Author:aaron
Status:ok
Tags:
Comment:
* Update 'revertedEdits' count on reject
* Minor code cleanups
Modified paths:
  • /trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/dataclasses/FRParserCacheStable.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/dataclasses/FRUserCounters.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/dataclasses/FRUserCounters.php
@@ -81,6 +81,21 @@
8282 }
8383
8484 /**
 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+ /**
85100 * Flatten params for a user for DB storage
86101 * Note: param values must be integers
87102 * @param array $params
Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevs.hooks.php
@@ -658,16 +658,10 @@
659659 if ( $rev && $undid && $user->isAllowed( 'autoreview' ) ) {
660660 // Note: $rev->getTitle() might be undefined (no rev id?)
661661 $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
665664 {
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' );
672666 }
673667 }
674668 return true;
Index: trunk/extensions/FlaggedRevs/dataclasses/FRParserCacheStable.php
@@ -10,7 +10,7 @@
1111 static $instance;
1212 if ( !isset( $instance ) ) {
1313 global $parserMemc;
14 - $instance = new FRParserCacheStable( $parserMemc );
 14+ $instance = new self( $parserMemc );
1515 }
1616 return $instance;
1717 }
@@ -23,8 +23,7 @@
2424 */
2525 protected function getParserOutputKey( $article, $hash ) {
2626 $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 );
2928 }
3029
3130 /**
@@ -34,7 +33,6 @@
3534 */
3635 protected function getOptionsKey( $article ) {
3736 $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 );
4038 }
4139 }
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php
@@ -306,6 +306,12 @@
307307 }
308308 $baseRevId = $newRev->isCurrent() ? $oldRev->getId() : 0;
309309 $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+ }
310316 }
311317 # Watch page if set to do so
312318 if ( $status === true ) {

Status & tagging log