mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-12-10 23:37:52 +00:00
7e97119a91
And also, avoid deprecated use of wfMemcKey() global function. So, create a BagOStuff cache object and use. ::getMainStashInstance() was deprecated in 1.28 and the MainObjectStash service was marked available. Currently, extension requires MediaWiki 1.31 at the minimum so the replacement is safe. Change-Id: I01494a2dcbcbf30fe9960fdfb55b4912a648c7b6
45 lines
851 B
PHP
45 lines
851 B
PHP
<?php
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
class CaptchaCacheStore extends CaptchaStore {
|
|
/** @var BagOStuff */
|
|
private $cache;
|
|
|
|
public function __construct() {
|
|
parent::__construct();
|
|
|
|
$this->cache = MediaWikiServices::getInstance()->getMainObjectStash();
|
|
}
|
|
|
|
public function store( $index, $info ) {
|
|
global $wgCaptchaSessionExpiration;
|
|
|
|
$cache = $this->cache;
|
|
$cache->set(
|
|
$cache->makeKey( 'captcha', $index ),
|
|
$info,
|
|
$wgCaptchaSessionExpiration
|
|
);
|
|
}
|
|
|
|
public function retrieve( $index ) {
|
|
$cache = $this->cache;
|
|
$info = $cache->get( $cache->makeKey( 'captcha', $index ) );
|
|
if ( $info ) {
|
|
return $info;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function clear( $index ) {
|
|
$cache = $this->cache;
|
|
$cache->delete( $cache->makeKey( 'captcha', $index ) );
|
|
}
|
|
|
|
public function cookiesNeeded() {
|
|
return false;
|
|
}
|
|
}
|