/**
  * Refresh cache when article is edited
  */
 static function onArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
 {
     wfProfileIn(__METHOD__);
     if ($revision !== NULL) {
         // // do not count null edits
         // tell service to update cached data for user who edited the page
         if (!$user->isAnon()) {
             $service = new UserStatsService($user->getId());
             $service->increaseEditsCount();
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
Beispiel #2
0
 /**
  * Increment the user's edit-count field.
  * Will have no effect for anonymous users.
  */
 public function incEditCount()
 {
     global $wgMemc, $wgCityId, $wgEnableEditCountLocal;
     if (!$this->isAnon()) {
         // wikia change, load always from first cluster when we use
         // shared users database
         // @author Lucas Garczewski (tor)
         global $wgExternalSharedDB, $wgSharedDB;
         if (isset($wgSharedDB)) {
             $dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
         } else {
             $dbw = wfGetDB(DB_MASTER);
         }
         $dbw->update('`user`', array('user_editcount=user_editcount+1'), array('user_id' => $this->getId()), __METHOD__);
         $dbw->commit();
         /**
          * Wikia change
          * Update editcount for wiki
          * @since Feb 2013
          * @author Kamil Koterba
          */
         if (!empty($wgEnableEditCountLocal)) {
             $userStatsService = new UserStatsService($this->getId());
             $userStatsService->increaseEditsCount();
         }
         /* end of change */
     }
     // edit count in user cache too
     $this->invalidateCache();
 }
Beispiel #3
0
	function testUserStatsService() {
		global $wgArticle;
		$user = User::newFromName('QATestsBot');

		$service = new UserStatsService($user->getId());
		$stats = $service->getStats();

		$this->assertType('int', $stats['edits']);
		$this->assertType('int', $stats['likes']);
		$this->assertType('string', $stats['date']);

		// edits increase - perform fake edit
		$edits = $stats['edits'];

		$flags = $status = false;
		UserStatsService::onArticleSaveComplete($wgArticle, $user, false, false, false, false, false, $flags, false, $status, false);

		$stats = $service->getStats();

		$this->assertEquals($edits+1, $stats['edits']);

		// edits increase ("manual")
		$edits = $stats['edits'];

		$service->increaseEditsCount();

		$stats = $service->getStats();
		$this->assertEquals($edits+1, $stats['edits']);
	}
Beispiel #4
0
 /**
  * @group UsingDB
  */
 function testUserStatsService()
 {
     $this->markTestSkipped('This is not a unit test');
     $user = User::newFromName('QATestsBot');
     $service = new UserStatsService($user->getId());
     $stats = $service->getStats();
     $this->assertInternalType('int', $stats['edits']);
     $this->assertInternalType('int', $stats['likes']);
     $this->assertInternalType('string', $stats['date']);
     // edits increase - perform fake edit
     $edits = $stats['edits'];
     $service->increaseEditsCount();
     $stats = $service->getStats();
     $this->assertEquals($edits + 1, $stats['edits']);
 }