Index: trunk/phase3/includes/api/ApiUndelete.php |
— | — | @@ -43,22 +43,22 @@ |
44 | 44 | |
45 | 45 | $titleObj = NULL; |
46 | 46 | if(!isset($params['title'])) |
47 | | - $this->dieUsage('The title parameter must be set', 'notitle'); |
| 47 | + $this->dieUsageMsg(array('missingparam', 'title')); |
48 | 48 | if(!isset($params['token'])) |
49 | | - $this->dieUsage('The token parameter must be set', 'notoken'); |
| 49 | + $this->dieUsageMsg(array('missingparam', 'token')); |
50 | 50 | |
51 | 51 | if(!$wgUser->isAllowed('undelete')) |
52 | | - $this->dieUsage('You don\'t have permission to restore deleted revisions', 'permissiondenied'); |
| 52 | + $this->dieUsageMsg(array('permdenied-undelete')); |
53 | 53 | if($wgUser->isBlocked()) |
54 | | - $this->dieUsage('You have been blocked from editing', 'blocked'); |
| 54 | + $this->dieUsageMsg(array('blockedtext')); |
55 | 55 | if(wfReadOnly()) |
56 | | - $this->dieUsage('The wiki is in read-only mode', 'readonly'); |
| 56 | + $this->dieUsageMsg(array('readonlytext')); |
57 | 57 | if(!$wgUser->matchEditToken($params['token'])) |
58 | | - $this->dieUsage('Invalid token', 'badtoken'); |
| 58 | + $this->dieUsageMsg(array('sessionfailure')); |
59 | 59 | |
60 | 60 | $titleObj = Title::newFromText($params['title']); |
61 | 61 | if(!$titleObj) |
62 | | - $this->dieUsage("Bad title ``{$params['title']}''", 'invalidtitle'); |
| 62 | + $this->dieUsageMsg(array('invalidtitle', $params['title'])); |
63 | 63 | |
64 | 64 | // Convert timestamps |
65 | 65 | if(!is_array($params['timestamps'])) |
— | — | @@ -71,17 +71,9 @@ |
72 | 72 | $dbw->begin(); |
73 | 73 | $retval = $pa->undelete((isset($params['timestamps']) ? $params['timestamps'] : array()), $params['reason']); |
74 | 74 | if(!is_array($retval)) |
75 | | - switch($retval) |
76 | | - { |
77 | | - case PageArchive::UNDELETE_NOTHINGRESTORED: |
78 | | - $this->dieUsage('No revisions could be restored', 'norevs'); |
79 | | - case PageArchive::UNDELETE_NOTAVAIL: |
80 | | - $this->dieUsage('Not all requested revisions could be found', 'revsnotfound'); |
81 | | - case PageArchive::UNDELETE_UNKNOWNERR: |
82 | | - $this->dieUsage('Undeletion failed with unknown error', 'unknownerror'); |
83 | | - } |
| 75 | + $this->dieUsageMsg(array('cannotundelete')); |
| 76 | + |
84 | 77 | $dbw->commit(); |
85 | | - |
86 | 78 | $info['title'] = $titleObj->getPrefixedText(); |
87 | 79 | $info['revisions'] = $retval[0]; |
88 | 80 | $info['fileversions'] = $retval[1]; |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -616,6 +616,8 @@ |
617 | 617 | 'unblock-notarget' => array('code' => 'notarget', 'info' => "Either the id or the user parameter must be set"), |
618 | 618 | 'unblock-idanduser' => array('code' => 'idanduser', 'info' => "The id and user parameters can\'t be used together"), |
619 | 619 | 'cantunblock' => array('code' => 'permissiondenied', 'info' => "You don't have permission to unblock users"), |
| 620 | + 'cannotundelete' => array('code' => 'cantundelete', 'info' => "Couldn't undelete: the requested revisions may not exist, or may have been undeleted already"), |
| 621 | + 'permdenied-undelete' => array('code' => 'permissiondenied', 'info' => "You don't have permission to restore deleted revisions"), |
620 | 622 | ); |
621 | 623 | |
622 | 624 | /** |
Index: trunk/phase3/includes/SpecialUndelete.php |
— | — | @@ -303,9 +303,6 @@ |
304 | 304 | return ($n > 0); |
305 | 305 | } |
306 | 306 | |
307 | | - const UNDELETE_NOTHINGRESTORED = 0; // No revisions could be restored |
308 | | - const UNDELETE_NOTAVAIL = -1; // Not all requested revisions are available |
309 | | - const UNDELETE_UNKNOWNERR = -2; // Unknown error |
310 | 307 | /** |
311 | 308 | * Restore the given (or all) text and file revisions for the page. |
312 | 309 | * Once restored, the items will be removed from the archive tables. |
— | — | @@ -315,7 +312,8 @@ |
316 | 313 | * @param string $comment |
317 | 314 | * @param array $fileVersions |
318 | 315 | * |
319 | | - * @return array(number of revisions restored, number of file versions restored, log reason) on success or UNDELETE_* on failure |
| 316 | + * @return array(number of file revisions restored, number of image revisions restored, log message) |
| 317 | + * on success, false on failure |
320 | 318 | */ |
321 | 319 | function undelete( $timestamps, $comment = '', $fileVersions = array() ) { |
322 | 320 | // If both the set of text revisions and file revisions are empty, |
— | — | @@ -335,8 +333,8 @@ |
336 | 334 | |
337 | 335 | if( $restoreText ) { |
338 | 336 | $textRestored = $this->undeleteRevisions( $timestamps ); |
339 | | - if($textRestored < 0) // It must be one of UNDELETE_* |
340 | | - return $textRestored; |
| 337 | + if($textRestored === false) // It must be one of UNDELETE_* |
| 338 | + return false; |
341 | 339 | } else { |
342 | 340 | $textRestored = 0; |
343 | 341 | } |
— | — | @@ -357,7 +355,7 @@ |
358 | 356 | $wgContLang->formatNum( $filesRestored ) ); |
359 | 357 | } else { |
360 | 358 | wfDebug( "Undelete: nothing undeleted...\n" ); |
361 | | - return self::UNDELETE_NOTHINGRESTORED; |
| 359 | + return false; |
362 | 360 | } |
363 | 361 | |
364 | 362 | if( trim( $comment ) != '' ) |
— | — | @@ -376,10 +374,11 @@ |
377 | 375 | * @param string $comment |
378 | 376 | * @param array $fileVersions |
379 | 377 | * |
380 | | - * @return int number of revisions restored on success or UNDELETE_* on failure |
| 378 | + * @return mixed number of revisions restored or false on failure |
381 | 379 | */ |
382 | 380 | private function undeleteRevisions( $timestamps ) { |
383 | | - if ( wfReadOnly() ) return 0; |
| 381 | + if ( wfReadOnly() ) |
| 382 | + return false; |
384 | 383 | |
385 | 384 | $restoreAll = empty( $timestamps ); |
386 | 385 | |
— | — | @@ -444,7 +443,7 @@ |
445 | 444 | ); |
446 | 445 | if( $dbw->numRows( $result ) < count( $timestamps ) ) { |
447 | 446 | wfDebug( __METHOD__.": couldn't find all requested rows\n" ); |
448 | | - return self::UNDELETE_NOTAVAIL; |
| 447 | + return false; |
449 | 448 | } |
450 | 449 | |
451 | 450 | $revision = null; |