r98490 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98489‎ | r98490 | r98491 >
Date:23:30, 29 September 2011
Author:johnduhart
Status:resolved (Comments)
Tags:
Comment:
Followup r95572, rename API modules to reduce chance of collisions per CR
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.php (modified) (history)
  • /trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckMatch.php (added) (history)
  • /trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckSyntax.php (added) (history)
  • /trunk/extensions/AbuseFilter/api/ApiAbuseFilterEvalExpression.php (added) (history)
  • /trunk/extensions/AbuseFilter/api/ApiAbuseFilterUnblockAutopromote.php (added) (history)
  • /trunk/extensions/AbuseFilter/api/ApiCheckFilterMatch.php (deleted) (history)
  • /trunk/extensions/AbuseFilter/api/ApiCheckFilterSyntax.php (deleted) (history)
  • /trunk/extensions/AbuseFilter/api/ApiEvalFilterExpression.php (deleted) (history)
  • /trunk/extensions/AbuseFilter/api/ApiUnblockAutopromote.php (deleted) (history)
  • /trunk/extensions/AbuseFilter/modules/ext.abuseFilter.edit.js (modified) (history)
  • /trunk/extensions/AbuseFilter/modules/ext.abuseFilter.examine.js (modified) (history)
  • /trunk/extensions/AbuseFilter/modules/ext.abuseFilter.tools.js (modified) (history)

Diff [purge]

Index: trunk/extensions/AbuseFilter/AbuseFilter.php
@@ -58,14 +58,14 @@
5959 $wgAPIListModules['abuselog'] = 'ApiQueryAbuseLog';
6060 $wgAutoloadClasses['ApiQueryAbuseFilters'] = "$dir/api/ApiQueryAbuseFilters.php";
6161 $wgAPIListModules['abusefilters'] = 'ApiQueryAbuseFilters';
62 -$wgAutoloadClasses['ApiCheckFilterSyntax'] = "$dir/api/ApiCheckFilterSyntax.php";
63 -$wgAPIModules['checkfiltersyntax'] = 'ApiCheckFilterSyntax';
64 -$wgAutoloadClasses['ApiEvalFilterExpression'] = "$dir/api/ApiEvalFilterExpression.php";
65 -$wgAPIModules['evalfilterexpression'] = 'ApiEvalFilterExpression';
66 -$wgAutoloadClasses['ApiUnblockAutopromote'] = "$dir/api/ApiUnblockAutopromote.php";
67 -$wgAPIModules['unblockautopromote'] = 'ApiUnblockAutopromote';
68 -$wgAutoloadClasses['ApiCheckFilterMatch'] = "$dir/api/ApiCheckFilterMatch.php";
69 -$wgAPIModules['checkfiltermatch'] = 'ApiCheckFilterMatch';
 62+$wgAutoloadClasses['ApiAbuseFilterCheckSyntax'] = "$dir/api/ApiAbuseFilterCheckSyntax.php";
 63+$wgAPIModules['abusefilterchecksyntax'] = 'ApiAbuseFilterCheckSyntax';
 64+$wgAutoloadClasses['ApiAbuseFilterEvalExpression'] = "$dir/api/ApiAbuseFilterEvalExpression.php";
 65+$wgAPIModules['abusefilterevalexpression'] = 'ApiAbuseFilterEvalExpression';
 66+$wgAutoloadClasses['ApiAbuseFilterUnblockAutopromote'] = "$dir/api/ApiAbuseFilterUnblockAutopromote.php";
 67+$wgAPIModules['abusefilterunblockautopromote'] = 'ApiAbuseFilterUnblockAutopromote';
 68+$wgAutoloadClasses['ApiAbuseFilterCheckMatch'] = "$dir/api/ApiAbuseFilterCheckMatch.php";
 69+$wgAPIModules['abusefiltercheckmatch'] = 'ApiAbuseFilterCheckMatch';
