mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-09-24 10:48:17 +00:00
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:
parent
49b54bb0bb
commit
648ffcb3b5
Notes:
Raimond Spekking
2012-03-12 20:46:25 +00:00
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in a new issue