2017-12-16 12:32:46 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 16:40:15 +00:00
|
|
|
namespace MediaWiki\Extension\ConfirmEdit\Store;
|
|
|
|
|
|
|
|
use BagOStuff;
|
2019-05-05 14:40:54 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
2017-12-16 12:32:46 +00:00
|
|
|
class CaptchaCacheStore extends CaptchaStore {
|
2019-05-05 14:40:54 +00:00
|
|
|
/** @var BagOStuff */
|
2023-11-20 17:59:03 +00:00
|
|
|
private $store;
|
2019-05-05 14:40:54 +00:00
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
|
2023-11-20 17:34:02 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
2023-11-20 17:59:03 +00:00
|
|
|
$this->store = $services->getMicroStash();
|
2019-05-05 14:40:54 +00:00
|
|
|
}
|
|
|
|
|
2020-04-14 23:29:18 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2018-06-15 21:08:14 +00:00
|
|
|
public function store( $index, $info ) {
|
2017-12-16 12:32:46 +00:00
|
|
|
global $wgCaptchaSessionExpiration;
|
|
|
|
|
2023-11-20 17:59:03 +00:00
|
|
|
$store = $this->store;
|
|
|
|
$store->set(
|
|
|
|
$store->makeKey( 'captcha', $index ),
|
2017-12-16 12:32:46 +00:00
|
|
|
$info,
|
2023-06-06 19:57:53 +00:00
|
|
|
$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
|
2023-11-20 17:59:03 +00:00
|
|
|
$store::WRITE_BACKGROUND
|
2017-12-16 12:32:46 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-14 23:29:18 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2018-06-15 21:08:14 +00:00
|
|
|
public function retrieve( $index ) {
|
2023-11-20 17:59:03 +00:00
|
|
|
$store = $this->store;
|
2023-11-20 17:34:02 +00:00
|
|
|
|
2023-11-20 17:59:03 +00:00
|
|
|
return $store->get( $store->makeKey( 'captcha', $index ) );
|
2017-12-16 12:32:46 +00:00
|
|
|
}
|
|
|
|
|
2020-04-14 23:29:18 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2018-06-15 21:08:14 +00:00
|
|
|
public function clear( $index ) {
|
2023-11-20 17:59:03 +00:00
|
|
|
$store = $this->store;
|
|
|
|
$store->delete( $store->makeKey( 'captcha', $index ) );
|
2017-12-16 12:32:46 +00:00
|
|
|
}
|
|
|
|
|
2018-06-15 21:08:14 +00:00
|
|
|
public function cookiesNeeded() {
|
2017-12-16 12:32:46 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2022-04-08 16:40:15 +00:00
|
|
|
|
|
|
|
class_alias( CaptchaCacheStore::class, 'CaptchaCacheStore' );
|