Followup r95572

Couple of stylistic tweaks

Move calls of extractRequestParams after the initial check that may abort the api call
This commit is contained in:
Sam Reed 2011-08-26 23:52:46 +00:00
parent 49b54bb0bb
commit 648ffcb3b5
Notes: Raimond Spekking 2012-03-12 20:46:25 +00:00
3 changed files with 20 additions and 13 deletions

View file

@ -15,8 +15,11 @@ class ApiCheckFilterMatch extends ApiBase {
$vars = json_decode( $params['vars'], true );
} elseif ( $params['rcid'] ) {
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'recentchanges', '*',
array( 'rc_id' => $params['rcid'] ), __METHOD__
$row = $dbr->selectRow(
'recentchanges',
'*',
array( 'rc_id' => $params['rcid'] ),
__METHOD__
);
if ( !$row ) {
@ -26,8 +29,11 @@ class ApiCheckFilterMatch extends ApiBase {
$vars = AbuseFilter::getVarsFromRCRow( $row );
} elseif ( $params['logid'] ) {
$dbr = wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'abuse_filter_log', '*',
array( 'afl_id' => $params['logid'] ), __METHOD__
$row = $dbr->selectRow(
'abuse_filter_log',
'*',
array( 'afl_id' => $params['logid'] ),
__METHOD__
);
if ( !$row ) {
@ -86,12 +92,14 @@ class ApiCheckFilterMatch extends ApiBase {
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(),
$this->getRequireOnlyOneParameterErrorMessages( array( 'vars', 'rcid', 'logid' ) ), array(
array( 'permissiondenied' ),
array( 'nosuchrcid' ),
array( 'code' => 'nosuchlogid', 'info' => 'There is no abuselog entry with the id given' ),
array( 'code' => 'badsyntax', 'info' => 'The filter has invalid syntax' ),
) );
$this->getRequireOnlyOneParameterErrorMessages( array( 'vars', 'rcid', 'logid' ) ),
array(
array( 'permissiondenied' ),
array( 'nosuchrcid' ),
array( 'code' => 'nosuchlogid', 'info' => 'There is no abuselog entry with the id given' ),
array( 'code' => 'badsyntax', 'info' => 'The filter has invalid syntax' ),
)
);
}
public function getExamples() {

View file

@ -4,13 +4,13 @@ class ApiCheckFilterSyntax extends ApiBase {
public function execute() {
global $wgUser;
$params = $this->extractRequestParams();
// "Anti-DoS"
if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
$this->dieUsageMsg( 'permissiondenied' );
}
$params = $this->extractRequestParams();
$result = AbuseFilter::checkSyntax( $params[ 'filter' ] );
$r = array();

View file

@ -3,13 +3,12 @@
class ApiUnblockAutopromote extends ApiBase {
public function execute() {
global $wgUser;
$params = $this->extractRequestParams();
$res = array();
if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
$this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' );
}
$params = $this->extractRequestParams();
$user = User::newFromName( $params['user'] );
if ( $user === false ) {