7070
7171 $wgHooks['EditFilterMerged'][] = 'AbuseFilterHooks::onEditFilterMerged';
7272 $wgHooks['GetAutoPromoteGroups'][] = 'AbuseFilterHooks::onGetAutoPromoteGroups';
Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.edit.js
@@ -40,7 +40,7 @@
4141 this.disabled = true;
4242 $.getJSON(
4343 mw.util.wikiScript( 'api' ), {
44 - action: 'checkfiltersyntax',
 44+ action: 'abusefilterchecksyntax',
4545 filter: filter,
4646 format: 'json'
4747 }, that.processSyntaxResult
Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.examine.js
@@ -36,7 +36,7 @@
3737 // Large amount of data
3838 $.post(
3939 mw.util.wikiScript( 'api' ), $.extend( params, {
40 - action: 'checkfiltermatch',
 40+ action: 'abusefiltercheckmatch',
4141 filter: filter,
4242 format: 'json'
4343 } ), that.examinerTestProcess, 'json'
Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.tools.js
@@ -15,7 +15,7 @@
1616 $( this ).injectSpinner( 'abusefilter-expr' );
1717 $.getJSON(
1818 mw.util.wikiScript( 'api' ), {
19 - action: 'evalfilterexpression',
 19+ action: 'abusefilterevalexpression',
2020 expression: expr,
2121 format: 'json'
2222 }, that.processExprResult
@@ -47,7 +47,7 @@
4848 $( this ).injectSpinner( 'abusefilter-reautoconfirm' );
4949 $.post(
5050 mw.util.wikiScript( 'api' ), {
51 - action: 'unblockautopromote',
 51+ action: 'abusefilterunblockautopromote',
5252 user: name,
5353 token: mw.user.tokens.get( 'editToken' ),
5454 format: 'json'
Index: trunk/extensions/AbuseFilter/api/ApiCheckFilterMatch.php
@@ -1,114 +0,0 @@
2 -<?php
3 -
4 -class ApiCheckFilterMatch extends ApiBase {
5 - public function execute() {
6 - global $wgUser;
7 - $params = $this->extractRequestParams();
8 - $this->requireOnlyOneParameter( $params, 'vars', 'rcid', 'logid' );
9 -
10 - // "Anti-DoS"
11 - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
12 - $this->dieUsageMsg( 'permissiondenied' );
13 - }
14 -
15 - if ( $params['vars'] ) {
16 - $vars = json_decode( $params['vars'], true );
17 - } elseif ( $params['rcid'] ) {
18 - $dbr = wfGetDB( DB_SLAVE );
19 - $row = $dbr->selectRow(
20 - 'recentchanges',
21 - '*',
22 - array( 'rc_id' => $params['rcid'] ),
23 - __METHOD__
24 - );
25 -
26 - if ( !$row ) {
27 - $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) );
28 - }
29 -
30 - $vars = AbuseFilter::getVarsFromRCRow( $row );
31 - } elseif ( $params['logid'] ) {
32 - $dbr = wfGetDB( DB_SLAVE );
33 - $row = $dbr->selectRow(
34 - 'abuse_filter_log',
35 - '*',
36 - array( 'afl_id' => $params['logid'] ),
37 - __METHOD__
38 - );
39 -
40 - if ( !$row ) {
41 - $this->dieUsage(
42 - "There is no abuselog entry with the id ``{$params['logid']}''",
43 - 'nosuchlogid'
44 - );
45 - }
46 -
47 - $vars = AbuseFilter::loadVarDump( $row->afl_var_dump );
48 - }
49 -
50 - if ( AbuseFilter::checkSyntax( $params[ 'filter' ] ) !== true ) {
51 - $this->dieUsage( 'The filter has invalid syntax', 'badsyntax' );
52 - }
53 -
54 - $result = AbuseFilter::checkConditions( $params['filter'], $vars );
55 - $this->getResult()->addValue(
56 - null,
57 - $this->getModuleName(),
58 - array( 'result' => $result )
59 - );
60 - }
61 -
62 - public function getAllowedParams() {
63 - return array(
64 - 'filter' => array(
65 - ApiBase::PARAM_REQUIRED => true,
66 - ),
67 - 'vars' => null,
68 - 'rcid' => array(
69 - ApiBase::PARAM_TYPE => 'integer'
70 - ),
71 - 'logid' => array(
72 - ApiBase::PARAM_TYPE => 'integer'
73 - ),
74 - );
75 - }
76 -
77 - public function getParamDescription() {
78 - return array(
79 - 'filter' => 'The full filter text to check for a match',
80 - 'vars' => 'JSON encoded array of variables to test against',
81 - 'rcid' => 'Recent change ID to check against',
82 - 'logid' => 'Abuse filter log ID to check against',
83 - );
84 - }
85 -
86 - public function getDescription() {
87 - return array(
88 - 'Check to see if an AbuseFilter matches a set of variables, edit'
89 - . 'or logged AbuseFilter event.',
90 - 'vars, rcid or logid is required however only one may be used',
91 - );
92 - }
93 -
94 - public function getPossibleErrors() {
95 - return array_merge( parent::getPossibleErrors(),
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 - );
104 - }
105 -
106 - public function getExamples() {
107 - return array(
108 - 'api.php?action=checkfiltermatch&filter=!("autoconfirmed"%20in%20user_groups)&rcid=15'
109 - );
110 - }
111 -
112 - public function getVersion() {
113 - return __CLASS__ . ': $Id$';
114 - }
115 -}
Index: trunk/extensions/AbuseFilter/api/ApiCheckFilterSyntax.php
@@ -1,67 +0,0 @@
2 -<?php
3 -
4 -class ApiCheckFilterSyntax extends ApiBase {
5 -
6 - public function execute() {
7 - global $wgUser;
8 -
9 - // "Anti-DoS"
10 - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
11 - $this->dieUsageMsg( 'permissiondenied' );
12 - }
13 -
14 - $params = $this->extractRequestParams();
15 - $result = AbuseFilter::checkSyntax( $params[ 'filter' ] );
16 -
17 - $r = array();
18 - if ( $result === true ) {
19 - // Everything went better than expected :)
20 - $r['status'] = 'ok';
21 - } else {
22 - $r = array(
23 - 'status' => 'error',
24 - 'message' => $result[0],
25 - 'character' => $result[1],
26 - );
27 - }
28 -
29 - $this->getResult()->addValue( null, $this->getModuleName(), $r );
30 - }
31 -
32 - public function getAllowedParams() {
33 - return array(
34 - 'filter' => array(
35 - ApiBase::PARAM_REQUIRED => true,
36 - ),
37 - );
38 - }
39 -
40 - public function getParamDescription() {
41 - return array(
42 - 'filter' => 'The full filter text to check syntax on',
43 - );
44 - }
45 -
46 - public function getDescription() {
47 - return array(
48 - 'Check syntax of an AbuseFilter filter'
49 - );
50 - }
51 -
52 - public function getPossibleErrors() {
53 - return array_merge( parent::getPossibleErrors(), array(
54 - array( 'permissiondenied' ),
55 - ) );
56 - }
57 -
58 - public function getExamples() {
59 - return array(
60 - 'api.php?action=checkfiltersyntax&filter="foo"',
61 - 'api.php?action=checkfiltersyntax&filter="bar"%20bad_variable',
62 - );
63 - }
64 -
65 - public function getVersion() {
66 - return __CLASS__ . ': $Id$';
67 - }
68 -}
\ No newline at end of file
Index: trunk/extensions/AbuseFilter/api/ApiUnblockAutopromote.php
@@ -1,87 +0,0 @@
2 -<?php
3 -
4 -class ApiUnblockAutopromote extends ApiBase {
5 - public function execute() {
6 - global $wgUser;
7 -
8 - if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
9 - $this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' );
10 - }
11 -
12 - $params = $this->extractRequestParams();
13 - $user = User::newFromName( $params['user'] );
14 -
15 - if ( $user === false ) {
16 - // Same as below
17 - $msg = wfMsgExt( 'abusefilter-reautoconfirm-none', array( 'parsemag' ), $params['user'] );
18 - $this->dieUsage( $msg, 'notsuspended' );
19 - }
20 -
21 - global $wgMemc;
22 - $key = AbuseFilter::autoPromoteBlockKey( $user );
23 -
24 - if ( !$wgMemc->get( $key ) ) {
25 - // Oh god this is so bad but this message uses GENDER
26 - $msg = wfMsgExt( 'abusefilter-reautoconfirm-none', array( 'parsemag' ), $params['user'] );
27 - $this->dieUsage( $msg, 'notsuspended' );
28 - }
29 -
30 - $wgMemc->delete( $key );
31 -
32 - $res = array( 'user' => $params['user'] );
33 - $this->getResult()->addValue( null, $this->getModuleName(), $res );
34 - }
35 -
36 - public function mustBePosted() {
37 - return true;
38 - }
39 -
40 - public function isWriteMode() {
41 - return true;
42 - }
43 -
44 - public function getAllowedParams() {
45 - return array(
46 - 'user' => array(
47 - ApiBase::PARAM_REQUIRED => true
48 - ),
49 - 'token' => null,
50 - );
51 - }
52 -
53 - public function getParamDescription() {
54 - return array(
55 - 'user' => 'Username of the user you want to unblock',
56 - 'token' => 'An edit token',
57 - );
58 - }
59 -
60 - public function getDescription() {
61 - return 'Unblocks a user from receiving autopromotions due to an abusefilter consequence';
62 - }
63 -
64 - public function getPossibleErrors() {
65 - return array_merge( parent::getPossibleErrors(), array(
66 - array( 'code' => 'notsuspended', 'info' => 'That user has not had their autoconfirmed status suspended'),
67 - array( 'code' => 'permissiondenied', 'info' => 'You do not have permissions to unblock autopromotion' ),
68 - ) );
69 - }
70 -
71 - public function needsToken() {
72 - return true;
73 - }
74 -
75 - public function getTokenSalt() {
76 - return '';
77 - }
78 -
79 - public function getExamples() {
80 - return array(
81 - 'api.php?action=unblockautopromote&user=Bob'
82 - );
83 - }
84 -
85 - public function getVersion() {
86 - return __CLASS__ . ': $Id$';
87 - }
88 -}
Index: trunk/extensions/AbuseFilter/api/ApiEvalFilterExpression.php
@@ -1,41 +0,0 @@
2 -<?php
3 -
4 -class ApiEvalFilterExpression extends ApiBase {
5 - public function execute() {
6 - $params = $this->extractRequestParams();
7 -
8 - $result = AbuseFilter::evaluateExpression( $params['expression'] );
9 -
10 - $this->getResult()->addValue( null, $this->getModuleName(), array( 'result' => $result ) );
11 - }
12 -
13 - public function getAllowedParams() {
14 - return array(
15 - 'expression' => array(
16 - ApiBase::PARAM_REQUIRED => true,
17 - ),
18 - );
19 - }
20 -
21 - public function getParamDescription() {
22 - return array(
23 - 'expression' => 'The expression to evaluate',
24 - );
25 - }
26 -
27 - public function getDescription() {
28 - return array(
29 - 'Evaluates an AbuseFilter expression'
30 - );
31 - }
32 -
33 - public function getExamples() {
34 - return array(
35 - 'api.php?action=evalfilterexpression&expression=lcase("FOO")'
36 - );
37 - }
38 -
39 - public function getVersion() {
40 - return __CLASS__ . ': $Id$';
41 - }
42 -}
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckMatch.php
@@ -0,0 +1,114 @@
 2+<?php
 3+
 4+class ApiAbuseFilterCheckMatch extends ApiBase {
 5+ public function execute() {
 6+ global $wgUser;
 7+ $params = $this->extractRequestParams();
 8+ $this->requireOnlyOneParameter( $params, 'vars', 'rcid', 'logid' );
 9+
 10+ // "Anti-DoS"
 11+ if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
 12+ $this->dieUsageMsg( 'permissiondenied' );
 13+ }
 14+
 15+ if ( $params['vars'] ) {
 16+ $vars = json_decode( $params['vars'], true );
 17+ } elseif ( $params['rcid'] ) {
 18+ $dbr = wfGetDB( DB_SLAVE );
 19+ $row = $dbr->selectRow(
 20+ 'recentchanges',
 21+ '*',
 22+ array( 'rc_id' => $params['rcid'] ),
 23+ __METHOD__
 24+ );
 25+
 26+ if ( !$row ) {
 27+ $this->dieUsageMsg( array( 'nosuchrcid', $params['rcid'] ) );
 28+ }
 29+
 30+ $vars = AbuseFilter::getVarsFromRCRow( $row );
 31+ } elseif ( $params['logid'] ) {
 32+ $dbr = wfGetDB( DB_SLAVE );
 33+ $row = $dbr->selectRow(
 34+ 'abuse_filter_log',
 35+ '*',
 36+ array( 'afl_id' => $params['logid'] ),
 37+ __METHOD__
 38+ );
 39+
 40+ if ( !$row ) {
 41+ $this->dieUsage(
 42+ "There is no abuselog entry with the id ``{$params['logid']}''",
 43+ 'nosuchlogid'
 44+ );
 45+ }
 46+
 47+ $vars = AbuseFilter::loadVarDump( $row->afl_var_dump );
 48+ }
 49+
 50+ if ( AbuseFilter::checkSyntax( $params[ 'filter' ] ) !== true ) {
 51+ $this->dieUsage( 'The filter has invalid syntax', 'badsyntax' );
 52+ }
 53+
 54+ $result = AbuseFilter::checkConditions( $params['filter'], $vars );
 55+ $this->getResult()->addValue(
 56+ null,
 57+ $this->getModuleName(),
 58+ array( 'result' => $result )
 59+ );
 60+ }
 61+
 62+ public function getAllowedParams() {
 63+ return array(
 64+ 'filter' => array(
 65+ ApiBase::PARAM_REQUIRED => true,
 66+ ),
 67+ 'vars' => null,
 68+ 'rcid' => array(
 69+ ApiBase::PARAM_TYPE => 'integer'
 70+ ),
 71+ 'logid' => array(
 72+ ApiBase::PARAM_TYPE => 'integer'
 73+ ),
 74+ );
 75+ }
 76+
 77+ public function getParamDescription() {
 78+ return array(
 79+ 'filter' => 'The full filter text to check for a match',
 80+ 'vars' => 'JSON encoded array of variables to test against',
 81+ 'rcid' => 'Recent change ID to check against',
 82+ 'logid' => 'Abuse filter log ID to check against',
 83+ );
 84+ }
 85+
 86+ public function getDescription() {
 87+ return array(
 88+ 'Check to see if an AbuseFilter matches a set of variables, edit'
 89+ . 'or logged AbuseFilter event.',
 90+ 'vars, rcid or logid is required however only one may be used',
 91+ );
 92+ }
 93+
 94+ public function getPossibleErrors() {
 95+ return array_merge( parent::getPossibleErrors(),
 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+ );
 104+ }
 105+
 106+ public function getExamples() {
 107+ return array(
 108+ 'api.php?action=checkfiltermatch&filter=!("autoconfirmed"%20in%20user_groups)&rcid=15'
 109+ );
 110+ }
 111+
 112+ public function getVersion() {
 113+ return __CLASS__ . ': $Id$';
 114+ }
 115+}
