mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-12-19 19:31:07 +00:00
10b9276855
Why: - We want to allow administrators to invoke a CAPTCHA if an AbuseFilter is configured to do so. What: - Implement the AbuseFilterCustomActions hook and define CaptchaConsequence, which will inform AbuseFilter's implementation of onConfirmEditTriggersCaptcha that it should show a CAPTCHA - Deliberately do not register the "showcaptcha" action as a "dangerous action", because filters that use this action are aimed at bot traffic, and we don't want a bot to be able to get past the "showcaptcha" action just by making repeat requests Soft depends on I110a5f5321649dcf85993a0c209ab70b9886057c Bug: T20110 Change-Id: Ie87e3d850541c7dc44aaeb6b30489a32a0c8cc60
23 lines
680 B
PHP
23 lines
680 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\ConfirmEdit\AbuseFilter;
|
|
|
|
use MediaWiki\Context\RequestContext;
|
|
use MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Consequence;
|
|
|
|
/**
|
|
* Will inform ConfirmEdit extension to show a CAPTCHA.
|
|
*/
|
|
class CaptchaConsequence extends Consequence {
|
|
|
|
public const FLAG = 'wgAbuseFilterCaptchaConsequence';
|
|
|
|
public function execute(): bool {
|
|
// This consequence was triggered, so we need to set a global flag
|
|
// which Extension:ConfirmEdit will read in order to decide if a
|
|
// CAPTCHA should be shown to the user in onConfirmEditTriggersCaptcha
|
|
RequestContext::getMain()->getRequest()->setVal( self::FLAG, true );
|
|
return true;
|
|
}
|
|
}
|