/**
  * @param AbstractRevision $revision Revision object
  * @param array $row Revision row
  * @param array $metadata;
  */
 public function onAfterInsert($revision, array $row, array $metadata)
 {
     global $wgRCFeeds;
     // No action on imported revisions
     if (isset($metadata['imported']) && $metadata['imported']) {
         return;
     }
     $action = $revision->getChangeType();
     $revisionId = $revision->getRevisionId()->getAlphadecimal();
     $timestamp = $revision->getRevisionId()->getTimestamp();
     /** @var Workflow $workflow */
     $workflow = $metadata['workflow'];
     $user = $revision->getUser();
     if (!$this->isAllowed($revision, $action)) {
         return;
     }
     $title = $this->getRcTitle($workflow, $revision->getChangeType());
     $attribs = array('rc_namespace' => $title->getNamespace(), 'rc_title' => $title->getDBkey(), 'rc_user' => $row['rev_user_id'], 'rc_user_text' => $this->usernames->get(wfWikiId(), $row['rev_user_id'], $row['rev_user_ip']), 'rc_type' => RC_FLOW, 'rc_source' => self::SRC_FLOW, 'rc_minor' => 0, 'rc_bot' => 0, 'rc_patrolled' => $user->isAllowed('autopatrol') ? 1 : 0, 'rc_old_len' => $revision->getPreviousContentLength(), 'rc_new_len' => $revision->getContentLength(), 'rc_this_oldid' => 0, 'rc_last_oldid' => 0, 'rc_log_type' => null, 'rc_params' => serialize(array('flow-workflow-change' => array('action' => $action, 'revision_type' => get_class($revision), 'revision' => $revisionId, 'workflow' => $workflow->getId()->getAlphadecimal()))), 'rc_cur_id' => 0, 'rc_comment' => '', 'rc_timestamp' => $timestamp, 'rc_deleted' => 0);
     $rc = $this->rcFactory->newFromRow((object) $attribs);
     $rc->save(true);
     // Insert into db
     $feeds = $wgRCFeeds;
     // Override the IRC formatter with our own formatter
     foreach (array_keys($feeds) as $name) {
         $feeds[$name]['original_formatter'] = $feeds[$name]['formatter'];
         $feeds[$name]['formatter'] = $this->ircFormatter;
     }
     // pre-load the irc formatter which will be triggered via hook
     $this->ircFormatter->associate($rc, array('revision' => $revision) + $metadata);
     // run the feeds/irc/etc external notifications
     $rc->notifyRCFeeds($feeds);
 }
 public function testPartialMissingAsFalse()
 {
     $query = $this->getMock('Flow\\Repository\\UserName\\UserNameQuery');
     $query->expects($this->once())->method('execute')->with('fakewiki', array(610, 408))->will($this->returnValue(array((object) array('user_id' => '408', 'user_name' => 'chuck'))));
     $batch = new UserNameBatch($query);
     $batch->add('fakewiki', 610);
     $batch->add('fakewiki', 408);
     $this->assertEquals(false, $batch->get('fakewiki', 610));
 }
 /**
  * Returns pretty-printed user links + user tool links for history and
  * RecentChanges pages.
  *
  * Moderation-aware.
  *
  * @param  AbstractRevision $revision        Revision to display
  * @return string                            HTML
  * @throws PermissionException
  */
 public function getUserLinks(AbstractRevision $revision)
 {
     if (!$revision->isModerated() && !$this->permissions->isAllowed($revision, 'history')) {
         throw new PermissionException('Insufficient permissions to see userlinks for rev_id = ' . $revision->getRevisionId()->getAlphadecimal());
     }
     // if this specific revision is moderated, its usertext can always be
     // displayed, since it will be the moderator user
     static $cache;
     $userid = $revision->getUserId();
     $userip = $revision->getUserIp();
     if (isset($cache[$userid][$userip])) {
         return $cache[$userid][$userip];
     }
     $username = $this->usernames->get(wfWikiId(), $userid, $userip);
     return $cache[$userid][$userip] = Linker::userLink($userid, $username) . Linker::userToolLinks($userid, $username);
 }
 public function serializeUser($userWiki, $userId, $userIp)
 {
     $res = array('name' => $this->usernames->get($userWiki, $userId, $userIp), 'wiki' => $userWiki, 'gender' => 'unknown', 'links' => array(), 'id' => $userId);
     // Only works for the local wiki
     if (wfWikiId() === $userWiki) {
         $res['gender'] = $this->genderCache->getGenderOf($res['name'], __METHOD__);
     }
     if ($res['name']) {
         $res['links'] = $this->serializeUserLinks($res);
     }
     return $res;
 }