mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-27 23:40:19 +00:00
Merge "Allow filtering AbuseLog in API by wiki"
This commit is contained in:
commit
c84da3552e
|
@ -455,6 +455,7 @@
|
|||
"apihelp-query+abuselog-param-filter": "Show only entries that were caught by a given filter ID.",
|
||||
"apihelp-query+abuselog-param-limit": "The maximum amount of entries to list.",
|
||||
"apihelp-query+abuselog-param-prop": "Which properties to get.",
|
||||
"apihelp-query+abuselog-param-wiki": "Wiki to show hits from.",
|
||||
"apihelp-query+abuselog-example-1": "Show recent log entries",
|
||||
"apihelp-query+abuselog-example-2": "Show recent log entries for [[API]]",
|
||||
"apierror-abusefilter-canttest": "You don't have permission to test abuse filters.",
|
||||
|
|
|
@ -486,6 +486,7 @@
|
|||
"apihelp-query+abuselog-param-filter": "{{doc-apihelp-param|query+abuselog|filter}}",
|
||||
"apihelp-query+abuselog-param-limit": "{{doc-apihelp-param|query+abuselog|limit}}",
|
||||
"apihelp-query+abuselog-param-prop": "{{doc-apihelp-param|query+abuselog|prop}}",
|
||||
"apihelp-query+abuselog-param-wiki": "{{doc-apihelp-param|query+abuselog|wiki}}",
|
||||
"apihelp-query+abuselog-example-1": "{{doc-apihelp-example|query+abuselog}}",
|
||||
"apihelp-query+abuselog-example-2": "{{doc-apihelp-example|query+abuselog}}",
|
||||
"apierror-abusefilter-canttest": "{{doc-apierror}}",
|
||||
|
|
|
@ -35,6 +35,8 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
}
|
||||
|
||||
public function execute() {
|
||||
global $wgAbuseFilterIsCentral;
|
||||
|
||||
$user = $this->getUser();
|
||||
$errors = $this->getTitle()->getUserPermissionsErrors(
|
||||
'abusefilter-log', $user, true, [ 'ns-specialprotected' ] );
|
||||
|
@ -57,6 +59,7 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
$fld_timestamp = isset( $prop['timestamp'] );
|
||||
$fld_hidden = isset( $prop['hidden'] );
|
||||
$fld_revid = isset( $prop['revid'] );
|
||||
$fld_wiki = $wgAbuseFilterIsCentral && isset( $prop['wiki'] );
|
||||
|
||||
if ( $fld_ip ) {
|
||||
$this->checkUserRightsAny( 'abusefilter-private' );
|
||||
|
@ -95,6 +98,7 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
$this->addFieldsIf( 'afl_action', $fld_action );
|
||||
$this->addFieldsIf( 'afl_var_dump', $fld_details );
|
||||
$this->addFieldsIf( 'afl_actions', $fld_result );
|
||||
$this->addFieldsIf( 'afl_wiki', $fld_wiki );
|
||||
|
||||
if ( $fld_filter ) {
|
||||
$this->addTables( 'abuse_filter' );
|
||||
|
@ -136,6 +140,8 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
|
||||
$this->addWhereIf( [ 'afl_filter' => $params['filter'] ], isset( $params['filter'] ) );
|
||||
$this->addWhereIf( $notDeletedCond, !SpecialAbuseLog::canSeeHidden( $user ) );
|
||||
$this->addWhereIf( [ 'afl_wiki' => $params['wiki'] ],
|
||||
$wgAbuseFilterIsCentral && isset( $params['wiki'] ) );
|
||||
|
||||
$title = $params['title'];
|
||||
if ( !is_null( $title ) ) {
|
||||
|
@ -185,6 +191,9 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
if ( $fld_ip ) {
|
||||
$entry['ip'] = $row->afl_ip;
|
||||
}
|
||||
if ( $fld_wiki ) {
|
||||
$entry['wiki'] = $row->afl_wiki;
|
||||
}
|
||||
if ( $fld_title ) {
|
||||
$title = Title::makeTitle( $row->afl_namespace, $row->afl_title );
|
||||
ApiQueryBase::addTitleInfo( $entry, $title );
|
||||
|
@ -237,7 +246,9 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
}
|
||||
|
||||
public function getAllowedParams() {
|
||||
return [
|
||||
global $wgAbuseFilterIsCentral;
|
||||
|
||||
$params = [
|
||||
'start' => [
|
||||
ApiBase::PARAM_TYPE => 'timestamp'
|
||||
],
|
||||
|
@ -255,6 +266,7 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
'user' => null,
|
||||
'title' => null,
|
||||
'filter' => [
|
||||
ApiBase::PARAM_TYPE => 'string',
|
||||
ApiBase::PARAM_ISMULTI => true
|
||||
],
|
||||
'limit' => [
|
||||
|
@ -282,6 +294,14 @@ class ApiQueryAbuseLog extends ApiQueryBase {
|
|||
ApiBase::PARAM_ISMULTI => true
|
||||
]
|
||||
];
|
||||
if ( $wgAbuseFilterIsCentral ) {
|
||||
$params['wiki'] = [
|
||||
ApiBase::PARAM_TYPE => 'string',
|
||||
];
|
||||
$params['prop'][ApiBase::PARAM_DFLT] .= '|wiki';
|
||||
$params['prop'][ApiBase::PARAM_TYPE][] = 'wiki';
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue