API: Cleanup around comment/reason params
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 7 Jul 2012 07:12:04 +0000 (09:12 +0200)
committerTimo Tijhof <ttijhof@wikimedia.org>
Sun, 8 Jul 2012 21:31:26 +0000 (23:31 +0200)
* 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

includes/api/ApiBlock.php
includes/api/ApiDelete.php
includes/api/ApiMove.php
includes/api/ApiProtect.php
includes/api/ApiRollback.php
includes/api/ApiUnblock.php
includes/api/ApiUndelete.php

index 6cd31ae..183d978 100644 (file)
@@ -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',
index 91406af..52b025c 100644 (file)
@@ -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 ) {
index c89f59b..acaa8b0 100644 (file)
@@ -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',
index 0fcaf42..42d9f65 100644 (file)
@@ -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',
index 4de49ea..76de5fb 100644 (file)
@@ -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',
                );
index 40a6d44..9bb8200 100644 (file)
@@ -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',
                );
        }
 
index c89f49a..a1a68c3 100644 (file)
@@ -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',
                );