public function execute() { $params = $this->extractRequestParams(); $titleObj = null; if (!isset($params['title'])) { $this->dieUsageMsg(array('missingparam', 'title')); } if (!isset($params['user'])) { $this->dieUsageMsg(array('missingparam', 'user')); } $titleObj = Title::newFromText($params['title']); if (!$titleObj) { $this->dieUsageMsg(array('invalidtitle', $params['title'])); } if (!$titleObj->exists()) { $this->dieUsageMsg(array('notanarticle')); } // We need to be able to revert IPs, but getCanonicalName rejects them $username = User::isIP($params['user']) ? $params['user'] : User::getCanonicalName($params['user']); if (!$username) { $this->dieUsageMsg(array('invaliduser', $params['user'])); } $articleObj = new Article($titleObj); $summary = isset($params['summary']) ? $params['summary'] : ""; $details = null; $retval = $articleObj->doRollback($username, $summary, $params['token'], $params['markbot'], $details); if ($retval) { // We don't care about multiple errors, just report one of them $this->dieUsageMsg(reset($retval)); } $info = array('title' => $titleObj->getPrefixedText(), 'pageid' => intval($details['current']->getPage()), 'summary' => $details['summary'], 'revid' => intval($details['newid']), 'old_revid' => intval($details['current']->getID()), 'last_revid' => intval($details['target']->getID())); $this->getResult()->addValue(null, $this->getModuleName(), $info); }
public function execute() { $params = $this->extractRequestParams(); // User and title already validated in call to getTokenSalt from Main $titleObj = $this->getTitle(); $articleObj = new Article($titleObj); $summary = isset($params['summary']) ? $params['summary'] : ''; $details = array(); $retval = $articleObj->doRollback($this->getUser(), $summary, $params['token'], $params['markbot'], $details); if ($retval) { // We don't care about multiple errors, just report one of them $this->dieUsageMsg(reset($retval)); } $this->setWatch($params['watchlist'], $titleObj); $info = array('title' => $titleObj->getPrefixedText(), 'pageid' => intval($details['current']->getPage()), 'summary' => $details['summary'], 'revid' => intval($details['newid']), 'old_revid' => intval($details['current']->getID()), 'last_revid' => intval($details['target']->getID())); $this->getResult()->addValue(null, $this->getModuleName(), $info); }
public function execute() { global $wgUser; $this->getMain()->requestWriteMode(); $params = $this->extractRequestParams(); $titleObj = NULL; if (!isset($params['title'])) { $this->dieUsageMsg(array('missingparam', 'title')); } if (!isset($params['user'])) { $this->dieUsageMsg(array('missingparam', 'user')); } if (!isset($params['token'])) { $this->dieUsageMsg(array('missingparam', 'token')); } $titleObj = Title::newFromText($params['title']); if (!$titleObj) { $this->dieUsageMsg(array('invalidtitle', $params['title'])); } if (!$titleObj->exists()) { $this->dieUsageMsg(array('notanarticle')); } $username = User::getCanonicalName($params['user']); if (!$username) { $this->dieUsageMsg(array('invaliduser', $params['user'])); } $articleObj = new Article($titleObj); $summary = isset($params['summary']) ? $params['summary'] : ""; $details = null; $dbw = wfGetDb(DB_MASTER); $dbw->begin(); $retval = $articleObj->doRollback($username, $summary, $params['token'], $params['markbot'], $details); if (!empty($retval)) { // We don't care about multiple errors, just report one of them $this->dieUsageMsg(current($retval)); } $dbw->commit(); $current = $target = $summary = NULL; extract($details); $info = array('title' => $titleObj->getPrefixedText(), 'pageid' => $current->getPage(), 'summary' => $summary, 'revid' => $titleObj->getLatestRevID(), 'old_revid' => $current->getID(), 'last_revid' => $target->getID()); $this->getResult()->addValue(null, $this->getModuleName(), $info); }