From: umherirrender Date: Sat, 7 Jul 2012 07:12:04 +0000 (+0200) Subject: API: Cleanup around comment/reason params X-Git-Tag: 1.31.0-rc.0~23019^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=89bb46e2e4a928819bbd1fd12037ae281d5c95f9;p=lhc%2Fweb%2Fwiklou.git API: Cleanup around comment/reason params * Moving setting of empty string to param description. * Removing word "(optional)" from comment/reason param, because all not required params are optional. * Correct description of action=rollback for default comment. Change-Id: Ifa5b60a7b55b216c43049cd81cb584b2e0518eed --- diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index 6cd31ae2fa..183d978795 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -72,9 +72,9 @@ class ApiBlock extends ApiBase { $data = array( 'Target' => $params['user'], 'Reason' => array( - is_null( $params['reason'] ) ? '' : $params['reason'], + $params['reason'], 'other', - is_null( $params['reason'] ) ? '' : $params['reason'] + $params['reason'] ), 'Expiry' => $params['expiry'] == 'never' ? 'infinite' : $params['expiry'], 'HardBlock' => !$params['anononly'], @@ -156,7 +156,7 @@ class ApiBlock extends ApiBase { ApiBase::PARAM_DEPRECATED => true, ), 'expiry' => 'never', - 'reason' => null, + 'reason' => '', 'anononly' => false, 'nocreate' => false, 'autoblock' => false, @@ -174,7 +174,7 @@ class ApiBlock extends ApiBase { 'token' => 'A block token previously obtained through prop=info', 'gettoken' => 'If set, a block token will be returned, and no other action will be taken', 'expiry' => 'Relative expiry time, e.g. \'5 months\' or \'2 weeks\'. If set to \'infinite\', \'indefinite\' or \'never\', the block will never expire.', - 'reason' => 'Reason for block (optional)', + 'reason' => 'Reason for block', 'anononly' => 'Block anonymous users only (i.e. disable anonymous edits for this IP)', 'nocreate' => 'Prevent account creation', 'autoblock' => 'Automatically block the last used IP address, and any subsequent IP addresses they try to login from', diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index 91406afab5..52b025cff3 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -52,7 +52,7 @@ class ApiDelete extends ApiBase { } $titleObj = $pageObj->getTitle(); - $reason = ( isset( $params['reason'] ) ? $params['reason'] : null ); + $reason = $params['reason']; $user = $this->getUser(); if ( $titleObj->getNamespace() == NS_FILE ) { diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index c89f59bbac..acaa8b0bf1 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -37,9 +37,6 @@ class ApiMove extends ApiBase { public function execute() { $user = $this->getUser(); $params = $this->extractRequestParams(); - if ( is_null( $params['reason'] ) ) { - $params['reason'] = ''; - } $this->requireOnlyOneParameter( $params, 'from', 'fromid' ); @@ -181,7 +178,7 @@ class ApiMove extends ApiBase { ApiBase::PARAM_REQUIRED => true ), 'token' => null, - 'reason' => null, + 'reason' => '', 'movetalk' => false, 'movesubpages' => false, 'noredirect' => false, @@ -213,7 +210,7 @@ class ApiMove extends ApiBase { 'fromid' => "Page ID of the page you want to move. Cannot be used together with {$p}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)', + 'reason' => 'Reason for the move', 'movetalk' => 'Move the talk page, if it exists', 'movesubpages' => 'Move subpages, if applicable', 'noredirect' => 'Don\'t create a redirect', diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index 0fcaf42169..42d9f651c6 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -176,7 +176,7 @@ class ApiProtect extends ApiBase { 'protections' => 'Pipe-separated list of protection levels, formatted action=group (e.g. edit=sysop)', 'expiry' => array( 'Expiry timestamps. If only one timestamp is set, it\'ll be used for all protections.', 'Use \'infinite\', \'indefinite\' or \'never\', for a neverexpiring protection.' ), - 'reason' => 'Reason for (un)protecting (optional)', + 'reason' => 'Reason for (un)protecting', 'cascade' => array( 'Enable cascading protection (i.e. protect pages included in this page)', 'Ignored if not all protection levels are \'sysop\' or \'protect\'' ), 'watch' => 'If set, add the page being (un)protected to your watchlist', diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php index 4de49ea9ba..76de5fb504 100644 --- a/includes/api/ApiRollback.php +++ b/includes/api/ApiRollback.php @@ -49,7 +49,7 @@ class ApiRollback extends ApiBase { // User and title already validated in call to getTokenSalt from Main $titleObj = $this->getRbTitle(); $pageObj = WikiPage::factory( $titleObj ); - $summary = ( isset( $params['summary'] ) ? $params['summary'] : '' ); + $summary = $params['summary']; $details = array(); $retval = $pageObj->doRollback( $this->getRbUser(), $summary, $params['token'], $params['markbot'], $details, $this->getUser() ); @@ -91,7 +91,7 @@ class ApiRollback extends ApiBase { ApiBase::PARAM_REQUIRED => true ), 'token' => null, - 'summary' => null, + 'summary' => '', 'markbot' => false, 'watchlist' => array( ApiBase::PARAM_DFLT => 'preferences', @@ -110,7 +110,7 @@ class ApiRollback extends ApiBase { 'title' => 'Title of the page you want to rollback.', 'user' => 'Name of the user whose edits are to be rolled back. If set incorrectly, you\'ll get a badtoken error.', 'token' => "A rollback token previously retrieved through {$this->getModulePrefix()}prop=revisions", - 'summary' => 'Custom edit summary. If not set, default summary will be used', + 'summary' => 'Custom edit summary. If empty, default summary will be used', 'markbot' => 'Mark the reverted edits and the revert as bot edits', 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch', ); diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php index 40a6d44811..9bb82002f7 100644 --- a/includes/api/ApiUnblock.php +++ b/includes/api/ApiUnblock.php @@ -69,7 +69,7 @@ class ApiUnblock extends ApiBase { $data = array( 'Target' => is_null( $params['id'] ) ? $params['user'] : "#{$params['id']}", - 'Reason' => is_null( $params['reason'] ) ? '' : $params['reason'] + 'Reason' => $params['reason'] ); $block = Block::newFromTarget( $data['Target'] ); $retval = SpecialUnblock::processUnblock( $data, $this->getContext() ); @@ -104,7 +104,7 @@ class ApiUnblock extends ApiBase { ApiBase::PARAM_DFLT => false, ApiBase::PARAM_DEPRECATED => true, ), - 'reason' => null, + 'reason' => '', ); } @@ -115,7 +115,7 @@ class ApiUnblock extends ApiBase { 'user' => "Username, IP address or IP range you want to unblock. Cannot be used together with {$p}id", 'token' => "An unblock token previously obtained through prop=info", 'gettoken' => 'If set, an unblock token will be returned, and no other action will be taken', - 'reason' => 'Reason for unblock (optional)', + 'reason' => 'Reason for unblock', ); } diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index c89f49a425..a1a68c3b4b 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -116,7 +116,7 @@ class ApiUndelete extends ApiBase { return array( 'title' => 'Title of the page you want to restore', 'token' => 'An undelete token previously retrieved through list=deletedrevs', - 'reason' => 'Reason for restoring (optional)', + 'reason' => 'Reason for restoring', 'timestamps' => 'Timestamps of the revisions to restore. If not set, all revisions will be restored.', 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch', );