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
|
|
|
* 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-03-25 03:48:03 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\AbuseFilterPermissionManager;
|
2020-10-17 08:27:02 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\CentralDBNotAvailableException;
|
2021-01-21 13:05:08 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Filter\FilterNotFoundException;
|
2021-04-04 18:57:49 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\FilterLookup;
|
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;
|
2021-04-04 18:57:49 +00:00
|
|
|
use MediaWiki\Extension\AbuseFilter\Variables\VariablesBlobStore;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Variables\VariablesManager;
|
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;
|
2022-04-03 23:23:52 +00:00
|
|
|
use Wikimedia\ParamValidator\ParamValidator;
|
2022-04-03 20:13:20 +00:00
|
|
|
use Wikimedia\ParamValidator\TypeDef\IntegerDef;
|
2020-01-08 13:33:10 +00:00
|
|
|
|
2009-03-28 23:40:27 +00:00
|
|
|
/**
|
|
|
|
* Query module to list abuse log entries.
|
|
|
|
*
|
2022-09-29 16:54:36 +00:00
|
|
|
* @copyright 2009 Alex Z. <mrzmanwiki AT gmail DOT com>
|
|
|
|
* Based mostly on code by Bryan Tong Minh and Roan Kattouw
|
|
|
|
*
|
2009-03-28 23:40:27 +00:00
|
|
|
* @ingroup API
|
|
|
|
* @ingroup Extensions
|
|
|
|
*/
|
2020-12-03 22:05:42 +00:00
|
|
|
class QueryAbuseLog extends ApiQueryBase {
|
2021-03-25 03:48:03 +00:00
|
|
|
|
2021-04-04 18:57:49 +00:00
|
|
|
/** @var FilterLookup */
|
|
|
|
private $afFilterLookup;
|
|
|
|
|
2021-03-25 03:48:03 +00:00
|
|
|
/** @var AbuseFilterPermissionManager */
|
|
|
|
private $afPermManager;
|
|
|
|
|
2021-04-04 18:57:49 +00:00
|
|
|
/** @var VariablesBlobStore */
|
|
|
|
private $afVariablesBlobStore;
|
|
|
|
|
|
|
|
/** @var VariablesManager */
|
|
|
|
private $afVariablesManager;
|
|
|
|
|
2018-04-04 21:14:25 +00:00
|
|
|
/**
|
|
|
|
* @param ApiQuery $query
|
|
|
|
* @param string $moduleName
|
2021-04-04 18:57:49 +00:00
|
|
|
* @param FilterLookup $afFilterLookup
|
2021-03-25 03:48:03 +00:00
|
|
|
* @param AbuseFilterPermissionManager $afPermManager
|
2021-04-04 18:57:49 +00:00
|
|
|
* @param VariablesBlobStore $afVariablesBlobStore
|
|
|
|
* @param VariablesManager $afVariablesManager
|
2018-04-04 21:14:25 +00:00
|
|
|
*/
|
2021-03-25 03:48:03 +00:00
|
|
|
public function __construct(
|
|
|
|
ApiQuery $query,
|
|
|
|
$moduleName,
|
2021-04-04 18:57:49 +00:00
|
|
|
FilterLookup $afFilterLookup,
|
|
|
|
AbuseFilterPermissionManager $afPermManager,
|
|
|
|
VariablesBlobStore $afVariablesBlobStore,
|
|
|
|
VariablesManager $afVariablesManager
|
2021-03-25 03:48:03 +00:00
|
|
|
) {
|
2009-10-07 13:57:06 +00:00
|
|
|
parent::__construct( $query, $moduleName, 'afl' );
|
2021-04-04 18:57:49 +00:00
|
|
|
$this->afFilterLookup = $afFilterLookup;
|
2021-03-25 03:48:03 +00:00
|
|
|
$this->afPermManager = $afPermManager;
|
2021-04-04 18:57:49 +00:00
|
|
|
$this->afVariablesBlobStore = $afVariablesBlobStore;
|
|
|
|
$this->afVariablesManager = $afVariablesManager;
|
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() {
|
2021-04-04 18:57:49 +00:00
|
|
|
$lookup = $this->afFilterLookup;
|
2018-09-11 16:57:49 +00:00
|
|
|
|
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
|
|
|
|
2022-07-02 13:35:00 +00:00
|
|
|
$performer = $this->getAuthority();
|
2009-03-28 23:40:27 +00:00
|
|
|
$params = $this->extractRequestParams();
|
|
|
|
|
2021-07-10 07:57:12 +00:00
|
|
|
$prop = array_fill_keys( $params['prop'], true );
|
2009-10-07 13:57:06 +00:00
|
|
|
$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
|
|
|
}
|
2022-07-02 13:35:00 +00:00
|
|
|
if ( !$this->afPermManager->canViewPrivateFiltersLogs( $performer ) ) {
|
2018-09-11 16:57:49 +00:00
|
|
|
foreach ( $searchFilters as [ $filterID, $global ] ) {
|
|
|
|
try {
|
|
|
|
$isHidden = $lookup->getFilter( $filterID, $global )->isHidden();
|
|
|
|
} catch ( CentralDBNotAvailableException $_ ) {
|
2021-01-21 13:05:08 +00:00
|
|
|
// Conservatively assume it's hidden, like in SpecialAbuseLog
|
|
|
|
$isHidden = true;
|
|
|
|
} catch ( FilterNotFoundException $_ ) {
|
2018-09-11 16:57:49 +00:00
|
|
|
$isHidden = false;
|
2021-01-21 13:05:08 +00:00
|
|
|
$foundInvalid = true;
|
2018-09-11 16:57:49 +00:00
|
|
|
}
|
|
|
|
if ( $isHidden ) {
|
|
|
|
$this->dieWithError(
|
|
|
|
[ 'apierror-permissiondenied', $this->msg( 'action-abusefilter-log-private' ) ]
|
|
|
|
);
|
|
|
|
}
|
2012-12-07 00:01:22 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-21 13:05:08 +00:00
|
|
|
|
|
|
|
if ( $foundInvalid ) {
|
|
|
|
// @todo Tell what the invalid IDs are
|
|
|
|
$this->addWarning( 'abusefilter-log-invalid-filter' );
|
|
|
|
}
|
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' );
|
2019-02-06 16:07:01 +00:00
|
|
|
$this->addFields( 'afl_filter_id' );
|
|
|
|
$this->addFields( 'afl_global' );
|
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
|
|
|
|
2019-02-06 16:07:01 +00:00
|
|
|
$this->addJoinConds( [
|
|
|
|
'abuse_filter' => [
|
|
|
|
'LEFT JOIN',
|
|
|
|
[
|
|
|
|
'af_id=afl_filter_id',
|
|
|
|
'afl_global' => 0
|
|
|
|
]
|
|
|
|
]
|
|
|
|
] );
|
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
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-02 13:35:00 +00:00
|
|
|
$this->addWhereIf( [ 'afl_deleted' => 0 ], !$this->afPermManager->canSeeHiddenLogEntries( $performer ) );
|
2018-09-11 16:57:49 +00:00
|
|
|
|
|
|
|
if ( $searchFilters ) {
|
|
|
|
// @todo Avoid code duplication with SpecialAbuseLog::showList
|
2019-02-06 16:07:01 +00:00
|
|
|
$filterConds = [ 'local' => [], 'global' => [] ];
|
|
|
|
foreach ( $searchFilters as $filter ) {
|
|
|
|
$isGlobal = $filter[1];
|
|
|
|
$key = $isGlobal ? 'global' : 'local';
|
|
|
|
$filterConds[$key][] = $filter[0];
|
|
|
|
}
|
|
|
|
$conds = [];
|
|
|
|
if ( $filterConds['local'] ) {
|
|
|
|
$conds[] = $this->getDB()->makeList(
|
|
|
|
[ 'afl_global' => 0, 'afl_filter_id' => $filterConds['local'] ],
|
|
|
|
LIST_AND
|
|
|
|
);
|
2018-09-11 16:57:49 +00:00
|
|
|
}
|
2019-02-06 16:07:01 +00:00
|
|
|
if ( $filterConds['global'] ) {
|
|
|
|
$conds[] = $this->getDB()->makeList(
|
|
|
|
[ 'afl_global' => 1, 'afl_filter_id' => $filterConds['global'] ],
|
|
|
|
LIST_AND
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$conds = $this->getDB()->makeList( $conds, LIST_OR );
|
|
|
|
|
2018-09-11 16:57:49 +00:00
|
|
|
$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;
|
|
|
|
}
|
2022-07-02 13:35:00 +00:00
|
|
|
$visibility = SpecialAbuseLog::getEntryVisibilityForUser( $row, $performer, $this->afPermManager );
|
2021-09-15 18:23:36 +00:00
|
|
|
if ( $visibility !== SpecialAbuseLog::VISIBILITY_VISIBLE ) {
|
2012-02-10 23:41:05 +00:00
|
|
|
continue;
|
2020-01-08 16:46:24 +00:00
|
|
|
}
|
2018-09-11 16:57:49 +00:00
|
|
|
|
2019-02-06 16:07:01 +00:00
|
|
|
$filterID = $row->afl_filter_id;
|
|
|
|
$global = $row->afl_global;
|
|
|
|
$fullName = GlobalNameUtils::buildGlobalName( $filterID, $global );
|
2020-11-18 19:24:02 +00:00
|
|
|
$isHidden = $lookup->getFilter( $filterID, $global )->isHidden();
|
2022-07-02 13:35:00 +00:00
|
|
|
$canSeeDetails = $this->afPermManager->canSeeLogDetailsForFilter( $performer, $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 ) {
|
2021-10-09 08:49:35 +00:00
|
|
|
$entry['revid'] = $canSeeDetails ? (int)$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 ) {
|
2021-04-04 18:57:49 +00:00
|
|
|
$vars = $this->afVariablesBlobStore->loadVarDump( $row->afl_var_dump );
|
|
|
|
$varManager = $this->afVariablesManager;
|
2020-10-18 22:25:05 +00:00
|
|
|
$entry['details'] = $varManager->exportAllVars( $vars );
|
2009-03-28 23:40:27 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-19 21:12:09 +00:00
|
|
|
|
2021-09-15 20:54:55 +00:00
|
|
|
if ( $fld_hidden ) {
|
|
|
|
$entry['hidden'] = (bool)$row->afl_deleted;
|
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
|
|
|
/**
|
2021-01-17 11:54:43 +00:00
|
|
|
* @codeCoverageIgnore Merely declarative
|
|
|
|
* @inheritDoc
|
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' => [
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'integer'
|
2018-07-14 12:26:42 +00:00
|
|
|
],
|
2017-06-15 14:23:16 +00:00
|
|
|
'start' => [
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'timestamp'
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
|
|
|
'end' => [
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'timestamp'
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
|
|
|
'dir' => [
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::PARAM_TYPE => [
|
2009-03-28 23:40:27 +00:00
|
|
|
'newer',
|
|
|
|
'older'
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::PARAM_DEFAULT => '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' => [
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'string',
|
|
|
|
ParamValidator::PARAM_ISMULTI => true,
|
2019-02-07 14:18:47 +00:00
|
|
|
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' => [
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::PARAM_DEFAULT => 10,
|
|
|
|
ParamValidator::PARAM_TYPE => 'limit',
|
2022-04-03 20:13:20 +00:00
|
|
|
IntegerDef::PARAM_MIN => 1,
|
|
|
|
IntegerDef::PARAM_MAX => ApiBase::LIMIT_BIG1,
|
|
|
|
IntegerDef::PARAM_MAX2 => ApiBase::LIMIT_BIG2
|
2017-06-15 14:23:16 +00:00
|
|
|
],
|
|
|
|
'prop' => [
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::PARAM_DEFAULT => 'ids|user|title|action|result|timestamp|hidden|revid',
|
|
|
|
ParamValidator::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
|
|
|
],
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::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'] = [
|
2022-04-03 23:23:52 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'string',
|
2018-02-03 15:39:08 +00:00
|
|
|
];
|
2022-04-03 23:23:52 +00:00
|
|
|
$params['prop'][ParamValidator::PARAM_DEFAULT] .= '|wiki';
|
|
|
|
$params['prop'][ParamValidator::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
|
|
|
/**
|
2021-01-17 11:54:43 +00:00
|
|
|
* @codeCoverageIgnore Merely declarative
|
|
|
|
* @inheritDoc
|
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
|
|
|
}
|
|
|
|
}
|