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();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-06-15 21:08:14 +00:00
|
|
|
public function retrieve( $index ) {
|
2019-05-05 14:40:54 +00:00
|
|
|
$cache = $this->cache;
|
|
|
|
$info = $cache->get( $cache->makeKey( 'captcha', $index ) );
|
2017-12-16 12:32:46 +00:00
|
|
|
if ( $info ) {
|
|
|
|
return $info;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|