public function execute() { global $wgRequest, $wgWikiLoveLogging, $wgParser; $params = $this->extractRequestParams(); $title = Title::newFromText($params['title']); if (is_null($title)) { $this->dieUsageMsg(array('invaliduser', $params['title'])); } $talk = WikiLoveHooks::getUserTalkPage($title); if (is_null($talk)) { $this->dieUsageMsg(array('invaliduser', $params['title'])); } if ($wgWikiLoveLogging) { $this->saveInDb($talk, $params['subject'], $params['message'], $params['type'], isset($params['email']) ? 1 : 0); } // not using section => 'new' here, as we like to give our own edit summary $api = new ApiMain(new DerivativeRequest($wgRequest, array('action' => 'edit', 'title' => $talk->getFullText(), 'appendtext' => ($talk->exists() ? "\n\n" : '') . wfMsgForContent('newsectionheaderdefaultlevel', $params['subject']) . "\n\n" . $params['text'], 'token' => $params['token'], 'summary' => wfMsgForContent('wikilove-summary', $wgParser->stripSectionName($params['subject'])), 'notminor' => true), false), true); $api->execute(); if (isset($params['email'])) { $this->emailUser($talk, $params['subject'], $params['email'], $params['token']); } $this->getResult()->addValue('redirect', 'pageName', $talk->getPrefixedDBkey()); $this->getResult()->addValue('redirect', 'fragment', Title::escapeFragmentForURL($params['subject'])); // note that we cannot use Title::makeTitle here as it doesn't sanitize the fragment }