mediawiki-extensions-Confir.../includes/store/CaptchaCacheStore.php
Derick Alangi 7e97119a91 store: Avoid deprecated use of ObjectCache::getMainStashInstance()
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
2019-05-08 22:59:16 +01:00

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;
}
}