public function testUpdateUserParams()
 {
     $p = FRUserCounters::getUserParams(-1);
     # Assumes (main) IN content namespace
     $title = Title::makeTitleSafe(0, 'helloworld');
     $article = new Article($title);
     $copyP = $p;
     FRUserCounters::updateUserParams($copyP, $article, "Manual edit comment");
     $this->assertEquals($p['editComments'] + 1, $copyP['editComments'], "Manual summary");
     $copyP = $p;
     FRUserCounters::updateUserParams($copyP, $article, "/* section */");
     $this->assertEquals($p['editComments'], $copyP['editComments'], "Auto summary");
     $copyP = $p;
     FRUserCounters::updateUserParams($copyP, $article, "edit summary");
     $this->assertEquals($p['totalContentEdits'] + 1, $copyP['totalContentEdits'], "Content edit count on content edit");
     $expected = $p['uniqueContentPages'];
     $expected[] = 0;
     $this->assertEquals($expected, $copyP['uniqueContentPages'], "Unique content pages on content edit");
     # Assumes (user) NOT IN content namespace
     $title = Title::makeTitleSafe(NS_USER, 'helloworld');
     $article = new Article($title);
     $copyP = $p;
     FRUserCounters::updateUserParams($copyP, $article, "Manual edit comment");
     $this->assertEquals($p['editComments'] + 1, $copyP['editComments'], "Manual summary");
     $copyP = $p;
     FRUserCounters::updateUserParams($copyP, $article, "/* section */");
     $this->assertEquals($p['editComments'], $copyP['editComments'], "Auto summary");
     $title = Title::makeTitleSafe(NS_USER, 'helloworld');
     $article = new Article($title);
     $copyP = $p;
     FRUserCounters::updateUserParams($copyP, $article, "edit summary");
     $this->assertEquals($p['totalContentEdits'], $copyP['totalContentEdits'], "Content edit count on non-content edit");
     $this->assertEquals($p['uniqueContentPages'], $copyP['uniqueContentPages'], "Unique content pages on non-content edit");
 }
 /**
  * Callback that autopromotes user according to the setting in
  * $wgFlaggedRevsAutopromote. This also handles user stats tallies.
  */
 public static function onArticleSaveComplete(Page $article, $user, $text, $summary, $m, $a, $b, &$f, $rev)
 {
     global $wgFlaggedRevsAutopromote, $wgFlaggedRevsAutoconfirm;
     # Ignore NULL edits or edits by anon users
     if (!$rev || !$user->getId()) {
         return true;
         # No sense in running counters if nothing uses them
     } elseif (!$wgFlaggedRevsAutopromote && !$wgFlaggedRevsAutoconfirm) {
         return true;
     }
     $p = FRUserCounters::getUserParams($user->getId(), FR_FOR_UPDATE);
     $changed = FRUserCounters::updateUserParams($p, $article, $summary);
     if ($changed) {
         FRUserCounters::saveUserParams($user->getId(), $p);
         // save any updates
     }
     return true;
 }