Property changes on: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckMatch.php
___________________________________________________________________
Added: svn:eol-style
1116 + native
Added: svn:keywords
2117 + Id
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterUnblockAutopromote.php
@@ -0,0 +1,87 @@
 2+<?php
 3+
 4+class ApiAbuseFilterUnblockAutopromote extends ApiBase {
 5+ public function execute() {
 6+ global $wgUser;
 7+
 8+ if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
 9+ $this->dieUsage( 'You do not have permissions to unblock autopromotion', 'permissiondenied' );
 10+ }
 11+
 12+ $params = $this->extractRequestParams();
 13+ $user = User::newFromName( $params['user'] );
 14+
 15+ if ( $user === false ) {
 16+ // Same as below
 17+ $msg = wfMsgExt( 'abusefilter-reautoconfirm-none', array( 'parsemag' ), $params['user'] );
 18+ $this->dieUsage( $msg, 'notsuspended' );
 19+ }
 20+
 21+ global $wgMemc;
 22+ $key = AbuseFilter::autoPromoteBlockKey( $user );
 23+
 24+ if ( !$wgMemc->get( $key ) ) {
 25+ // Oh god this is so bad but this message uses GENDER
 26+ $msg = wfMsgExt( 'abusefilter-reautoconfirm-none', array( 'parsemag' ), $params['user'] );
 27+ $this->dieUsage( $msg, 'notsuspended' );
 28+ }
 29+
 30+ $wgMemc->delete( $key );
 31+
 32+ $res = array( 'user' => $params['user'] );
 33+ $this->getResult()->addValue( null, $this->getModuleName(), $res );
 34+ }
 35+
 36+ public function mustBePosted() {
 37+ return true;
 38+ }
 39+
 40+ public function isWriteMode() {
 41+ return true;
 42+ }
 43+
 44+ public function getAllowedParams() {
 45+ return array(
 46+ 'user' => array(
 47+ ApiBase::PARAM_REQUIRED => true
 48+ ),
 49+ 'token' => null,
 50+ );
 51+ }
 52+
 53+ public function getParamDescription() {
 54+ return array(
 55+ 'user' => 'Username of the user you want to unblock',
 56+ 'token' => 'An edit token',
 57+ );
 58+ }
 59+
 60+ public function getDescription() {
 61+ return 'Unblocks a user from receiving autopromotions due to an abusefilter consequence';
 62+ }
 63+
 64+ public function getPossibleErrors() {
 65+ return array_merge( parent::getPossibleErrors(), array(
 66+ array( 'code' => 'notsuspended', 'info' => 'That user has not had their autoconfirmed status suspended'),
 67+ array( 'code' => 'permissiondenied', 'info' => 'You do not have permissions to unblock autopromotion' ),
 68+ ) );
 69+ }
 70+
 71+ public function needsToken() {
 72+ return true;
 73+ }
 74+
 75+ public function getTokenSalt() {
 76+ return '';
 77+ }
 78+
 79+ public function getExamples() {
 80+ return array(
 81+ 'api.php?action=unblockautopromote&user=Bob'
 82+ );
 83+ }
 84+
 85+ public function getVersion() {
 86+ return __CLASS__ . ': $Id$';
 87+ }
 88+}
