Index: trunk/phase3/includes/api/ApiMove.php |
— | — | @@ -44,9 +44,7 @@ |
45 | 45 | if(is_null($params['reason'])) |
46 | 46 | $params['reason'] = ''; |
47 | 47 | |
48 | | - $titleObj = NULL; |
49 | | - if(!isset($params['from'])) |
50 | | - $this->dieUsageMsg(array('missingparam', 'from')); |
| 48 | + $this->requireOnlyOneParameter($params, 'from', 'fromid'); |
51 | 49 | if(!isset($params['to'])) |
52 | 50 | $this->dieUsageMsg(array('missingparam', 'to')); |
53 | 51 | if(!isset($params['token'])) |
— | — | @@ -54,9 +52,18 @@ |
55 | 53 | if(!$wgUser->matchEditToken($params['token'])) |
56 | 54 | $this->dieUsageMsg(array('sessionfailure')); |
57 | 55 | |
58 | | - $fromTitle = Title::newFromText($params['from']); |
59 | | - if(!$fromTitle) |
60 | | - $this->dieUsageMsg(array('invalidtitle', $params['from'])); |
| 56 | + if(isset($params['from'])) |
| 57 | + { |
| 58 | + $fromTitle = Title::newFromText($params['from']); |
| 59 | + if(!$fromTitle) |
| 60 | + $this->dieUsageMsg(array('invalidtitle', $params['from'])); |
| 61 | + } |
| 62 | + else if(isset($params['fromid'])) |
| 63 | + { |
| 64 | + $fromTitle = Title::newFromID($params['fromid']); |
| 65 | + if(!$fromTitle) |
| 66 | + $this->dieUsageMsg(array('nosuchpageid', $params['fromid'])); |
| 67 | + } |
61 | 68 | if(!$fromTitle->exists()) |
62 | 69 | $this->dieUsageMsg(array('notanarticle')); |
63 | 70 | $fromTalk = $fromTitle->getTalkPage(); |
— | — | @@ -112,6 +119,9 @@ |
113 | 120 | public function getAllowedParams() { |
114 | 121 | return array ( |
115 | 122 | 'from' => null, |
| 123 | + 'fromid' => array( |
| 124 | + ApiBase::PARAM_TYPE => 'integer' |
| 125 | + ), |
116 | 126 | 'to' => null, |
117 | 127 | 'token' => null, |
118 | 128 | 'reason' => null, |
— | — | @@ -124,7 +134,8 @@ |
125 | 135 | |
126 | 136 | public function getParamDescription() { |
127 | 137 | return array ( |
128 | | - 'from' => 'Title of the page you want to move.', |
| 138 | + 'from' => 'Title of the page you want to move. Cannot be used together with fromid.', |
| 139 | + 'fromid' => 'Page ID of the page you want to move. Cannot be used together with from.', |
129 | 140 | 'to' => 'Title you want to rename the page to.', |
130 | 141 | 'token' => 'A move token previously retrieved through prop=info', |
131 | 142 | 'reason' => 'Reason for the move (optional).', |
Index: trunk/phase3/includes/api/ApiDelete.php |
— | — | @@ -52,15 +52,22 @@ |
53 | 53 | $this->getMain()->requestWriteMode(); |
54 | 54 | $params = $this->extractRequestParams(); |
55 | 55 | |
56 | | - $titleObj = NULL; |
57 | | - if(!isset($params['title'])) |
58 | | - $this->dieUsageMsg(array('missingparam', 'title')); |
| 56 | + $this->requireOnlyOneParameter($params, 'title', 'pageid'); |
59 | 57 | if(!isset($params['token'])) |
60 | 58 | $this->dieUsageMsg(array('missingparam', 'token')); |
61 | 59 | |
62 | | - $titleObj = Title::newFromText($params['title']); |
63 | | - if(!$titleObj) |
64 | | - $this->dieUsageMsg(array('invalidtitle', $params['title'])); |
| 60 | + if(isset($params['title'])) |
| 61 | + { |
| 62 | + $titleObj = Title::newFromText($params['title']); |
| 63 | + if(!$titleObj) |
| 64 | + $this->dieUsageMsg(array('invalidtitle', $params['title'])); |
| 65 | + } |
| 66 | + else if(isset($params['pageid'])) |
| 67 | + { |
| 68 | + $titleObj = Title::newFromID($params['pageid']); |
| 69 | + if(!$titleObj) |
| 70 | + $this->dieUsageMsg(array('nosuchpageid', $params['pageid'])); |
| 71 | + } |
65 | 72 | if(!$titleObj->exists()) |
66 | 73 | $this->dieUsageMsg(array('notanarticle')); |
67 | 74 | |
— | — | @@ -112,8 +119,8 @@ |
113 | 120 | public static function delete(&$article, $token, &$reason = NULL) |
114 | 121 | { |
115 | 122 | global $wgUser; |
116 | | - |
117 | | - $errors = self::getPermissionsError($article->getTitle(), $token); |
| 123 | + $title = $article->getTitle(); |
| 124 | + $errors = self::getPermissionsError($title, $token); |
118 | 125 | if (count($errors)) return $errors; |
119 | 126 | |
120 | 127 | // Auto-generate a summary, if necessary |
— | — | @@ -168,6 +175,9 @@ |
169 | 176 | public function getAllowedParams() { |
170 | 177 | return array ( |
171 | 178 | 'title' => null, |
| 179 | + 'pageid' => array( |
| 180 | + ApiBase::PARAM_TYPE => 'integer' |
| 181 | + ), |
172 | 182 | 'token' => null, |
173 | 183 | 'reason' => null, |
174 | 184 | 'watch' => false, |
— | — | @@ -178,7 +188,8 @@ |
179 | 189 | |
180 | 190 | public function getParamDescription() { |
181 | 191 | return array ( |
182 | | - 'title' => 'Title of the page you want to delete.', |
| 192 | + 'title' => 'Title of the page you want to delete. Cannot be used together with pageid', |
| 193 | + 'pageid' => 'Page ID of the page you want to delete. Cannot be used together with title', |
183 | 194 | 'token' => 'A delete token previously retrieved through prop=info', |
184 | 195 | 'reason' => 'Reason for the deletion. If not set, an automatically generated reason will be used.', |
185 | 196 | 'watch' => 'Add the page to your watchlist', |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -688,6 +688,7 @@ |
689 | 689 | // API-specific messages |
690 | 690 | 'missingparam' => array('code' => 'no$1', 'info' => "The \$1 parameter must be set"), |
691 | 691 | 'invalidtitle' => array('code' => 'invalidtitle', 'info' => "Bad title ``\$1''"), |
| 692 | + 'nosuchpageid' => array('code' => 'nosuchpageid', 'info' => "There is no page with ID \$1"), |
692 | 693 | 'invaliduser' => array('code' => 'invaliduser', 'info' => "Invalid username ``\$1''"), |
693 | 694 | 'invalidexpiry' => array('code' => 'invalidexpiry', 'info' => "Invalid expiry time ``\$1''"), |
694 | 695 | 'pastexpiry' => array('code' => 'pastexpiry', 'info' => "Expiry time ``\$1'' is in the past"), |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -309,6 +309,8 @@ |
310 | 310 | action=protect |
311 | 311 | * Added allowsduplicates attribute to action=paraminfo output |
312 | 312 | * (bug 15767) apfilterlanglinks returns duplicate results |
| 313 | +* (bug 15845) Added pageid/fromid parameter to action=delete/move, making |
| 314 | + manipulation of legacy pages with invalid titles possible |
313 | 315 | |
314 | 316 | === Languages updated in 1.14 === |
315 | 317 | |