2009-03-28 23:40:27 +00:00
|
|
|
<?php
|
2009-10-07 13:57:06 +00:00
|
|
|
/**
|
2009-03-28 23:40:27 +00:00
|
|
|
* Created on Mar 28, 2009
|
|
|
|
*
|
|
|
|
* AbuseFilter extension
|
|
|
|
*
|
2010-08-19 21:12:09 +00:00
|
|
|
* Copyright © 2008 Alex Z. mrzmanwiki AT gmail DOT com
|
2009-03-28 23:40:27 +00:00
|
|
|
* Based mostly on code by Bryan Tong Minh and Roan Kattouw
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2010-06-21 13:45:17 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-03-28 23:40:27 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*/
|
|
|
|
|
2020-12-03 22:05:42 +00:00
|
|
|
namespace MediaWiki\Extension\AbuseFilter\Api;
|
|
|
|
|
|
|
|
use ApiBase;
|
|
|
|
use ApiQuery;
|
|
|
|
use ApiQueryBase;
|
2018-09-11 16:57:49 +00:00
|
|
|
use InvalidArgumentException;
|
2021-01-03 11:12:16 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilter;
|
2020-09-18 14:49:13 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilterServices;
|
2020-10-17 08:27:02 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\CentralDBNotAvailableException;
|
2020-12-02 22:47:40 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\GlobalNameUtils;
|
2021-01-01 17:28:36 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Special\SpecialAbuseLog;
|
2020-01-08 16:46:24 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2020-12-03 22:05:42 +00:00
|
|
|
use MWTimestamp;
|
|
|
|
use Title;
|
|
|
|
use User;
|
2020-01-24 17:26:03 +00:00
|
|
|
use Wikimedia\IPUtils;
|
2020-01-08 13:33:10 +00:00
|
|
|
|
2009-03-28 23:40:27 +00:00
|
|
|
/**
|
|
|
|
* Query module to list abuse log entries.
|
|
|
|
*
|
|
|
|
* @ingroup API
|
|
|
|
* @ingroup Extensions
|
|
|
|
*/
|
2020-12-03 22:05:42 +00:00
|
|
|
class QueryAbuseLog extends ApiQueryBase {
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @param ApiQuery $query
|
|
|
|
* @param string $moduleName
|
|
|
|
*/
|
2018-10-17 05:15:21 +00:00
|
|
|
public function __construct( ApiQuery $query, $moduleName ) {
|
2009-10-07 13:57:06 +00:00
|
|
|
parent::__construct( $query, $moduleName, 'afl' );
|
2009-03-28 23:40:27 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
2019-01-11 16:34:08 +00:00
|
|
|
* @inheritDoc
|
2018-04-04 21:14:25 +00:00
|
|
|
*/
|
2009-03-28 23:40:27 +00:00
|
|
|
public function execute() {
|
2020-09-18 14:49:13 +00:00
|
|
|
$afPermManager = AbuseFilterServices::getPermissionManager();
|
2020-10-17 08:27:02 +00:00
|
|
|
$lookup = AbuseFilterServices::getFilterLookup();
|
2018-09-11 16:57:49 +00:00
|
|
|
$aflFilterMigrationStage = $this->getConfig()->get( 'AbuseFilterAflFilterMigrationStage' );
|
|
|
|
|
2019-01-11 16:34:08 +00:00
|
|
|
// Same check as in SpecialAbuseLog
|
|
|
|
$this->checkUserRightsAny( 'abusefilter-log' );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2019-01-11 16:34:08 +00:00
|
|
|
$user = $this->getUser();
|
2009-03-28 23:40:27 +00:00
|
|
|
$params = $this->extractRequestParams();
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
$prop = array_flip( $params['prop'] );
|
|
|
|
$fld_ids = isset( $prop['ids'] );
|
|
|
|
$fld_filter = isset( $prop['filter'] );
|
|
|
|
$fld_user = isset( $prop['user'] );
|
|
|
|
$fld_title = isset( $prop['title'] );
|
|
|
|
$fld_action = isset( $prop['action'] );
|
|
|
|
$fld_details = isset( $prop['details'] );
|
|
|
|
$fld_result = isset( $prop['result'] );
|
|
|
|
$fld_timestamp = isset( $prop['timestamp'] );
|
2010-06-25 20:04:55 +00:00
|
|
|
$fld_hidden = isset( $prop['hidden'] );
|
2012-12-14 11:17:24 +00:00
|
|
|
$fld_revid = isset( $prop['revid'] );
|
2018-03-10 21:47:33 +00:00
|
|
|
$isCentral = $this->getConfig()->get( 'AbuseFilterIsCentral' );
|
|
|
|
$fld_wiki = $isCentral && isset( $prop['wiki'] );
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2017-08-08 12:03:56 +00:00
|
|
|
if ( $fld_details ) {
|
|
|
|
$this->checkUserRightsAny( 'abusefilter-log-detail' );
|
2010-08-19 21:12:09 +00:00
|
|
|
}
|
2018-09-11 16:57:49 +00:00
|
|
|
|
|
|
|
// Map of [ [ id, global ], ... ]
|
|
|
|
$searchFilters = [];
|
2012-12-11 00:58:24 +00:00
|
|
|
// Match permissions for viewing events on private filters to SpecialAbuseLog (bug 42814)
|
2018-09-11 16:57:49 +00:00
|
|
|
// @todo Avoid code duplication with SpecialAbuseLog::showList, make it so that, if hidden
|
|
|
|
// filters are specified, we only filter them out instead of failing.
|
|
|
|
if ( $params['filter'] ) {
|
2012-12-07 00:01:22 +00:00
|
|
|
if ( !is_array( $params['filter'] ) ) {
|
2017-06-15 14:23:16 +00:00
|
|
|
$params['filter'] = [ $params['filter'] ];
|
2012-12-07 00:01:22 +00:00
|
|
|
}
|
2018-09-11 16:57:49 +00:00
|
|
|
|
|
|
|
$foundInvalid = false;
|
2015-09-28 18:03:35 +00:00
|
|
|
foreach ( $params['filter'] as $filter ) {
|
2020-10-17 08:27:02 +00:00
|
|
|
try {
|
2020-12-02 22:47:40 +00:00
|
|
|
$searchFilters[] = GlobalNameUtils::splitGlobalName( $filter );
|
2018-09-11 16:57:49 +00:00
|
|
|
} catch ( InvalidArgumentException $e ) {
|
|
|
|
$foundInvalid = true;
|
|
|
|
continue;
|
2020-10-17 08:27:02 +00:00
|
|
|
}
|
2018-09-11 16:57:49 +00:00
|
|
|
}
|
|
|
|
// @phan-suppress-next-line PhanImpossibleCondition
|
|
|
|
if ( $foundInvalid ) {
|
|
|
|
// @todo Tell what the invalid IDs are
|
|
|
|
$this->addWarning( 'abusefilter-log-invalid-filter' );
|
|
|
|
}
|
|
|
|
if ( !$afPermManager->canViewPrivateFiltersLogs( $user ) ) {
|
|
|
|
foreach ( $searchFilters as [ $filterID, $global ] ) {
|
|
|
|
try {
|
|
|
|
$isHidden = $lookup->getFilter( $filterID, $global )->isHidden();
|
|
|
|
} catch ( CentralDBNotAvailableException $_ ) {
|
|
|
|
$isHidden = false;
|
|
|
|
}
|
|
|
|
if ( $isHidden ) {
|
|
|
|
$this->dieWithError(
|
|
|
|
[ 'apierror-permissiondenied', $this->msg( 'action-abusefilter-log-private' ) ]
|
|
|
|
);
|
|
|
|
}
|
2012-12-07 00:01:22 +00:00
|
|
|
}
|
|
|
|
}
|
2012-12-11 00:58:24 +00:00
|
|
|
}
|
2009-03-28 23:40:27 +00:00
|
|
|
|
|
|
|
$result = $this->getResult();
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
$this->addTables( 'abuse_filter_log' );
|
|
|
|
$this->addFields( 'afl_timestamp' );
|
2012-12-14 11:17:24 +00:00
|
|
|
$this->addFields( 'afl_rev_id' );
|
|
|
|
$this->addFields( 'afl_deleted' );
|
2018-09-11 16:57:49 +00:00
|
|
|
$this->addFieldsIf( 'afl_filter',
|
|
|
|
( $aflFilterMigrationStage & SCHEMA_COMPAT_READ_OLD ) !== 0 );
|
|
|
|
$this->addFieldsIf( 'afl_filter_id',
|
|
|
|
( $aflFilterMigrationStage & SCHEMA_COMPAT_READ_NEW ) !== 0 );
|
|
|
|
$this->addFieldsIf( 'afl_global',
|
|
|
|
( $aflFilterMigrationStage & SCHEMA_COMPAT_READ_NEW ) !== 0 );
|
2012-12-14 11:17:24 +00:00
|
|
|
$this->addFieldsIf( 'afl_id', $fld_ids );
|
2013-06-26 22:58:36 +00:00
|
|
|
$this->addFieldsIf( 'afl_user_text', $fld_user );
|
2017-06-15 14:23:16 +00:00
|
|
|
$this->addFieldsIf( [ 'afl_namespace', 'afl_title' ], $fld_title );
|
2009-10-07 13:57:06 +00:00
|
|
|
$this->addFieldsIf( 'afl_action', $fld_action );
|
|
|
|
$this->addFieldsIf( 'afl_var_dump', $fld_details );
|
|
|
|
$this->addFieldsIf( 'afl_actions', $fld_result );
|
2018-02-03 15:39:08 +00:00
|
|
|
$this->addFieldsIf( 'afl_wiki', $fld_wiki );
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2010-02-13 14:10:36 +00:00
|
|
|
if ( $fld_filter ) {
|
2009-10-07 13:57:06 +00:00
|
|
|
$this->addTables( 'abuse_filter' );
|
|
|
|
$this->addFields( 'af_public_comments' );
|
2018-09-11 16:57:49 +00:00
|
|
|
|
|
|
|
if ( $aflFilterMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
|
|
|
|
$join = [ 'af_id=afl_filter_id', 'afl_global' => 0 ];
|
|
|
|
} else {
|
|
|
|
// SCHEMA_COMPAT_READ_OLD
|
|
|
|
$join = 'af_id=afl_filter';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->addJoinConds( [ 'abuse_filter' => [ 'LEFT JOIN', $join ] ] );
|
2009-03-30 12:19:41 +00:00
|
|
|
}
|
2009-03-28 23:40:27 +00:00
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
$this->addOption( 'LIMIT', $params['limit'] + 1 );
|
|
|
|
|
2018-07-14 12:26:42 +00:00
|
|
|
$this->addWhereIf( [ 'afl_id' => $params['logid'] ], isset( $params['logid'] ) );
|
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
$this->addWhereRange( 'afl_timestamp', $params['dir'], $params['start'], $params['end'] );
|
2012-12-11 00:58:24 +00:00
|
|
|
|
2013-03-25 23:28:26 +00:00
|
|
|
if ( isset( $params['user'] ) ) {
|
|
|
|
$u = User::newFromName( $params['user'] );
|
|
|
|
if ( $u ) {
|
|
|
|
// Username normalisation
|
|
|
|
$params['user'] = $u->getName();
|
|
|
|
$userId = $u->getId();
|
2020-01-24 17:26:03 +00:00
|
|
|
} elseif ( IPUtils::isIPAddress( $params['user'] ) ) {
|
2013-03-25 23:28:26 +00:00
|
|
|
// It's an IP, sanitize it
|
2020-01-24 17:26:03 +00:00
|
|
|
$params['user'] = IPUtils::sanitizeIP( $params['user'] );
|
2013-03-25 23:28:26 +00:00
|
|
|
$userId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isset( $userId ) ) {
|
2015-09-28 18:03:35 +00:00
|
|
|
// Only add the WHERE for user in case it's either a valid user
|
|
|
|
// (but not necessary an existing one) or an IP.
|
2013-03-25 23:28:26 +00:00
|
|
|
$this->addWhere(
|
2017-06-15 14:23:16 +00:00
|
|
|
[
|
2013-03-25 23:28:26 +00:00
|
|
|
'afl_user' => $userId,
|
|
|
|
'afl_user_text' => $params['user']
|
2017-06-15 14:23:16 +00:00
|
|
|
]
|
2013-03-25 23:28:26 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-18 14:49:13 +00:00
|
|
|
$this->addWhereIf( [ 'afl_deleted' => 0 ], !$afPermManager->canSeeHiddenLogEntries( $user ) );
|
2018-09-11 16:57:49 +00:00
|
|
|
|
|
|
|
if ( $searchFilters ) {
|
|
|
|
$conds = [];
|
|
|
|
// @todo Avoid code duplication with SpecialAbuseLog::showList
|
|
|
|
if ( $aflFilterMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
|
|
|
|
$filterConds = [ 'local' => [], 'global' => [] ];
|
|
|
|
foreach ( $searchFilters as $filter ) {
|
|
|
|
$isGlobal = $filter[1];
|
|
|
|
$key = $isGlobal ? 'global' : 'local';
|
|
|
|
$filterConds[$key][] = $filter[0];
|
|
|
|
}
|
|
|
|
$conds = [];
|
|
|
|
// @phan-suppress-next-line PhanImpossibleCondition False positive
|
|
|
|
if ( $filterConds['local'] ) {
|
|
|
|
$conds[] = $this->getDB()->makeList(
|
|
|
|
[ 'afl_global' => 0, 'afl_filter_id' => $filterConds['local'] ],
|
|
|
|
LIST_AND
|
|
|
|
);
|
|
|
|
}
|
|
|
|
// @phan-suppress-next-line PhanImpossibleCondition False positive
|
|
|
|
if ( $filterConds['global'] ) {
|
|
|
|
$conds[] = $this->getDB()->makeList(
|
|
|
|
[ 'afl_global' => 1, 'afl_filter_id' => $filterConds['global'] ],
|
|
|
|
LIST_AND
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$conds = $this->getDB()->makeList( $conds, LIST_OR );
|
|
|
|
} else {
|
|
|
|
// SCHEMA_COMPAT_READ_OLD
|
|
|
|
$names = [];
|
|
|
|
foreach ( $searchFilters as $filter ) {
|
2020-12-02 22:47:40 +00:00
|
|
|
$names[] = GlobalNameUtils::buildGlobalName( ...$filter );
|
2018-09-11 16:57:49 +00:00
|
|
|
}
|
|
|
|
$conds = [ 'afl_filter' => $names ];
|
|
|
|
}
|
|
|
|
$this->addWhere( $conds );
|
|
|
|
}
|
|
|
|
|
2018-02-09 20:00:07 +00:00
|
|
|
if ( isset( $params['wiki'] ) ) {
|
|
|
|
// 'wiki' won't be set if $wgAbuseFilterIsCentral = false
|
2018-03-10 21:47:33 +00:00
|
|
|
$this->addWhereIf( [ 'afl_wiki' => $params['wiki'] ], $isCentral );
|
2018-02-09 20:00:07 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2009-03-28 23:40:27 +00:00
|
|
|
$title = $params['title'];
|
2020-01-21 07:38:52 +00:00
|
|
|
if ( $title !== null ) {
|
2009-10-07 13:57:06 +00:00
|
|
|
$titleObj = Title::newFromText( $title );
|
2020-01-21 07:38:52 +00:00
|
|
|
if ( $titleObj === null ) {
|
2017-08-07 23:35:21 +00:00
|
|
|
$this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $title ) ] );
|
2010-08-19 21:12:09 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
$this->addWhereFld( 'afl_namespace', $titleObj->getNamespace() );
|
|
|
|
$this->addWhereFld( 'afl_title', $titleObj->getDBkey() );
|
|
|
|
}
|
|
|
|
$res = $this->select( __METHOD__ );
|
2009-03-28 23:40:27 +00:00
|
|
|
|
|
|
|
$count = 0;
|
2011-02-10 17:25:25 +00:00
|
|
|
foreach ( $res as $row ) {
|
2010-02-13 14:10:36 +00:00
|
|
|
if ( ++$count > $params['limit'] ) {
|
2009-03-28 23:40:27 +00:00
|
|
|
// We've had enough
|
2012-09-02 11:07:02 +00:00
|
|
|
$ts = new MWTimestamp( $row->afl_timestamp );
|
|
|
|
$this->setContinueEnumParameter( 'start', $ts->getTimestamp( TS_ISO_8601 ) );
|
2009-03-28 23:40:27 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-10-16 21:04:20 +00:00
|
|
|
$hidden = SpecialAbuseLog::isHidden( $row );
|
2020-09-18 14:49:13 +00:00
|
|
|
if ( $hidden === true && !$afPermManager->canSeeHiddenLogEntries( $user ) ) {
|
2012-02-10 23:41:05 +00:00
|
|
|
continue;
|
2020-01-08 16:46:24 +00:00
|
|
|
}
|
|
|
|
if ( $hidden === 'implicit' ) {
|
|
|
|
$revRec = MediaWikiServices::getInstance()
|
|
|
|
->getRevisionLookup()
|
|
|
|
->getRevisionById( (int)$row->afl_rev_id );
|
|
|
|
if ( !AbuseFilter::userCanViewRev( $revRec, $user ) ) {
|
2018-10-16 21:04:20 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-02-10 23:41:05 +00:00
|
|
|
}
|
2018-09-11 16:57:49 +00:00
|
|
|
|
|
|
|
if ( $aflFilterMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
|
|
|
|
$filterID = $row->afl_filter_id;
|
|
|
|
$global = $row->afl_global;
|
2020-12-02 22:47:40 +00:00
|
|
|
$fullName = GlobalNameUtils::buildGlobalName( $filterID, $global );
|
2018-09-11 16:57:49 +00:00
|
|
|
} else {
|
|
|
|
// SCHEMA_COMPAT_READ_OLD
|
2020-12-02 22:47:40 +00:00
|
|
|
list( $filterID, $global ) = GlobalNameUtils::splitGlobalName( $row->afl_filter );
|
2018-09-11 16:57:49 +00:00
|
|
|
$fullName = $row->afl_filter;
|
|
|
|
}
|
2020-11-18 19:24:02 +00:00
|
|
|
$isHidden = $lookup->getFilter( $filterID, $global )->isHidden();
|
2020-10-27 19:21:44 +00:00
|
|
|
$canSeeDetails = $afPermManager->canSeeLogDetailsForFilter( $user, $isHidden );
|
2013-07-17 15:18:13 +00:00
|
|
|
|
2017-06-15 14:23:16 +00:00
|
|
|
$entry = [];
|
2010-02-13 14:10:36 +00:00
|
|
|
if ( $fld_ids ) {
|
2009-10-07 13:57:06 +00:00
|
|
|
$entry['id'] = intval( $row->afl_id );
|
2018-09-11 16:57:49 +00:00
|
|
|
$entry['filter_id'] = $canSeeDetails ? $fullName : '';
|
2009-03-28 23:40:27 +00:00
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
if ( $fld_filter ) {
|
2019-02-06 12:59:34 +00:00
|
|
|
if ( $global ) {
|
2020-10-17 08:27:02 +00:00
|
|
|
$entry['filter'] = $lookup->getFilter( $filterID, true )->getName();
|
2016-12-26 09:49:26 +00:00
|
|
|
} else {
|
|
|
|
$entry['filter'] = $row->af_public_comments;
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
}
|
|
|
|
if ( $fld_user ) {
|
2013-06-26 22:58:36 +00:00
|
|
|
$entry['user'] = $row->afl_user_text;
|
2010-08-19 21:12:09 +00:00
|
|
|
}
|
2018-02-03 15:39:08 +00:00
|
|
|
if ( $fld_wiki ) {
|
|
|
|
$entry['wiki'] = $row->afl_wiki;
|
|
|
|
}
|
2010-02-13 14:10:36 +00:00
|
|
|
if ( $fld_title ) {
|
2009-10-07 13:57:06 +00:00
|
|
|
$title = Title::makeTitle( $row->afl_namespace, $row->afl_title );
|
|
|
|
ApiQueryBase::addTitleInfo( $entry, $title );
|
2009-03-28 23:40:27 +00:00
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
if ( $fld_action ) {
|
2009-03-28 23:40:27 +00:00
|
|
|
$entry['action'] = $row->afl_action;
|
2010-08-19 21:12:09 +00:00
|
|
|
}
|
|
|
|
if ( $fld_result ) {
|
2009-03-28 23:40:27 +00:00
|
|
|
$entry['result'] = $row->afl_actions;
|
2010-08-19 21:12:09 +00:00
|
|
|
}
|
2020-01-21 07:38:52 +00:00
|
|
|
if ( $fld_revid && $row->afl_rev_id !== null ) {
|
2018-07-14 12:26:42 +00:00
|
|
|
$entry['revid'] = $canSeeDetails ? $row->afl_rev_id : '';
|
2012-12-14 11:17:24 +00:00
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
if ( $fld_timestamp ) {
|
2012-09-02 11:07:02 +00:00
|
|
|
$ts = new MWTimestamp( $row->afl_timestamp );
|
|
|
|
$entry['timestamp'] = $ts->getTimestamp( TS_ISO_8601 );
|
2010-08-19 21:12:09 +00:00
|
|
|
}
|
2010-02-13 14:10:36 +00:00
|
|
|
if ( $fld_details ) {
|
2017-06-15 14:23:16 +00:00
|
|
|
$entry['details'] = [];
|
2013-07-17 15:18:13 +00:00
|
|
|
if ( $canSeeDetails ) {
|
2020-09-29 14:52:05 +00:00
|
|
|
$vars = AbuseFilterServices::getVariablesBlobStore()->loadVarDump( $row->afl_var_dump );
|
2020-10-18 22:25:05 +00:00
|
|
|
$varManager = AbuseFilterServices::getVariablesManager();
|
|
|
|
$entry['details'] = $varManager->exportAllVars( $vars );
|
2009-03-28 23:40:27 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2018-10-16 21:04:20 +00:00
|
|
|
if ( $fld_hidden && $hidden ) {
|
|
|
|
$entry['hidden'] = $hidden;
|
2010-06-25 20:04:55 +00:00
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2009-10-07 13:57:06 +00:00
|
|
|
if ( $entry ) {
|
2017-06-15 14:23:16 +00:00
|
|
|
$fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $entry );
|
2010-02-13 14:10:36 +00:00
|
|
|
if ( !$fit ) {
|
2012-09-02 11:07:02 +00:00
|
|
|
$ts = new MWTimestamp( $row->afl_timestamp );
|
|
|
|
$this->setContinueEnumParameter( 'start', $ts->getTimestamp( TS_ISO_8601 ) );
|
2009-03-30 12:19:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-03-28 23:40:27 +00:00
|
|
|
}
|
2017-06-15 14:23:16 +00:00
|
|
|
$result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'item' );
|
2009-03-28 23:40:27 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @return array
|
2020-12-03 22:05:42 +00:00
|
|
|
* @see ApiQueryBase::getAllowedParams()
|
2018-04-04 21:14:25 +00:00
|
|
|
*/
|
2009-03-28 23:40:27 +00:00
|
|
|
public function getAllowedParams() {
|
2018-02-03 15:39:08 +00:00
|
|
|
$params = [
|
2018-07-14 12:26:42 +00:00
|
|
|
'logid' => [
|
|
|
|
ApiBase::PARAM_TYPE => 'integer'
|
|
|
|
],
|
2017-06-15 14:23:16 +00:00
|
|
|
'start' => [
|
2009-10-07 13:57:06 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'timestamp'
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
|
|
|
'end' => [
|
2009-10-07 13:57:06 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'timestamp'
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
|
|
|
'dir' => [
|
|
|
|
ApiBase::PARAM_TYPE => [
|
2009-03-28 23:40:27 +00:00
|
|
|
'newer',
|
|
|
|
'older'
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
2014-10-28 16:25:22 +00:00
|
|
|
ApiBase::PARAM_DFLT => 'older',
|
2016-09-20 18:39:11 +00:00
|
|
|
ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
2009-03-28 23:40:27 +00:00
|
|
|
'user' => null,
|
|
|
|
'title' => null,
|
2017-06-15 14:23:16 +00:00
|
|
|
'filter' => [
|
2018-02-03 15:39:08 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
2019-02-07 14:18:47 +00:00
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
ApiBase::PARAM_HELP_MSG => [
|
|
|
|
'apihelp-query+abuselog-param-filter',
|
2020-12-02 22:47:40 +00:00
|
|
|
GlobalNameUtils::GLOBAL_FILTER_PREFIX
|
2019-02-07 14:18:47 +00:00
|
|
|
]
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
|
|
|
'limit' => [
|
2009-10-07 13:57:06 +00:00
|
|
|
ApiBase::PARAM_DFLT => 10,
|
|
|
|
ApiBase::PARAM_TYPE => 'limit',
|
|
|
|
ApiBase::PARAM_MIN => 1,
|
|
|
|
ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
|
|
|
|
ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
|
|
|
'prop' => [
|
2012-12-14 11:17:24 +00:00
|
|
|
ApiBase::PARAM_DFLT => 'ids|user|title|action|result|timestamp|hidden|revid',
|
2017-06-15 14:23:16 +00:00
|
|
|
ApiBase::PARAM_TYPE => [
|
2009-10-07 13:57:06 +00:00
|
|
|
'ids',
|
|
|
|
'filter',
|
|
|
|
'user',
|
|
|
|
'title',
|
|
|
|
'action',
|
|
|
|
'details',
|
|
|
|
'result',
|
|
|
|
'timestamp',
|
2010-06-25 20:04:55 +00:00
|
|
|
'hidden',
|
2012-12-14 11:17:24 +00:00
|
|
|
'revid',
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
2009-10-07 13:57:06 +00:00
|
|
|
ApiBase::PARAM_ISMULTI => true
|
2017-06-15 14:23:16 +00:00
|
|
|
]
|
|
|
|
];
|
2018-03-10 21:47:33 +00:00
|
|
|
if ( $this->getConfig()->get( 'AbuseFilterIsCentral' ) ) {
|
2018-02-03 15:39:08 +00:00
|
|
|
$params['wiki'] = [
|
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
|
|
|
];
|
|
|
|
$params['prop'][ApiBase::PARAM_DFLT] .= '|wiki';
|
|
|
|
$params['prop'][ApiBase::PARAM_TYPE][] = 'wiki';
|
2019-11-18 03:08:28 +00:00
|
|
|
$params['filter'][ApiBase::PARAM_HELP_MSG] = 'apihelp-query+abuselog-param-filter-central';
|
2018-02-03 15:39:08 +00:00
|
|
|
}
|
|
|
|
return $params;
|
2010-02-13 14:10:36 +00:00
|
|
|
}
|
2009-10-07 13:57:06 +00:00
|
|
|
|
2014-10-28 16:25:22 +00:00
|
|
|
/**
|
2017-10-06 18:52:31 +00:00
|
|
|
* @return array
|
2020-12-03 22:05:42 +00:00
|
|
|
* @see ApiBase::getExamplesMessages()
|
2014-10-28 16:25:22 +00:00
|
|
|
*/
|
|
|
|
protected function getExamplesMessages() {
|
2017-06-15 14:23:16 +00:00
|
|
|
return [
|
2014-10-28 16:25:22 +00:00
|
|
|
'action=query&list=abuselog'
|
|
|
|
=> 'apihelp-query+abuselog-example-1',
|
|
|
|
'action=query&list=abuselog&afltitle=API'
|
|
|
|
=> 'apihelp-query+abuselog-example-2',
|
2017-06-15 14:23:16 +00:00
|
|
|
];
|
2009-03-28 23:40:27 +00:00
|
|
|
}
|
|
|
|
}
|