public function actionReply($threads, $params)
 {
     global $wgUser;
     // Validate thread parameter
     if (count($threads) > 1) {
         $this->dieUsage('You may only reply to one thread at a time', 'too-many-threads');
     } elseif (count($threads) < 1) {
         $this->dieUsage('You must specify a thread to reply to', 'no-specified-threads');
     }
     $replyTo = array_pop($threads);
     // Check if we can reply to that thread.
     $perm_result = $replyTo->canUserReply($wgUser);
     if ($perm_result !== true) {
         $this->dieUsage("You cannot reply to this thread, because the " . $perm_result . " is protected from replies.", $perm_result . '-protected');
     }
     // Validate text parameter
     if (empty($params['text'])) {
         $this->dieUsage('You must include text in your post', 'no-text');
     }
     $text = $params['text'];
     $bump = isset($params['bump']) ? $params['bump'] : null;
     // Generate/pull summary
     $summary = wfMsgForContent('lqt-reply-summary', $replyTo->subject(), $replyTo->title()->getPrefixedText());
     if (!empty($params['reason'])) {
         $summary = $params['reason'];
     }
     $signature = null;
     if (isset($params['signature'])) {
         $signature = $params['signature'];
     }
     // Grab data from parent
     $talkpage = $replyTo->article();
     $subject = $replyTo->subject();
     // Generate a reply title.
     $title = Threads::newReplyTitle($replyTo, $wgUser);
     $article = new Article($title, 0);
     // Inform hooks what we're doing
     LqtHooks::$editTalkpage = $talkpage;
     LqtHooks::$editArticle = $article;
     LqtHooks::$editThread = null;
     LqtHooks::$editType = 'reply';
     LqtHooks::$editAppliesTo = $replyTo;
     // Pull token in
     $token = $params['token'];
     // All seems in order. Construct an API edit request
     $requestData = array('action' => 'edit', 'title' => $title->getPrefixedText(), 'text' => $text, 'summary' => $summary, 'token' => $token, 'basetimestamp' => wfTimestampNow(), 'minor' => 0, 'format' => 'json');
     if ($wgUser->isAllowed('bot')) {
         $requestData['bot'] = true;
     }
     $editReq = new FauxRequest($requestData, true);
     LqtView::fixFauxRequestSession($editReq);
     $internalApi = new ApiMain($editReq, true);
     $internalApi->execute();
     $editResult = $internalApi->getResultData();
     if ($editResult['edit']['result'] != 'Success') {
         $result = array('result' => 'EditFailure', 'details' => $editResult);
         $this->getResult()->addValue(null, $this->getModuleName(), $result);
         return;
     }
     $articleId = $editResult['edit']['pageid'];
     $article->getTitle()->resetArticleID($articleId);
     $title->resetArticleID($articleId);
     $thread = LqtView::replyMetadataUpdates(array('root' => $article, 'replyTo' => $replyTo, 'signature' => $signature, 'summary' => $summary, 'text' => $text, 'bump' => $bump));
     $result = array('action' => 'reply', 'result' => 'Success', 'thread-id' => $thread->id(), 'thread-title' => $title->getPrefixedText(), 'parent-id' => $replyTo->id(), 'parent-title' => $replyTo->title()->getPrefixedText(), 'ancestor-id' => $replyTo->topmostThread()->id(), 'ancestor-title' => $replyTo->topmostThread()->title()->getPrefixedText(), 'modified' => $thread->modified());
     if (!empty($params['render'])) {
         $result['html'] = self::renderThreadPostAction($thread);
     }
     $result = array('thread' => $result);
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }