mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-24 06:03:49 +00:00
Merge "Move API modules to separate namespace and rename them"
This commit is contained in:
commit
edd998f532
|
@ -115,15 +115,15 @@
|
|||
"abusefilterprivatedetails": "abusefilter-privatedetails-log"
|
||||
},
|
||||
"APIModules": {
|
||||
"abusefilterchecksyntax": "ApiAbuseFilterCheckSyntax",
|
||||
"abusefilterevalexpression": "ApiAbuseFilterEvalExpression",
|
||||
"abusefilterunblockautopromote": "ApiAbuseFilterUnblockAutopromote",
|
||||
"abusefiltercheckmatch": "ApiAbuseFilterCheckMatch",
|
||||
"abuselogprivatedetails": "ApiAbuseLogPrivateDetails"
|
||||
"abusefilterchecksyntax": "MediaWiki\\Extension\\AbuseFilter\\Api\\CheckSyntax",
|
||||
"abusefilterevalexpression": "MediaWiki\\Extension\\AbuseFilter\\Api\\EvalExpression",
|
||||
"abusefilterunblockautopromote": "MediaWiki\\Extension\\AbuseFilter\\Api\\UnblockAutopromote",
|
||||
"abusefiltercheckmatch": "MediaWiki\\Extension\\AbuseFilter\\Api\\CheckMatch",
|
||||
"abuselogprivatedetails": "MediaWiki\\Extension\\AbuseFilter\\Api\\AbuseLogPrivateDetails"
|
||||
},
|
||||
"APIListModules": {
|
||||
"abuselog": "ApiQueryAbuseLog",
|
||||
"abusefilters": "ApiQueryAbuseFilters"
|
||||
"abuselog": "MediaWiki\\Extension\\AbuseFilter\\Api\\QueryAbuseLog",
|
||||
"abusefilters": "MediaWiki\\Extension\\AbuseFilter\\Api\\QueryAbuseFilters"
|
||||
},
|
||||
"MessagesDirs": {
|
||||
"AbuseFilter": [
|
||||
|
@ -135,6 +135,7 @@
|
|||
"AbuseFilterAliases": "AbuseFilter.alias.php"
|
||||
},
|
||||
"AutoloadNamespaces": {
|
||||
"MediaWiki\\Extension\\AbuseFilter\\Api\\": "includes/Api/",
|
||||
"MediaWiki\\Extension\\AbuseFilter\\VariableGenerator\\": "includes/VariableGenerator/",
|
||||
"MediaWiki\\Extension\\AbuseFilter\\Hooks\\": "includes/Hooks/",
|
||||
"MediaWiki\\Extension\\AbuseFilter\\LogFormatter\\": "includes/LogFormatter/",
|
||||
|
@ -191,13 +192,6 @@
|
|||
"AFPSyntaxTree": "includes/parser/AFPSyntaxTree.php",
|
||||
"AFPTreeParser": "includes/parser/AFPTreeParser.php",
|
||||
"AFPUserVisibleException": "includes/parser/AFPUserVisibleException.php",
|
||||
"ApiQueryAbuseLog": "includes/api/ApiQueryAbuseLog.php",
|
||||
"ApiQueryAbuseFilters": "includes/api/ApiQueryAbuseFilters.php",
|
||||
"ApiAbuseFilterCheckSyntax": "includes/api/ApiAbuseFilterCheckSyntax.php",
|
||||
"ApiAbuseFilterEvalExpression": "includes/api/ApiAbuseFilterEvalExpression.php",
|
||||
"ApiAbuseFilterUnblockAutopromote": "includes/api/ApiAbuseFilterUnblockAutopromote.php",
|
||||
"ApiAbuseFilterCheckMatch": "includes/api/ApiAbuseFilterCheckMatch.php",
|
||||
"ApiAbuseLogPrivateDetails": "includes/api/ApiAbuseLogPrivateDetails.php",
|
||||
"NormalizeThrottleParameters": "maintenance/normalizeThrottleParameters.php",
|
||||
"FixOldLogEntries": "maintenance/fixOldLogEntries.php",
|
||||
"UpdateVarDumps": "maintenance/updateVarDumps.php"
|
||||
|
|
|
@ -16,7 +16,11 @@
|
|||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
namespace MediaWiki\Extension\AbuseFilter\Api;
|
||||
|
||||
use ApiBase;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
use SpecialAbuseLog;
|
||||
|
||||
/**
|
||||
* API module to allow accessing private details (the user's IP) from AbuseLog entries
|
||||
|
@ -24,7 +28,7 @@ use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
|||
* @ingroup API
|
||||
* @ingroup Extensions
|
||||
*/
|
||||
class ApiAbuseLogPrivateDetails extends ApiBase {
|
||||
class AbuseLogPrivateDetails extends ApiBase {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
|
@ -1,9 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\AbuseFilter\Api;
|
||||
|
||||
use AbuseFilter;
|
||||
use AbuseFilterVariableHolder;
|
||||
use ApiBase;
|
||||
use ApiResult;
|
||||
use FormatJson;
|
||||
use LogicException;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
use MediaWiki\Extension\AbuseFilter\VariableGenerator\RCVariableGenerator;
|
||||
use RecentChange;
|
||||
|
||||
class ApiAbuseFilterCheckMatch extends ApiBase {
|
||||
class CheckMatch extends ApiBase {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
@ -52,7 +61,7 @@ class ApiAbuseFilterCheckMatch extends ApiBase {
|
|||
}
|
||||
|
||||
$parser = AbuseFilterServices::getParserFactory()->newParser();
|
||||
if ( $parser->checkSyntax( $params[ 'filter' ] ) !== true ) {
|
||||
if ( $parser->checkSyntax( $params['filter'] ) !== true ) {
|
||||
$this->dieWithError( 'apierror-abusefilter-badsyntax', 'badsyntax' );
|
||||
}
|
||||
|
||||
|
@ -70,8 +79,8 @@ class ApiAbuseFilterCheckMatch extends ApiBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getAllowedParams
|
||||
* @return array
|
||||
* @see ApiBase::getAllowedParams
|
||||
*/
|
||||
public function getAllowedParams() {
|
||||
return [
|
||||
|
@ -89,8 +98,8 @@ class ApiAbuseFilterCheckMatch extends ApiBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
* @return array
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
*/
|
||||
protected function getExamplesMessages() {
|
||||
return [
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\AbuseFilter\Api;
|
||||
|
||||
use ApiBase;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
|
||||
class ApiAbuseFilterCheckSyntax extends ApiBase {
|
||||
class CheckSyntax extends ApiBase {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
|
@ -15,7 +18,7 @@ class ApiAbuseFilterCheckSyntax extends ApiBase {
|
|||
}
|
||||
|
||||
$params = $this->extractRequestParams();
|
||||
$result = AbuseFilterServices::getParserFactory()->newParser()->checkSyntax( $params[ 'filter' ] );
|
||||
$result = AbuseFilterServices::getParserFactory()->newParser()->checkSyntax( $params['filter'] );
|
||||
|
||||
$r = [];
|
||||
if ( $result === true ) {
|
||||
|
@ -33,8 +36,8 @@ class ApiAbuseFilterCheckSyntax extends ApiBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getAllowedParams
|
||||
* @return array
|
||||
* @see ApiBase::getAllowedParams
|
||||
*/
|
||||
public function getAllowedParams() {
|
||||
return [
|
||||
|
@ -45,8 +48,8 @@ class ApiAbuseFilterCheckSyntax extends ApiBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
* @return array
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
*/
|
||||
protected function getExamplesMessages() {
|
||||
return [
|
|
@ -1,9 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\AbuseFilter\Api;
|
||||
|
||||
use AbuseFilter;
|
||||
use AbuseFilterVariableHolder;
|
||||
use ApiBase;
|
||||
use ApiResult;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
use MediaWiki\Extension\AbuseFilter\VariableGenerator\VariableGenerator;
|
||||
use Status;
|
||||
|
||||
class ApiAbuseFilterEvalExpression extends ApiBase {
|
||||
class EvalExpression extends ApiBase {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
@ -34,7 +41,7 @@ class ApiAbuseFilterEvalExpression extends ApiBase {
|
|||
* @param string $expr
|
||||
* @return Status
|
||||
*/
|
||||
private function evaluateExpression( string $expr ) : Status {
|
||||
private function evaluateExpression( string $expr ): Status {
|
||||
$parser = AbuseFilterServices::getParserFactory()->newParser();
|
||||
if ( $parser->checkSyntax( $expr ) !== true ) {
|
||||
return Status::newFatal( 'abusefilter-tools-syntax-error' );
|
||||
|
@ -51,8 +58,8 @@ class ApiAbuseFilterEvalExpression extends ApiBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getAllowedParams()
|
||||
* @return array
|
||||
* @see ApiBase::getAllowedParams()
|
||||
*/
|
||||
public function getAllowedParams() {
|
||||
return [
|
||||
|
@ -66,8 +73,8 @@ class ApiAbuseFilterEvalExpression extends ApiBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
* @return array
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
*/
|
||||
protected function getExamplesMessages() {
|
||||
return [
|
|
@ -23,7 +23,13 @@
|
|||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
namespace MediaWiki\Extension\AbuseFilter\Api;
|
||||
|
||||
use ApiBase;
|
||||
use ApiQuery;
|
||||
use ApiQueryBase;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
use MWTimestamp;
|
||||
|
||||
/**
|
||||
* Query module to list abuse filter details.
|
||||
|
@ -31,7 +37,7 @@ use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
|||
* @ingroup API
|
||||
* @ingroup Extensions
|
||||
*/
|
||||
class ApiQueryAbuseFilters extends ApiQueryBase {
|
||||
class QueryAbuseFilters extends ApiQueryBase {
|
||||
/**
|
||||
* @param ApiQuery $query
|
||||
* @param string $moduleName
|
||||
|
@ -162,8 +168,8 @@ class ApiQueryAbuseFilters extends ApiQueryBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiQueryBase::getAllowedParams()
|
||||
* @return array
|
||||
* @see ApiQueryBase::getAllowedParams()
|
||||
*/
|
||||
public function getAllowedParams() {
|
||||
return [
|
||||
|
@ -219,8 +225,8 @@ class ApiQueryAbuseFilters extends ApiQueryBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
* @return array
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
*/
|
||||
protected function getExamplesMessages() {
|
||||
return [
|
|
@ -23,9 +23,19 @@
|
|||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
namespace MediaWiki\Extension\AbuseFilter\Api;
|
||||
|
||||
use AbuseFilter;
|
||||
use ApiBase;
|
||||
use ApiQuery;
|
||||
use ApiQueryBase;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
use MediaWiki\Extension\AbuseFilter\CentralDBNotAvailableException;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MWTimestamp;
|
||||
use SpecialAbuseLog;
|
||||
use Title;
|
||||
use User;
|
||||
use Wikimedia\IPUtils;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +44,7 @@ use Wikimedia\IPUtils;
|
|||
* @ingroup API
|
||||
* @ingroup Extensions
|
||||
*/
|
||||
class ApiQueryAbuseLog extends ApiQueryBase {
|
||||
class QueryAbuseLog extends ApiQueryBase {
|
||||
/**
|
||||
* @param ApiQuery $query
|
||||
* @param string $moduleName
|
||||
|
@ -112,7 +122,7 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
$this->addTables( 'abuse_filter' );
|
||||
$this->addFields( 'af_public_comments' );
|
||||
$this->addJoinConds( [ 'abuse_filter' => [ 'LEFT JOIN',
|
||||
'af_id=afl_filter' ] ] );
|
||||
'af_id=afl_filter' ] ] );
|
||||
}
|
||||
|
||||
$this->addOption( 'LIMIT', $params['limit'] + 1 );
|
||||
|
@ -249,8 +259,8 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiQueryBase::getAllowedParams()
|
||||
* @return array
|
||||
* @see ApiQueryBase::getAllowedParams()
|
||||
*/
|
||||
public function getAllowedParams() {
|
||||
$params = [
|
||||
|
@ -317,8 +327,8 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
* @return array
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
*/
|
||||
protected function getExamplesMessages() {
|
||||
return [
|
|
@ -1,8 +1,12 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
namespace MediaWiki\Extension\AbuseFilter\Api;
|
||||
|
||||
class ApiAbuseFilterUnblockAutopromote extends ApiBase {
|
||||
use ApiBase;
|
||||
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
||||
use User;
|
||||
|
||||
class UnblockAutopromote extends ApiBase {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
@ -38,24 +42,24 @@ class ApiAbuseFilterUnblockAutopromote extends ApiBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::mustBePosted()
|
||||
* @return bool
|
||||
* @see ApiBase::mustBePosted()
|
||||
*/
|
||||
public function mustBePosted() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::isWriteMode()
|
||||
* @return bool
|
||||
* @see ApiBase::isWriteMode()
|
||||
*/
|
||||
public function isWriteMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getAllowedParams()
|
||||
* @return array
|
||||
* @see ApiBase::getAllowedParams()
|
||||
*/
|
||||
public function getAllowedParams() {
|
||||
return [
|
||||
|
@ -68,16 +72,16 @@ class ApiAbuseFilterUnblockAutopromote extends ApiBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::needsToken()
|
||||
* @return string
|
||||
* @see ApiBase::needsToken()
|
||||
*/
|
||||
public function needsToken() {
|
||||
return 'csrf';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
* @return array
|
||||
* @see ApiBase::getExamplesMessages()
|
||||
*/
|
||||
protected function getExamplesMessages() {
|
||||
return [
|
Loading…
Reference in a new issue