手册:$wgRateLimits

This page is a translated version of the page Manual:$wgRateLimits and the translation is 56% complete.
Other languages:
English • ‎español • ‎français • ‎magyar • ‎polski • ‎русский • ‎中文 • ‎日本語
速率控制: $wgRateLimits
简单的速率限制器选项可以用于制动大量编辑。
引进版本:1.4.5
移除版本:仍在使用
允许的值:未指定
默认值:参见下方

详情

此设置提供了一个简单的速率限制器,可以制止编辑泛滥和其他可能具有破坏性的行为,例如向其他用户发送电子邮件。 它设置在给定秒数内允许的最大操作数;如果超过,违规客户端会收到HTTP 429错误页面,直到该时间段过去。 要检查是否已超出速率限制,请使用User::pingLimiter()函数

The general syntax is:

$wgRateLimits['<action>']['<usergroup>'] = [ <maximum number of action>, <timespan in second> ];

There are some special additional limits:

  • anon - applies to unregistered users only, and applies by action and IP.
  • user - applies to registered users only, and applies by action and user.
  • newbie - applies to both unregistered and "newbie" users, and applies by action and user.
  • ip - applies to both unregistered and "newbie" users (i.e. users without the autoconfirmed user right), and will limit total number of action from one IP regardless of specific users. This will be enforced in addition to other limits.
  • subnet - applies to both unregistered and "newbie" users, and will limit total number of action from the /24 (for IPv4) or /64 (for IPv6) range of IP. This will be enforced in addition to other limits.
  • ip-all - applies to all users other than those whose user-specific limit (see below) is more permissive, and will limit total number of action from one IP regardless of specific users. This will be enforced in addition to other limits.
  • subnet-all - applies to all users other than those whose user-specific limit is more permissive, and will limit total number of action from /24 or /64 range. This will be enforced in addition to other limits.

If there are multiple limit defined, the user-specific limit is defined as:

  • newbie - if the user is a "newbie", or
  • The most permissive (i.e. with the highest action/timespan ratio) of user limit and all applicable user group limits of the user, or
  • anon - for unregistered users.

All user groups defined in $wgAutopromote (for example, autoconfirmed) will not be checked unless you explicitly assigned the user group to a specific user.

For example, to set a maximum of 4 edits per 60 seconds for "newbie" (i.e. non-autoconfirmed) users, add the following:

$wgRateLimits['edit']['newbie'] = [ 4, 60 ];
If you have many newbies using the same IP address, they all aggregate in the same count for the ip limit. 这可能会有积极作用和副作用。 If you for example have a code sprint with a huge number of (legitimate) new users, they might hit the IP limit rather quickly, which might be unwanted. On the other hand, spammers who use several different accounts from the same IP address will hit it as well, which will be wanted.

By setting $wgRateLimits['anAction']['&can-bypass'] = false; the limitations for a specific action can be marked as not skippable. If that is set, neither the noratelimit user right nor the $wgRateLimitsExcludedIPs setting have any effect for that action.

$wgMainCacheType must be set to a value other than CACHE_NONE for rate limits to be enabled at all.

默认值

MediaWiki版本: 1.34
$wgRateLimits = [
	// 页面编辑
	'edit' => [
		'ip' => [ 8, 60 ],
		'newbie' => [ 8, 60 ],
		'user' => [ 90, 60 ],
	],
	// 页面移动
	'move' => [
		'newbie' => [ 2, 120 ],
		'user' => [ 8, 60 ],
	],
	// 文件上传
	'upload' => [
		'ip' => [ 8, 60 ],
		'newbie' => [ 8, 60 ],
	],
	// 页面回退
	'rollback' => [
		'user' => [ 10, 60 ],
		'newbie' => [ 5, 120 ]
	],
	// 触发密码重置电子邮件
	'mailpassword' => [
		'ip' => [ 5, 3600 ],
	],
	// 使用MediaWiki向其他用户发送电子邮件
	'emailuser' => [
		'ip' => [ 5, 86400 ],
		'newbie' => [ 5, 86400 ],
		'user' => [ 20, 86400 ],
	],
	'changeemail' => [
		'ip-all' => [ 10, 3600 ],
		'user' => [ 4, 86400 ]
	],
	// since 1.33 - rate limit email confirmations
	'confirmemail' => [
		'ip-all' => [ 10, 3600 ],
		'user' => [ 4, 86400 ]
	],
	// 清除页面缓存
	'purge' => [
		'ip' => [ 30, 60 ],
		'user' => [ 30, 60 ],
	],
	// 清除链接表
	'linkpurge' => [
		'ip' => [ 30, 60 ],
		'user' => [ 30, 60 ],
	],
	// Files rendered via thumb.php or thumb_handler.php
	'renderfile' => [
		'ip' => [ 700, 30 ],
		'user' => [ 700, 30 ],
	],
	// Same as above but for non-standard thumbnails
	'renderfile-nonstandard' => [
		'ip' => [ 70, 30 ],
		'user' => [ 70, 30 ],
	],
	// Stashing edits into cache before save
	'stashedit' => [
		'ip' => [ 30, 60 ],
		'newbie' => [ 30, 60 ],
	],
	// Adding or removing change tags
	'changetag' => [
		'ip' => [ 8, 60 ],
		'newbie' => [ 8, 60 ],
	],
	// Changing the content model of a page
	'editcontentmodel' => [
		'newbie' => [ 2, 120 ],
		'user' => [ 8, 60 ],
	],
];

Extensions can provide additional keys for $wgRateLimit. E.g. Extension:ConfirmEdit provides a "badcaptcha" key, which allows to throttle users based on the number of wrong answers they have given to a captcha. An example might be:

$wgRateLimits['badcaptcha']['newbie'] = [ 100, 86400 ];

This will allow newbie users not more than 100 wrong answers per day (86400 seconds).

版本差异

  • The 'mailpassword' array was added in MediaWiki 1.7.0.
  • The 'emailuser' array was added in MediaWiki 1.10.0.
  • The 'linkpurge' array was added in MediaWiki 1.22.0.
  • The 'renderfile' array was added in MediaWiki 1.22.0.

参见