2017-12-16 12:32:46 +00:00
|
|
|
<?php
|
|
|
|
|
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 */
|
|
|
|
private $cache;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->cache = MediaWikiServices::getInstance()->getMainObjectStash();
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2019-05-05 14:40:54 +00:00
|
|
|
$cache = $this->cache;
|
|
|
|
$cache->set(
|
|
|
|
$cache->makeKey( 'captcha', $index ),
|
2017-12-16 12:32:46 +00:00
|
|
|
$info,
|
|
|
|
$wgCaptchaSessionExpiration
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-14 23:29:18 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2018-06-15 21:08:14 +00:00
|
|
|
public function retrieve( $index ) {
|
2019-05-05 14:40:54 +00:00
|
|
|
$cache = $this->cache;
|
2020-02-03 14:36:31 +00:00
|
|
|
return $cache->get( $cache->makeKey( 'captcha', $index ) ) ?: false;
|
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 ) {
|
2019-05-05 14:40:54 +00:00
|
|
|
$cache = $this->cache;
|
|
|
|
$cache->delete( $cache->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;
|
|
|
|
}
|
|
|
|
}
|