mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-27 17:40:11 +00:00
3b195090fe
Why: - In the production WMF deployment of AbuseFilter and ConfirmEdit, we load ConfirmEdit first, then AbuseFilter. That means that ConfirmEdit's onEditFilterMergedContent hook fires before AbuseFilter's. The problem is that AbuseFilter uses onEditFilterMergedContent to evaluate its rules and consequences, so an AbuseFilter rule that defines a "showcaptcha" consequence becomes a no-op, as it fires after ConfirmEdit has already decided to show or not show a CAPTCHA to a user. - All of that is to say: we need a way to tell ConfirmEdit to show a CAPTCHA at the time that AbuseFilter's consequences are invoked, which could be before or after ConfirmEdit's EditFilterMergedContent hook invocation, depending on how the wiki has decided to load the extensions What: - Define a flag for "shouldForceShowCaptcha", that other extensions can set on the SimpleCaptcha base class to indicate that ConfirmEdit must show a CAPTCHA (users with "skipcaptcha" right are still exempt) - Check the isCaptchaSolved() and shouldForShowCaptcha() flags in ::triggersCaptcha, and also check if ConfirmEdit's EditFilterMergedContent hook already ran - In CaptchaConsequence, set the forceShowCaptcha property on the SimpleCaptcha base class - [misc] Add getter/setter for the captchaSolved property and the other new class properties Depends-On: I7dd3a7c41606dcf5123518c2d3d0f4355f5edfd3 Bug: T20110 Change-Id: Idc47bdae8007da938f31e1c0f33e9be4813f41d7
20 lines
542 B
PHP
20 lines
542 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\ConfirmEdit\AbuseFilter;
|
|
|
|
use MediaWiki\Extension\AbuseFilter\Consequences\Consequence\Consequence;
|
|
use MediaWiki\Extension\ConfirmEdit\Hooks;
|
|
|
|
/**
|
|
* Show a CAPTCHA to the user before they can proceed with an action.
|
|
*/
|
|
class CaptchaConsequence extends Consequence {
|
|
|
|
public function execute(): bool {
|
|
// This consequence was triggered, so we need to set a flag
|
|
// on the SimpleCaptcha instance to force showing the CAPTCHA.
|
|
Hooks::getInstance()->setForceShowCaptcha( true );
|
|
return true;
|
|
}
|
|
}
|