2017-12-16 12:32:46 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 16:40:15 +00:00
|
|
|
namespace MediaWiki\Extension\ConfirmEdit\Store;
|
|
|
|
|
2019-05-05 14:40:54 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2024-10-19 21:34:41 +00:00
|
|
|
use Wikimedia\ObjectCache\BagOStuff;
|
2019-05-05 14:40:54 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2024-10-25 18:24:07 +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,
|
2024-10-25 18:24:07 +00:00
|
|
|
// Assume the write action will reach the primary DC before the user sends the
|
2023-06-06 19:57:53 +00:00
|
|
|
// 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
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-10-25 18:24:07 +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
|
|
|
}
|
|
|
|
|
2024-10-25 18:24:07 +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
|
|
|
}
|
|
|
|
|
2024-10-25 18:24:07 +00:00
|
|
|
/** @inheritDoc */
|
2018-06-15 21:08:14 +00:00
|
|
|
public function cookiesNeeded() {
|
2017-12-16 12:32:46 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|