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();
|
2024-01-15 15:17:21 +00:00
|
|
|
$this->store = MediaWikiServices::getInstance()->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;
|
|
|
|
|
2024-01-15 15:17:21 +00:00
|
|
|
$this->store->set(
|
|
|
|
$this->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
|
2024-01-15 15:17:21 +00:00
|
|
|
$this->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 ) {
|
2024-01-15 15:17:21 +00:00
|
|
|
return $this->store->get( $this->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 ) {
|
2024-01-15 15:17:21 +00:00
|
|
|
$this->store->delete( $this->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' );
|