r95588 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95587‎ | r95588 | r95589 >
Date:23:52, 26 August 2011
Author:reedy
Status:ok
Tags:
Comment:
Followup r95572

Couple of stylistic tweaks

Move calls of extractRequestParams after the initial check that may abort the api call
Modified paths:
  • /trunk/extensions/AbuseFilter/api/ApiCheckFilterMatch.php (modified) (history)
  • /trunk/extensions/AbuseFilter/api/ApiCheckFilterSyntax.php (modified) (history)
  • /trunk/extensions/AbuseFilter/api/ApiUnblockAutopromote.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/api/ApiCheckFilterMatch.php
@@ -15,8 +15,11 @@
1616 $vars = json_decode( $params['vars'], true );
1717 } elseif ( $params['rcid'] ) {
1818 $dbr = wfGetDB( DB_SLAVE );
19 - $row = $dbr->selectRow( 'recentchanges', '*',
20 - array( 'rc_id' => $params['rcid'] ), __METHOD__
 19+ $row = $dbr->selectRow(
 20+ 'recentchanges',
 21+ '*',
 22+ array( 'rc_id' => $params['rcid'] ),
 23+ __METHOD__
2124 );
2225
2326 if ( !$row ) {
@@ -26,8 +29,11 @@
2730 $vars = AbuseFilter::getVarsFromRCRow( $row );
2831 } elseif ( $params['logid'] ) {
2932 $dbr = wfGetDB( DB_SLAVE );
30 - $row = $dbr->selectRow( 'abuse_filter_log', '*',
31 - array( 'afl_id' => $params['logid'] ), __METHOD__
 33+ $row = $dbr->selectRow(
 34+ 'abuse_filter_log',
 35+ '*',
 36+ array( 'afl_id' => $params['logid'] ),
 37+ __METHOD__
3238 );
3339
3440 if ( !$row ) {
@@ -86,12 +92,14 @@
8793
8894 public function getPossibleErrors() {
8995 return array_merge( parent::getPossibleErrors(),
90 - $this->getRequireOnlyOneParameterErrorMessages( array( 'vars', 'rcid', 'logid' ) ), array(
91 - array( 'permissiondenied' ),
92 - array( 'nosuchrcid' ),
93 - array( 'code' => 'nosuchlogid', 'info' => 'There is no abuselog entry with the id given' ),
94 - array( 'code' => 'badsyntax', 'info' => 'The filter has invalid syntax' ),
95 - ) );
 96+ $this->getRequireOnlyOneParameterErrorMessages( array( 'vars', 'rcid', 'logid' ) ),
 97+ array(
 98+ array( 'permissiondenied' ),
 99+ array( 'nosuchrcid' ),
 100+ array( 'code' => 'nosuchlogid', 'info' => 'There is no abuselog entry with the id given' ),
 101+ array( 'code' => 'badsyntax', 'info' => 'The filter has invalid syntax' ),
 102+ )
 103+ );
96104 }
97105
98106 public function getExamples() {
Index: trunk/extensions/AbuseFilter/api/ApiCheckFilterSyntax.php
@@ -4,13 +4,13 @@
55
66 public function execute() {
77 global $wgUser;
8 - $params = $this->extractRequestParams();
98
109 // "Anti-DoS"
1110 if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
1211 $this->dieUsageMsg( 'permissiondenied' );
1312 }
1413
 14+ $params = $this->extractRequestParams();
1515 $result = AbuseFilter::checkSyntax( $params[ 'filter' ] );
1616
1717 $r = array();
Index: trunk/extensions/AbuseFilter/api/ApiUnblockAutopromote.php
@@ -3,13 +3,12 @@
44 class ApiUnblockAutopromote extends ApiBase {
55 public function execute() {
66 global $wgUser;
7 - $params = $this->extractRequestParams();
8 - $res = array();
97
108 if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
119 $this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' );
1210 }
1311
 12+ $params = $this->extractRequestParams();
1413 $user = User::newFromName( $params['user'] );
1514
1615 if ( $user === false ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95572Adds ResourceLoader support to AbuseFilter...johnduhart20:12, 26 August 2011

Status & tagging log