/**
  * @covers MassMessage::followRedirect
  */
 public function testFollowRedirect()
 {
     $title = Title::newfromtext('R1');
     self::updatePage($title, '#REDIRECT [[R2]]');
     $title2 = Title::newfromtext('R2');
     self::updatePage($title2, 'foo');
     $this->assertEquals($title2->getFullText(), MassMessage::followRedirect($title)->getFullText());
     $this->assertEquals($title2->getFullText(), MassMessage::followRedirect($title2)->getFullText());
 }
 /**
  * Echo!
  *
  * @param $event EchoEvent
  * @return bool
  */
 public static function onBeforeEchoEventInsert(EchoEvent $event)
 {
     // Don't spam a user with mention notifications if it's a MassMessage
     if ($event->getType() == 'mention' && $event->getAgent() && $event->getAgent()->getId() == MassMessage::getMessengerUser()->getId()) {
         return false;
     }
     return true;
 }
 function makeAPIRequest(array $params)
 {
     global $wgUser, $wgRequest;
     $wgRequest = new DerivativeRequest($wgRequest, $params, true);
     $wgUser = MassMessage::getMessengerUser();
     // New user objects will use $wgRequest, so we set that
     // to our DerivativeRequest, so we don't run into any issues
     RequestContext::getMain()->setUser($wgUser);
     RequestContext::getMain()->setRequest($wgRequest);
     // All further internal API requests will use the main
     // RequestContext, so setting it here will fix it for
     // all other internal uses, like how LQT does
     $api = new ApiMain($wgRequest, true);
     try {
         $api->execute();
     } catch (UsageException $e) {
         $this->logLocalFailure($e->getCodeString());
     }
 }
 /**
  * Send out the message
  *
  * @param $data Array
  * @return Status
  */
 protected function submit(array $data)
 {
     $spamlist = $this->getSpamlist($data['spamlist']);
     // Prep the HTML comment message
     $data['comment'] = array($this->getUser()->getName(), wfWikiID(), $spamlist->getFullURL('', false, PROTO_CANONICAL));
     // Log it.
     $this->logToWiki($spamlist, $data['subject']);
     // Insert it into the job queue.
     $pages = MassMessage::getParserFunctionTargets($spamlist, $this->getContext());
     if (!is_array($pages)) {
         $this->status->fatal($pages);
         return $this->status;
     }
     $params = array('data' => $data, 'pages' => $pages);
     $job = new MassMessageSubmitJob($spamlist, $params);
     JobQueueGroup::singleton()->push($job);
     $this->count = count($pages);
     return $this->status;
 }