2007-12-06 16:06:22 +00:00
|
|
|
<?php
|
2010-02-24 14:00:23 +00:00
|
|
|
/**
|
2023-03-16 17:27:37 +00:00
|
|
|
* Copyright © 2007 Roan Kattouw <roan.kattouw@gmail.com>
|
2007-12-06 16:06:22 +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:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-12-06 16:06:22 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2007-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
|
2024-09-25 16:17:29 +00:00
|
|
|
namespace MediaWiki\Api;
|
|
|
|
|
|
2021-05-07 11:45:50 +00:00
|
|
|
use MediaWiki\Block\BlockActionInfo;
|
2021-04-19 14:12:50 +00:00
|
|
|
use MediaWiki\Block\BlockRestrictionStore;
|
Support new block schema
Support migration stages when reading and writing blocks.
I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.
However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.
HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.
When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.
Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-10-27 03:34:10 +00:00
|
|
|
use MediaWiki\Block\DatabaseBlockStore;
|
2023-11-15 06:09:27 +00:00
|
|
|
use MediaWiki\Block\HideUserUtils;
|
2022-08-14 01:10:31 +00:00
|
|
|
use MediaWiki\Block\Restriction\PageRestriction;
|
2022-12-28 21:50:03 +00:00
|
|
|
use MediaWiki\CommentStore\CommentStore;
|
2022-04-13 15:28:26 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2019-08-21 19:53:53 +00:00
|
|
|
use MediaWiki\ParamValidator\TypeDef\UserDef;
|
2019-06-25 18:53:15 +00:00
|
|
|
use Wikimedia\IPUtils;
|
2022-06-05 23:18:50 +00:00
|
|
|
use Wikimedia\ParamValidator\ParamValidator;
|
|
|
|
|
use Wikimedia\ParamValidator\TypeDef\IntegerDef;
|
2020-01-10 00:00:51 +00:00
|
|
|
use Wikimedia\Rdbms\IResultWrapper;
|
2024-07-22 20:39:25 +00:00
|
|
|
use Wikimedia\Rdbms\RawSQLExpression;
|
2018-06-26 23:12:05 +00:00
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
/**
|
2011-06-05 21:04:48 +00:00
|
|
|
* Query module to enumerate all user blocks
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2007-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
class ApiQueryBlocks extends ApiQueryBase {
|
2010-02-24 14:00:23 +00:00
|
|
|
|
Support new block schema
Support migration stages when reading and writing blocks.
I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.
However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.
HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.
When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.
Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-10-27 03:34:10 +00:00
|
|
|
private DatabaseBlockStore $blockStore;
|
2023-08-28 15:32:58 +00:00
|
|
|
private BlockActionInfo $blockActionInfo;
|
|
|
|
|
private BlockRestrictionStore $blockRestrictionStore;
|
|
|
|
|
private CommentStore $commentStore;
|
2023-11-15 06:09:27 +00:00
|
|
|
private HideUserUtils $hideUserUtils;
|
2021-04-23 14:51:18 +00:00
|
|
|
|
2021-04-19 14:12:50 +00:00
|
|
|
public function __construct(
|
|
|
|
|
ApiQuery $query,
|
2024-10-14 20:12:27 +00:00
|
|
|
string $moduleName,
|
Support new block schema
Support migration stages when reading and writing blocks.
I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.
However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.
HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.
When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.
Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-10-27 03:34:10 +00:00
|
|
|
DatabaseBlockStore $blockStore,
|
2021-05-07 11:45:50 +00:00
|
|
|
BlockActionInfo $blockActionInfo,
|
2021-04-23 14:51:18 +00:00
|
|
|
BlockRestrictionStore $blockRestrictionStore,
|
2023-11-15 06:09:27 +00:00
|
|
|
CommentStore $commentStore,
|
|
|
|
|
HideUserUtils $hideUserUtils
|
2021-04-19 14:12:50 +00:00
|
|
|
) {
|
2010-02-24 14:00:23 +00:00
|
|
|
parent::__construct( $query, $moduleName, 'bk' );
|
Support new block schema
Support migration stages when reading and writing blocks.
I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.
However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.
HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.
When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.
Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-10-27 03:34:10 +00:00
|
|
|
$this->blockStore = $blockStore;
|
2021-05-07 11:45:50 +00:00
|
|
|
$this->blockActionInfo = $blockActionInfo;
|
2021-04-19 14:12:50 +00:00
|
|
|
$this->blockRestrictionStore = $blockRestrictionStore;
|
2021-04-23 14:51:18 +00:00
|
|
|
$this->commentStore = $commentStore;
|
2023-11-15 06:09:27 +00:00
|
|
|
$this->hideUserUtils = $hideUserUtils;
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
2013-12-24 20:26:47 +00:00
|
|
|
$db = $this->getDB();
|
2007-12-06 16:06:22 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2011-06-06 16:45:40 +00:00
|
|
|
$this->requireMaxOneParameter( $params, 'users', 'ip' );
|
2008-06-19 13:43:14 +00:00
|
|
|
|
2021-06-11 02:52:06 +00:00
|
|
|
$prop = array_fill_keys( $params['prop'], true );
|
2010-01-11 15:55:52 +00:00
|
|
|
$fld_id = isset( $prop['id'] );
|
|
|
|
|
$fld_user = isset( $prop['user'] );
|
2011-02-21 19:48:15 +00:00
|
|
|
$fld_userid = isset( $prop['userid'] );
|
2010-01-11 15:55:52 +00:00
|
|
|
$fld_by = isset( $prop['by'] );
|
2011-02-21 19:48:15 +00:00
|
|
|
$fld_byid = isset( $prop['byid'] );
|
2010-01-11 15:55:52 +00:00
|
|
|
$fld_timestamp = isset( $prop['timestamp'] );
|
|
|
|
|
$fld_expiry = isset( $prop['expiry'] );
|
|
|
|
|
$fld_reason = isset( $prop['reason'] );
|
|
|
|
|
$fld_range = isset( $prop['range'] );
|
|
|
|
|
$fld_flags = isset( $prop['flags'] );
|
2018-06-26 23:12:05 +00:00
|
|
|
$fld_restrictions = isset( $prop['restrictions'] );
|
2007-12-06 16:06:22 +00:00
|
|
|
|
|
|
|
|
$result = $this->getResult();
|
|
|
|
|
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addTables( [ 'block', 'block_target', 'block_target_user' => 'user' ] );
|
|
|
|
|
$this->addJoinConds( [
|
|
|
|
|
'block_target' => [ 'JOIN', 'bt_id=bl_target' ],
|
|
|
|
|
'block_target_user' => [ 'LEFT JOIN', 'user_id=bt_user' ]
|
|
|
|
|
] );
|
|
|
|
|
$this->addFields( [ 'bt_auto', 'bl_id', 'bl_timestamp' ] );
|
|
|
|
|
$this->addFieldsIf(
|
|
|
|
|
[
|
|
|
|
|
'bt_address',
|
|
|
|
|
'bt_user',
|
|
|
|
|
'bt_address_or_user_name' => 'COALESCE(bt_address, bt_user_text)'
|
|
|
|
|
],
|
|
|
|
|
$fld_user || $fld_userid
|
|
|
|
|
);
|
2010-02-15 12:20:52 +00:00
|
|
|
|
2017-09-12 17:12:29 +00:00
|
|
|
if ( $fld_by || $fld_byid ) {
|
2021-04-19 01:00:56 +00:00
|
|
|
$this->addTables( 'actor' );
|
|
|
|
|
$this->addFields( [ 'actor_user', 'actor_name' ] );
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addJoinConds( [ 'actor' => [ 'JOIN', 'actor_id=bl_by_actor' ] ] );
|
2017-09-12 17:12:29 +00:00
|
|
|
}
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addFieldsIf( 'bl_expiry', $fld_expiry );
|
|
|
|
|
$this->addFieldsIf( [ 'bt_range_start', 'bt_range_end' ], $fld_range );
|
|
|
|
|
$this->addFieldsIf( [ 'bl_anon_only', 'bl_create_account', 'bl_enable_autoblock',
|
|
|
|
|
'bl_block_email', 'bl_deleted', 'bl_allow_usertalk', 'bl_sitewide' ],
|
2013-11-14 12:51:06 +00:00
|
|
|
$fld_flags );
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addFieldsIf( 'bl_sitewide', $fld_restrictions );
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2017-06-06 17:39:14 +00:00
|
|
|
if ( $fld_reason ) {
|
2024-04-09 03:26:02 +00:00
|
|
|
$commentQuery = $this->commentStore->getJoin( 'bl_reason' );
|
2017-06-06 17:39:14 +00:00
|
|
|
$this->addTables( $commentQuery['tables'] );
|
|
|
|
|
$this->addFields( $commentQuery['fields'] );
|
|
|
|
|
$this->addJoinConds( $commentQuery['joins'] );
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addOption( 'LIMIT', $params['limit'] + 1 );
|
2013-11-14 17:38:36 +00:00
|
|
|
$this->addTimestampWhereRange(
|
2024-04-09 03:26:02 +00:00
|
|
|
'bl_timestamp',
|
2013-11-14 17:38:36 +00:00
|
|
|
$params['dir'],
|
|
|
|
|
$params['start'],
|
|
|
|
|
$params['end']
|
|
|
|
|
);
|
2013-12-24 20:26:47 +00:00
|
|
|
// Include in ORDER BY for uniqueness
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addWhereRange( 'bl_id', $params['dir'], null, null );
|
2012-02-18 01:07:42 +00:00
|
|
|
|
2020-01-09 23:48:34 +00:00
|
|
|
if ( $params['continue'] !== null ) {
|
2022-10-31 22:26:14 +00:00
|
|
|
$cont = $this->parseContinueParamOrDie( $params['continue'], [ 'timestamp', 'int' ] );
|
2022-09-03 22:48:19 +00:00
|
|
|
$op = ( $params['dir'] == 'newer' ? '>=' : '<=' );
|
|
|
|
|
$this->addWhere( $db->buildComparison( $op, [
|
2024-04-09 03:26:02 +00:00
|
|
|
'bl_timestamp' => $db->timestamp( $cont[0] ),
|
|
|
|
|
'bl_id' => $cont[1],
|
2022-09-03 22:48:19 +00:00
|
|
|
] ) );
|
2013-12-24 20:26:47 +00:00
|
|
|
}
|
2012-02-18 01:07:42 +00:00
|
|
|
|
2022-02-19 11:04:19 +00:00
|
|
|
if ( $params['ids'] ) {
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addWhereIDsFld( 'block', 'bl_id', $params['ids'] );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2022-02-19 11:04:19 +00:00
|
|
|
if ( $params['users'] ) {
|
2024-04-09 03:26:02 +00:00
|
|
|
$addresses = [];
|
|
|
|
|
$userNames = [];
|
|
|
|
|
foreach ( $params['users'] as $target ) {
|
|
|
|
|
if ( IPUtils::isValid( $target ) || IPUtils::isValidRange( $target ) ) {
|
|
|
|
|
$addresses[] = $target;
|
|
|
|
|
} else {
|
|
|
|
|
$userNames[] = $target;
|
Support new block schema
Support migration stages when reading and writing blocks.
I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.
However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.
HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.
When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.
Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-10-27 03:34:10 +00:00
|
|
|
}
|
2024-04-09 03:26:02 +00:00
|
|
|
}
|
|
|
|
|
if ( $addresses && $userNames ) {
|
|
|
|
|
// Use a union, not "OR" (T360088)
|
|
|
|
|
$ids = $db->newUnionQueryBuilder()
|
|
|
|
|
->add( $db->newSelectQueryBuilder()
|
|
|
|
|
->select( 'bt_id' )
|
|
|
|
|
->from( 'block_target' )
|
|
|
|
|
->where( [ 'bt_address' => $addresses ] )
|
|
|
|
|
)
|
|
|
|
|
->add( $db->newSelectQueryBuilder()
|
|
|
|
|
->select( 'bt_id' )
|
|
|
|
|
->from( 'block_target' )
|
|
|
|
|
->join( 'user', null, 'user_id=bt_user' )
|
|
|
|
|
->where( [ 'user_name' => $userNames ] )
|
|
|
|
|
)
|
|
|
|
|
->caller( __METHOD__ )
|
|
|
|
|
->fetchFieldValues();
|
|
|
|
|
if ( $ids ) {
|
|
|
|
|
$this->addWhere( [ 'bt_id' => $ids ] );
|
2024-03-15 00:05:13 +00:00
|
|
|
} else {
|
|
|
|
|
$this->addWhere( '1=0' );
|
Support new block schema
Support migration stages when reading and writing blocks.
I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.
However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.
HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.
When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.
Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-10-27 03:34:10 +00:00
|
|
|
}
|
2024-04-09 03:26:02 +00:00
|
|
|
} elseif ( $addresses ) {
|
|
|
|
|
$this->addWhere( [ 'bt_address' => $addresses ] );
|
|
|
|
|
} elseif ( $userNames ) {
|
|
|
|
|
$this->addWhere( [ 'block_target_user.user_name' => $userNames ] );
|
|
|
|
|
} else {
|
|
|
|
|
// Unreachable since $params['users'] is non-empty
|
|
|
|
|
$this->addWhere( '1=0' );
|
Support new block schema
Support migration stages when reading and writing blocks.
I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.
However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.
HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.
When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.
Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-10-27 03:34:10 +00:00
|
|
|
}
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addWhereFld( 'bt_auto', 0 );
|
2008-04-26 14:09:16 +00:00
|
|
|
}
|
2022-02-19 11:04:19 +00:00
|
|
|
if ( $params['ip'] !== null ) {
|
2022-04-13 15:28:26 +00:00
|
|
|
$blockCIDRLimit = $this->getConfig()->get( MainConfigNames::BlockCIDRLimit );
|
2019-06-25 18:53:15 +00:00
|
|
|
if ( IPUtils::isIPv4( $params['ip'] ) ) {
|
2013-05-06 14:27:46 +00:00
|
|
|
$type = 'IPv4';
|
2014-01-24 02:51:11 +00:00
|
|
|
$cidrLimit = $blockCIDRLimit['IPv4'];
|
2019-06-25 18:53:15 +00:00
|
|
|
} elseif ( IPUtils::isIPv6( $params['ip'] ) ) {
|
2013-05-06 14:27:46 +00:00
|
|
|
$type = 'IPv6';
|
2014-01-24 02:51:11 +00:00
|
|
|
$cidrLimit = $blockCIDRLimit['IPv6'];
|
2010-02-24 14:00:23 +00:00
|
|
|
} else {
|
2016-10-19 16:54:25 +00:00
|
|
|
$this->dieWithError( 'apierror-badip', 'param_ip' );
|
2013-05-06 14:27:46 +00:00
|
|
|
}
|
|
|
|
|
|
2023-09-01 00:15:03 +00:00
|
|
|
// Check range validity, if it's a CIDR
|
2019-06-25 18:53:15 +00:00
|
|
|
[ $ip, $range ] = IPUtils::parseCIDR( $params['ip'] );
|
2013-05-06 14:27:46 +00:00
|
|
|
if ( $ip !== false && $range !== false && $range < $cidrLimit ) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$this->dieWithError( [ 'apierror-cidrtoobroad', $type, $cidrLimit ] );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2013-05-06 14:27:46 +00:00
|
|
|
|
2023-09-01 00:15:03 +00:00
|
|
|
// Let IPUtils::parseRange handle calculating $upper, instead of duplicating the logic here.
|
2019-06-25 18:53:15 +00:00
|
|
|
[ $lower, $upper ] = IPUtils::parseRange( $params['ip'] );
|
2013-05-06 14:27:46 +00:00
|
|
|
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addWhere( $this->blockStore->getRangeCond( $lower, $upper ) );
|
|
|
|
|
$this->addWhere( [ 'bt_auto' => 0 ] );
|
2008-06-19 13:43:14 +00:00
|
|
|
}
|
2010-07-23 07:33:40 +00:00
|
|
|
|
2020-01-09 23:48:34 +00:00
|
|
|
if ( $params['show'] !== null ) {
|
2021-06-11 02:52:06 +00:00
|
|
|
$show = array_fill_keys( $params['show'], true );
|
2011-08-13 15:39:57 +00:00
|
|
|
|
2023-09-01 00:15:03 +00:00
|
|
|
// Check for conflicting parameters.
|
2013-04-26 12:18:06 +00:00
|
|
|
if ( ( isset( $show['account'] ) && isset( $show['!account'] ) )
|
2013-11-14 12:51:06 +00:00
|
|
|
|| ( isset( $show['ip'] ) && isset( $show['!ip'] ) )
|
|
|
|
|
|| ( isset( $show['range'] ) && isset( $show['!range'] ) )
|
|
|
|
|
|| ( isset( $show['temp'] ) && isset( $show['!temp'] ) )
|
2011-08-13 15:39:57 +00:00
|
|
|
) {
|
2016-10-19 16:54:25 +00:00
|
|
|
$this->dieWithError( 'apierror-show' );
|
2011-08-13 15:39:57 +00:00
|
|
|
}
|
|
|
|
|
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addWhereIf( [ 'bt_user' => 0 ], isset( $show['!account'] ) );
|
2024-07-22 20:39:25 +00:00
|
|
|
$this->addWhereIf( $db->expr( 'bt_user', '!=', 0 ), isset( $show['account'] ) );
|
|
|
|
|
$this->addWhereIf(
|
|
|
|
|
$db->expr( 'bt_user', '!=', 0 )->orExpr( new RawSQLExpression( 'bt_range_end > bt_range_start' ) ),
|
|
|
|
|
isset( $show['!ip'] )
|
|
|
|
|
);
|
|
|
|
|
$this->addWhereIf( [ 'bt_user' => 0, 'bt_range_end = bt_range_start' ], isset( $show['ip'] ) );
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addWhereIf( [ 'bl_expiry' => $db->getInfinity() ], isset( $show['!temp'] ) );
|
|
|
|
|
$this->addWhereIf( $db->expr( 'bl_expiry', '!=', $db->getInfinity() ), isset( $show['temp'] ) );
|
|
|
|
|
$this->addWhereIf( 'bt_range_end = bt_range_start', isset( $show['!range'] ) );
|
|
|
|
|
$this->addWhereIf( 'bt_range_end > bt_range_start', isset( $show['range'] ) );
|
2011-08-13 15:39:57 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-11 15:26:02 +00:00
|
|
|
if ( !$this->getAuthority()->isAllowed( 'hideuser' ) ) {
|
2025-06-25 19:26:39 +00:00
|
|
|
$this->addWhere( [ 'bl_deleted' => 0 ] );
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addWhere(
|
2024-12-10 14:17:24 +00:00
|
|
|
$this->hideUserUtils->getExpression( $db, 'block_target.bt_user' )
|
2024-04-09 03:26:02 +00:00
|
|
|
);
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2023-09-01 00:15:03 +00:00
|
|
|
// Filter out expired rows
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->addWhere( $db->expr( 'bl_expiry', '>', $db->timestamp() ) );
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$res = $this->select( __METHOD__ );
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2018-06-26 23:12:05 +00:00
|
|
|
$restrictions = [];
|
|
|
|
|
if ( $fld_restrictions ) {
|
2021-04-19 14:12:50 +00:00
|
|
|
$restrictions = $this->getRestrictionData( $res, $params['limit'] );
|
2018-06-26 23:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-06 16:06:22 +00:00
|
|
|
$count = 0;
|
2010-09-28 01:21:15 +00:00
|
|
|
foreach ( $res as $row ) {
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( ++$count > $params['limit'] ) {
|
2007-12-06 16:06:22 +00:00
|
|
|
// We've had enough
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue', "{$row->bl_timestamp}|{$row->bl_id}" );
|
2007-12-06 16:06:22 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2016-02-17 09:09:32 +00:00
|
|
|
$block = [
|
2015-01-16 19:00:07 +00:00
|
|
|
ApiResult::META_TYPE => 'assoc',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $fld_id ) {
|
2024-04-09 03:26:02 +00:00
|
|
|
$block['id'] = (int)$row->bl_id;
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2024-04-09 03:26:02 +00:00
|
|
|
if ( $fld_user && !$row->bt_auto ) {
|
|
|
|
|
$block['user'] = $row->bt_address_or_user_name;
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2024-04-09 03:26:02 +00:00
|
|
|
if ( $fld_userid && !$row->bt_auto ) {
|
|
|
|
|
$block['userid'] = (int)$row->bt_user;
|
2011-02-21 19:48:15 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $fld_by ) {
|
2021-04-19 01:00:56 +00:00
|
|
|
$block['by'] = $row->actor_name;
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2011-02-21 19:48:15 +00:00
|
|
|
if ( $fld_byid ) {
|
2021-04-19 01:00:56 +00:00
|
|
|
$block['byid'] = (int)$row->actor_user;
|
2011-02-21 19:48:15 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $fld_timestamp ) {
|
2024-04-09 03:26:02 +00:00
|
|
|
$block['timestamp'] = wfTimestamp( TS_ISO_8601, $row->bl_timestamp );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
|
|
|
|
if ( $fld_expiry ) {
|
2024-04-09 03:26:02 +00:00
|
|
|
$block['expiry'] = ApiResult::formatExpiry( $row->bl_expiry );
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
|
|
|
|
if ( $fld_reason ) {
|
2024-04-09 03:26:02 +00:00
|
|
|
$block['reason'] = $this->commentStore->getComment( 'bl_reason', $row )->text;
|
2010-02-24 14:00:23 +00:00
|
|
|
}
|
2024-04-09 03:26:02 +00:00
|
|
|
if ( $fld_range && !$row->bt_auto && $row->bt_range_start !== null ) {
|
|
|
|
|
$block['rangestart'] = IPUtils::formatHex( $row->bt_range_start );
|
|
|
|
|
$block['rangeend'] = IPUtils::formatHex( $row->bt_range_end );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( $fld_flags ) {
|
2007-12-06 16:06:22 +00:00
|
|
|
// For clarity, these flags use the same names as their action=block counterparts
|
2024-04-09 03:26:02 +00:00
|
|
|
$block['automatic'] = (bool)$row->bt_auto;
|
|
|
|
|
$block['anononly'] = (bool)$row->bl_anon_only;
|
|
|
|
|
$block['nocreate'] = (bool)$row->bl_create_account;
|
|
|
|
|
$block['autoblock'] = (bool)$row->bl_enable_autoblock;
|
|
|
|
|
$block['noemail'] = (bool)$row->bl_block_email;
|
|
|
|
|
$block['hidden'] = (bool)$row->bl_deleted;
|
|
|
|
|
$block['allowusertalk'] = (bool)$row->bl_allow_usertalk;
|
|
|
|
|
$block['partial'] = !(bool)$row->bl_sitewide;
|
2018-06-26 23:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $fld_restrictions ) {
|
|
|
|
|
$block['restrictions'] = [];
|
2024-04-09 03:26:02 +00:00
|
|
|
if ( !$row->bl_sitewide && isset( $restrictions[$row->bl_id] ) ) {
|
|
|
|
|
$block['restrictions'] = $restrictions[$row->bl_id];
|
2018-06-26 23:12:05 +00:00
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2018-06-26 23:12:05 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $block );
|
2010-02-24 14:00:23 +00:00
|
|
|
if ( !$fit ) {
|
2024-04-09 03:26:02 +00:00
|
|
|
$this->setContinueEnumParameter( 'continue', "{$row->bl_timestamp}|{$row->bl_id}" );
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2016-02-17 09:09:32 +00:00
|
|
|
$result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'block' );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2010-02-24 14:00:23 +00:00
|
|
|
|
2018-06-26 23:12:05 +00:00
|
|
|
/**
|
|
|
|
|
* Retrieves the restrictions based on the query result.
|
|
|
|
|
*
|
|
|
|
|
* @param IResultWrapper $result
|
|
|
|
|
* @param int $limit
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2021-04-19 14:12:50 +00:00
|
|
|
private function getRestrictionData( IResultWrapper $result, $limit ) {
|
2018-06-26 23:12:05 +00:00
|
|
|
$partialIds = [];
|
|
|
|
|
$count = 0;
|
|
|
|
|
foreach ( $result as $row ) {
|
Support new block schema
Support migration stages when reading and writing blocks.
I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.
However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.
HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.
When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.
Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-10-27 03:34:10 +00:00
|
|
|
if ( ++$count <= $limit && !( $row->ipb_sitewide ?? $row->bl_sitewide ) ) {
|
|
|
|
|
$partialIds[] = (int)( $row->ipb_id ?? $row->bl_id );
|
2018-06-26 23:12:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-19 14:12:50 +00:00
|
|
|
$restrictions = $this->blockRestrictionStore->loadByBlockId( $partialIds );
|
2018-06-26 23:12:05 +00:00
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
|
$keys = [
|
|
|
|
|
'page' => 'pages',
|
|
|
|
|
'ns' => 'namespaces',
|
|
|
|
|
];
|
2022-04-13 15:28:26 +00:00
|
|
|
if ( $this->getConfig()->get( MainConfigNames::EnablePartialActionBlocks ) ) {
|
Introduce infrastructure for partial blocks for actions
This adds a new type of block restriction for actions, which extends
AbstractRestriction. Like page and namespace restrictions, action
restrictions are stored in the ipblocks_restrictions table.
Blockable actions are defined in a BlockActionInfo service, with a
method for getting all the blockable actions, getAllBlockActions.
Action blocks are checked for in PermissionManager::checkUserBlock
using DatabaseBlock::appliesToRight. To make this work, this patch
also removes the 'edit' case from AbstractBlock::appliesToRight,
which always returned true. This was incorrect, as blocks do not
always apply to edit, so cases that called appliesToRight('edit')
were fixed before this commit. appliesToRight('edit') now returns
null (i.e. unsure), which is correct because it is not possible to
determine whether a block applies to editing a particular page
without knowing what that page is, and appliesToRight doesn't know
that page.
There are some flags on sitewide blocks that predate partial blocks,
which block particular actions: 'createaccount' and 'sendemail'.
These are still handled in AbstractBlock::appliesToRight, and are
still checked for separately in the peripheral components.
The feature flag $wgEnablePartialActionBlocks must set to true to
enable partial action blocks.
Bug: T279556
Bug: T6995
Change-Id: I17962bb7c4247a12c722e7bc6bcaf8c36efd8600
2021-04-26 23:07:17 +00:00
|
|
|
$keys['action'] = 'actions';
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-26 23:12:05 +00:00
|
|
|
foreach ( $restrictions as $restriction ) {
|
|
|
|
|
$key = $keys[$restriction->getType()];
|
|
|
|
|
$id = $restriction->getBlockId();
|
|
|
|
|
switch ( $restriction->getType() ) {
|
|
|
|
|
case 'page':
|
2022-08-14 01:10:31 +00:00
|
|
|
/** @var PageRestriction $restriction */
|
2019-08-31 16:14:38 +00:00
|
|
|
'@phan-var \MediaWiki\Block\Restriction\PageRestriction $restriction';
|
2018-06-26 23:12:05 +00:00
|
|
|
$value = [ 'id' => $restriction->getValue() ];
|
2019-01-30 23:45:36 +00:00
|
|
|
if ( $restriction->getTitle() ) {
|
|
|
|
|
self::addTitleInfo( $value, $restriction->getTitle() );
|
|
|
|
|
}
|
2018-06-26 23:12:05 +00:00
|
|
|
break;
|
2021-05-07 11:45:50 +00:00
|
|
|
case 'action':
|
|
|
|
|
$value = $this->blockActionInfo->getActionFromId( $restriction->getValue() );
|
|
|
|
|
break;
|
2018-06-26 23:12:05 +00:00
|
|
|
default:
|
|
|
|
|
$value = $restriction->getValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !isset( $data[$id][$key] ) ) {
|
|
|
|
|
$data[$id][$key] = [];
|
|
|
|
|
ApiResult::setIndexedTagName( $data[$id][$key], $restriction->getType() );
|
|
|
|
|
}
|
|
|
|
|
$data[$id][$key][] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2022-04-13 15:28:26 +00:00
|
|
|
$blockCIDRLimit = $this->getConfig()->get( MainConfigNames::BlockCIDRLimit );
|
2014-09-18 17:38:23 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
'start' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'timestamp'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'end' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'timestamp',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'dir' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_TYPE => [
|
2007-12-06 16:06:22 +00:00
|
|
|
'newer',
|
|
|
|
|
'older'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_DEFAULT => 'older',
|
2014-09-18 17:38:23 +00:00
|
|
|
ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
|
2023-08-05 13:05:24 +00:00
|
|
|
ApiBase::PARAM_HELP_MSG_PER_VALUE => [
|
|
|
|
|
'newer' => 'api-help-paramvalue-direction-newer',
|
|
|
|
|
'older' => 'api-help-paramvalue-direction-older',
|
|
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'ids' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'integer',
|
|
|
|
|
ParamValidator::PARAM_ISMULTI => true
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'users' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_TYPE => 'user',
|
Add 'temp' to allowed user types in various APIs
Why:
* Before this task, when an API parameter specifies allowed user
types, temporary users and permanent users are in the same
category: 'name'.
* However, it is useful to separate them out, and sometimes
allow a permanent user but not a temporary user (e.g.
ApiResetPassword, since temporary users don't have passwords).
* We therefore re-defined the 'name' type only to refer to
permanent (named) users, and add a new 'temp' type.
* This fixes params that currently intend to allow temp users,
and that use 'name' to do so, by adding 'temp'.
What:
* Based on a search for `UserDef::PARAM_ALLOWED_USER_TYPES`,
add the 'temp' type where necessary.
* The following were not updated, because they shouldn't apply
to temporary users:
- owners for includes/api/ApiQueryWatchlist.php,
includes/api/ApiQueryWatchlistRaw.php
- users for includes/api/ApiResetPassword.php,
includes/api/ApiUserrights.php,
includes/api/ApiValidatePassword.php
Bug: T350701
Change-Id: If5ccf1d469327791acff74d013343307e411cca9
2023-11-29 12:21:16 +00:00
|
|
|
UserDef::PARAM_ALLOWED_USER_TYPES => [ 'name', 'ip', 'temp', 'cidr' ],
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_ISMULTI => true
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'ip' => [
|
|
|
|
|
ApiBase::PARAM_HELP_MSG => [
|
2014-09-18 17:38:23 +00:00
|
|
|
'apihelp-query+blocks-param-ip',
|
|
|
|
|
$blockCIDRLimit['IPv4'],
|
|
|
|
|
$blockCIDRLimit['IPv6'],
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
'limit' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_DEFAULT => 10,
|
|
|
|
|
ParamValidator::PARAM_TYPE => 'limit',
|
|
|
|
|
IntegerDef::PARAM_MIN => 1,
|
|
|
|
|
IntegerDef::PARAM_MAX => ApiBase::LIMIT_BIG1,
|
|
|
|
|
IntegerDef::PARAM_MAX2 => ApiBase::LIMIT_BIG2
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'prop' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_DEFAULT => 'id|user|by|timestamp|expiry|reason|flags',
|
|
|
|
|
ParamValidator::PARAM_TYPE => [
|
2010-02-24 14:00:23 +00:00
|
|
|
'id',
|
|
|
|
|
'user',
|
2011-02-21 19:48:15 +00:00
|
|
|
'userid',
|
2010-02-24 14:00:23 +00:00
|
|
|
'by',
|
2011-02-21 19:48:15 +00:00
|
|
|
'byid',
|
2010-02-24 14:00:23 +00:00
|
|
|
'timestamp',
|
|
|
|
|
'expiry',
|
|
|
|
|
'reason',
|
|
|
|
|
'range',
|
2018-06-26 23:12:05 +00:00
|
|
|
'flags',
|
|
|
|
|
'restrictions',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_ISMULTI => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
|
|
|
|
|
],
|
|
|
|
|
'show' => [
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_TYPE => [
|
2011-08-13 15:39:57 +00:00
|
|
|
'account',
|
|
|
|
|
'!account',
|
|
|
|
|
'temp',
|
|
|
|
|
'!temp',
|
|
|
|
|
'ip',
|
|
|
|
|
'!ip',
|
|
|
|
|
'range',
|
|
|
|
|
'!range',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2022-06-05 23:18:50 +00:00
|
|
|
ParamValidator::PARAM_ISMULTI => true
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'continue' => [
|
2014-09-18 17:38:23 +00:00
|
|
|
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
];
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2014-10-28 17:17:02 +00:00
|
|
|
protected function getExamplesMessages() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2014-09-18 17:38:23 +00:00
|
|
|
'action=query&list=blocks'
|
|
|
|
|
=> 'apihelp-query+blocks-example-simple',
|
|
|
|
|
'action=query&list=blocks&bkusers=Alice|Bob'
|
|
|
|
|
=> 'apihelp-query+blocks-example-users',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-17 17:02:06 +00:00
|
|
|
public function getHelpUrls() {
|
2017-04-04 22:52:57 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Blocks';
|
2011-07-17 17:02:06 +00:00
|
|
|
}
|
2010-07-23 07:17:56 +00:00
|
|
|
}
|
2024-09-25 16:17:29 +00:00
|
|
|
|
|
|
|
|
/** @deprecated class alias since 1.43 */
|
|
|
|
|
class_alias( ApiQueryBlocks::class, 'ApiQueryBlocks' );
|