Property changes on: trunk/extensions/AbuseFilter/api/ApiAbuseFilterUnblockAutopromote.php
___________________________________________________________________
Added: svn:eol-style
189 + native
Added: svn:keywords
290 + Id
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckSyntax.php
@@ -0,0 +1,67 @@
 2+<?php
 3+
 4+class ApiAbuseFilterCheckSyntax extends ApiBase {
 5+
 6+ public function execute() {
 7+ global $wgUser;
 8+
 9+ // "Anti-DoS"
 10+ if ( !$wgUser->isAllowed( 'abusefilter-modify' ) ) {
 11+ $this->dieUsageMsg( 'permissiondenied' );
 12+ }
 13+
 14+ $params = $this->extractRequestParams();
 15+ $result = AbuseFilter::checkSyntax( $params[ 'filter' ] );
 16+
 17+ $r = array();
 18+ if ( $result === true ) {
 19+ // Everything went better than expected :)
 20+ $r['status'] = 'ok';
 21+ } else {
 22+ $r = array(
 23+ 'status' => 'error',
 24+ 'message' => $result[0],
 25+ 'character' => $result[1],
 26+ );
 27+ }
 28+
 29+ $this->getResult()->addValue( null, $this->getModuleName(), $r );
 30+ }
 31+
 32+ public function getAllowedParams() {
 33+ return array(
 34+ 'filter' => array(
 35+ ApiBase::PARAM_REQUIRED => true,
 36+ ),
 37+ );
 38+ }
 39+
 40+ public function getParamDescription() {
 41+ return array(
 42+ 'filter' => 'The full filter text to check syntax on',
 43+ );
 44+ }
 45+
 46+ public function getDescription() {
 47+ return array(
 48+ 'Check syntax of an AbuseFilter filter'
 49+ );
 50+ }
 51+
 52+ public function getPossibleErrors() {
 53+ return array_merge( parent::getPossibleErrors(), array(
 54+ array( 'permissiondenied' ),
 55+ ) );
 56+ }
 57+
 58+ public function getExamples() {
 59+ return array(
 60+ 'api.php?action=checkfiltersyntax&filter="foo"',
 61+ 'api.php?action=checkfiltersyntax&filter="bar"%20bad_variable',
 62+ );
 63+ }
 64+
 65+ public function getVersion() {
 66+ return __CLASS__ . ': $Id$';
 67+ }
 68+}
