action=protect
* Added allowsduplicates attribute to action=paraminfo output
* (bug 15767) apfilterlanglinks returns duplicate results
+* (bug 15845) Added pageid/fromid parameter to action=delete/move, making
+ manipulation of legacy pages with invalid titles possible
=== Languages updated in 1.14 ===
// API-specific messages
'missingparam' => array('code' => 'no$1', 'info' => "The \$1 parameter must be set"),
'invalidtitle' => array('code' => 'invalidtitle', 'info' => "Bad title ``\$1''"),
+ 'nosuchpageid' => array('code' => 'nosuchpageid', 'info' => "There is no page with ID \$1"),
'invaliduser' => array('code' => 'invaliduser', 'info' => "Invalid username ``\$1''"),
'invalidexpiry' => array('code' => 'invalidexpiry', 'info' => "Invalid expiry time ``\$1''"),
'pastexpiry' => array('code' => 'pastexpiry', 'info' => "Expiry time ``\$1'' is in the past"),
$this->getMain()->requestWriteMode();
$params = $this->extractRequestParams();
- $titleObj = NULL;
- if(!isset($params['title']))
- $this->dieUsageMsg(array('missingparam', 'title'));
+ $this->requireOnlyOneParameter($params, 'title', 'pageid');
if(!isset($params['token']))
$this->dieUsageMsg(array('missingparam', 'token'));
- $titleObj = Title::newFromText($params['title']);
- if(!$titleObj)
- $this->dieUsageMsg(array('invalidtitle', $params['title']));
+ if(isset($params['title']))
+ {
+ $titleObj = Title::newFromText($params['title']);
+ if(!$titleObj)
+ $this->dieUsageMsg(array('invalidtitle', $params['title']));
+ }
+ else if(isset($params['pageid']))
+ {
+ $titleObj = Title::newFromID($params['pageid']);
+ if(!$titleObj)
+ $this->dieUsageMsg(array('nosuchpageid', $params['pageid']));
+ }
if(!$titleObj->exists())
$this->dieUsageMsg(array('notanarticle'));
public static function delete(&$article, $token, &$reason = NULL)
{
global $wgUser;
-
- $errors = self::getPermissionsError($article->getTitle(), $token);
+ $title = $article->getTitle();
+ $errors = self::getPermissionsError($title, $token);
if (count($errors)) return $errors;
// Auto-generate a summary, if necessary
public function getAllowedParams() {
return array (
'title' => null,
+ 'pageid' => array(
+ ApiBase::PARAM_TYPE => 'integer'
+ ),
'token' => null,
'reason' => null,
'watch' => false,
public function getParamDescription() {
return array (
- 'title' => 'Title of the page you want to delete.',
+ 'title' => 'Title of the page you want to delete. Cannot be used together with pageid',
+ 'pageid' => 'Page ID of the page you want to delete. Cannot be used together with title',
'token' => 'A delete token previously retrieved through prop=info',
'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used.',
'watch' => 'Add the page to your watchlist',
if(is_null($params['reason']))
$params['reason'] = '';
- $titleObj = NULL;
- if(!isset($params['from']))
- $this->dieUsageMsg(array('missingparam', 'from'));
+ $this->requireOnlyOneParameter($params, 'from', 'fromid');
if(!isset($params['to']))
$this->dieUsageMsg(array('missingparam', 'to'));
if(!isset($params['token']))
if(!$wgUser->matchEditToken($params['token']))
$this->dieUsageMsg(array('sessionfailure'));
- $fromTitle = Title::newFromText($params['from']);
- if(!$fromTitle)
- $this->dieUsageMsg(array('invalidtitle', $params['from']));
+ if(isset($params['from']))
+ {
+ $fromTitle = Title::newFromText($params['from']);
+ if(!$fromTitle)
+ $this->dieUsageMsg(array('invalidtitle', $params['from']));
+ }
+ else if(isset($params['fromid']))
+ {
+ $fromTitle = Title::newFromID($params['fromid']);
+ if(!$fromTitle)
+ $this->dieUsageMsg(array('nosuchpageid', $params['fromid']));
+ }
if(!$fromTitle->exists())
$this->dieUsageMsg(array('notanarticle'));
$fromTalk = $fromTitle->getTalkPage();
public function getAllowedParams() {
return array (
'from' => null,
+ 'fromid' => array(
+ ApiBase::PARAM_TYPE => 'integer'
+ ),
'to' => null,
'token' => null,
'reason' => null,
public function getParamDescription() {
return array (
- 'from' => 'Title of the page you want to move.',
+ 'from' => 'Title of the page you want to move. Cannot be used together with fromid.',
+ 'fromid' => 'Page ID of the page you want to move. Cannot be used together with from.',
'to' => 'Title you want to rename the page to.',
'token' => 'A move token previously retrieved through prop=info',
'reason' => 'Reason for the move (optional).',