r24518 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24517‎ | r24518 | r24519 >
Date:12:27, 1 August 2007
Author:catrope
Status:old
Tags:
Comment:
apiedit: API: Adapting Rollback module to new Article::doRollback() interface
Modified paths:
  • /branches/apiedit/phase3/includes/api/ApiRollback.php (modified) (history)

Diff [purge]

Index: branches/apiedit/phase3/includes/api/ApiRollback.php
@@ -62,8 +62,8 @@
6363
6464 $articleObj = new Article($titleObj);
6565 $summary = (isset($params['summary']) ? $params['summary'] : "");
66 - $info = array();
67 - $retval = $articleObj->doRollback($params['user'], $params['token'], isset($params['markbot']), $summary, &$info);
 66+ $details = NULL;
 67+ $retval = $articleObj->doRollback($params['user'], $summary, $params['token'], isset($params['markbot']), &$details);
6868
6969 switch($retval)
7070 {
@@ -80,7 +80,10 @@
8181 case Article::BAD_TITLE:
8282 $this->dieUsage("The article ``{$params['title']}'' doesn't exist", 'missingtitle');
8383 case Article::ALREADYROLLED:
84 - $this->dieUsage('The edit(s) you tried to rollback is/are already rolled back', 'alreadyrolled');
 84+ $current = $details['current'];
 85+ $currentID = $current->getId();
 86+ $this->dieUsage("The edit(s) you tried to rollback is/are already rolled back." .
 87+ "The current revision ID is $currentID", 'alreadyrolled');
8588 case Article::ONLY_AUTHOR:
8689 $this->dieUsage("{$params['user']} is the only author of the page", 'onlyauthor');
8790 case Article::EDIT_FAILED:
@@ -90,6 +93,18 @@
9194 $this->dieDebug(__METHOD__, "rollback() returned an unknown error ($retval)");
9295 }
9396 // $retval has to be Article::SUCCESS if we get here
 97+ $current = $target = $summary = NULL;
 98+ extract($details);
 99+
 100+ $info = array(
 101+ 'title' => $titleObj->getPrefixedText(),
 102+ 'pageid' => $current->getPage(),
 103+ 'summary' => $summary,
 104+ 'revid' => $titleObj->getLatestRevID(),
 105+ 'old_revid' => $current->getID(),
 106+ 'last_revid' => $target->getID()
 107+ );
 108+
94109 $this->getResult()->addValue(null, $this->getModuleName(), $info);
95110 }
96111

Status & tagging log