\ No newline at end of file
Property changes on: trunk/extensions/AbuseFilter/api/ApiAbuseFilterCheckSyntax.php
___________________________________________________________________
Added: svn:eol-style
169 + native
Added: svn:keywords
270 + Id
Index: trunk/extensions/AbuseFilter/api/ApiAbuseFilterEvalExpression.php
@@ -0,0 +1,41 @@
 2+<?php
 3+
 4+class ApiAbuseFilterEvalExpression extends ApiBase {
 5+ public function execute() {
 6+ $params = $this->extractRequestParams();
 7+
 8+ $result = AbuseFilter::evaluateExpression( $params['expression'] );
 9+
 10+ $this->getResult()->addValue( null, $this->getModuleName(), array( 'result' => $result ) );
 11+ }
 12+
 13+ public function getAllowedParams() {
 14+ return array(
 15+ 'expression' => array(
 16+ ApiBase::PARAM_REQUIRED => true,
 17+ ),
 18+ );
 19+ }
 20+
 21+ public function getParamDescription() {
 22+ return array(
 23+ 'expression' => 'The expression to evaluate',
 24+ );
 25+ }
 26+
 27+ public function getDescription() {
 28+ return array(
 29+ 'Evaluates an AbuseFilter expression'
 30+ );
 31+ }
 32+
 33+ public function getExamples() {
 34+ return array(
 35+ 'api.php?action=evalfilterexpression&expression=lcase("FOO")'
 36+ );
 37+ }
 38+
 39+ public function getVersion() {
 40+ return __CLASS__ . ': $Id$';
 41+ }
 42+}
Property changes on: trunk/extensions/AbuseFilter/api/ApiAbuseFilterEvalExpression.php
___________________________________________________________________
Added: svn:eol-style
143 + native
Added: svn:keywords
244 + Id

Follow-up revisions

RevisionCommit summaryAuthorDate
r98492Followup r98490, since the module names changed the variable names need chang...johnduhart00:05, 30 September 2011

Past revisions this follows-up on

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

Comments

#Comment by Johnduhart (talk | contribs)   23:51, 29 September 2011

Gotta change those variable names as well, darn.

Status & tagging log