mediawiki-extensions-Confir.../includes/Store/CaptchaCacheStore.php
Reedy 36bd54e4ec FancyCaptcha: Allow configuration of the actual directory captchas are stored in
Change-Id: Iecc48db5237adc5b89c99019faac0af425e4eb5d
2024-01-15 15:43:46 +00:00

53 lines
1.1 KiB
PHP

<?php
namespace MediaWiki\Extension\ConfirmEdit\Store;
use BagOStuff;
use MediaWiki\MediaWikiServices;
class CaptchaCacheStore extends CaptchaStore {
/** @var BagOStuff */
private $store;
public function __construct() {
parent::__construct();
$this->store = MediaWikiServices::getInstance()->getMicroStash();
}
/**
* @inheritDoc
*/
public function store( $index, $info ) {
global $wgCaptchaSessionExpiration;
$this->store->set(
$this->store->makeKey( 'captcha', $index ),
$info,
$wgCaptchaSessionExpiration,
// Assume the write will reach the master DC before the user sends the
// HTTP POST request attempted to solve the captcha and perform an action
$this->store::WRITE_BACKGROUND
);
}
/**
* @inheritDoc
*/
public function retrieve( $index ) {
return $this->store->get( $this->store->makeKey( 'captcha', $index ) );
}
/**
* @inheritDoc
*/
public function clear( $index ) {
$this->store->delete( $this->store->makeKey( 'captcha', $index ) );
}
public function cookiesNeeded() {
return false;
}
}
class_alias( CaptchaCacheStore::class, 'CaptchaCacheStore' );