MediaWiki  1.34.0
CaptchaCacheStore.php
Go to the documentation of this file.
1 <?php
2 
4 
7  private $cache;
8 
9  public function __construct() {
10  parent::__construct();
11 
12  $this->cache = MediaWikiServices::getInstance()->getMainObjectStash();
13  }
14 
15  public function store( $index, $info ) {
16  global $wgCaptchaSessionExpiration;
17 
19  $cache->set(
20  $cache->makeKey( 'captcha', $index ),
21  $info,
22  $wgCaptchaSessionExpiration
23  );
24  }
25 
26  public function retrieve( $index ) {
28  $info = $cache->get( $cache->makeKey( 'captcha', $index ) );
29  if ( $info ) {
30  return $info;
31  } else {
32  return false;
33  }
34  }
35 
36  public function clear( $index ) {
38  $cache->delete( $cache->makeKey( 'captcha', $index ) );
39  }
40 
41  public function cookiesNeeded() {
42  return false;
43  }
44 }
CaptchaCacheStore\cookiesNeeded
cookiesNeeded()
Whether this type of CaptchaStore needs cookies.
Definition: CaptchaCacheStore.php:41
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
CaptchaCacheStore\$cache
BagOStuff $cache
Definition: CaptchaCacheStore.php:7
BagOStuff
Class representing a cache/ephemeral data store.
Definition: BagOStuff.php:63
CaptchaCacheStore\retrieve
retrieve( $index)
Retrieve the answer for a given captcha.
Definition: CaptchaCacheStore.php:26
BagOStuff\get
get( $key, $flags=0)
Get an item with the given key.
CaptchaCacheStore\clear
clear( $index)
Delete a result once the captcha has been used, so it cannot be reused.
Definition: CaptchaCacheStore.php:36
CaptchaStore
Definition: CaptchaStore.php:3
CaptchaCacheStore\store
store( $index, $info)
Store the correct answer for a given captcha.
Definition: CaptchaCacheStore.php:15
BagOStuff\makeKey
makeKey( $class,... $components)
Make a cache key, scoped to this instance's keyspace.
CaptchaCacheStore\__construct
__construct()
Protected constructor: no creating instances except through the factory method above.
Definition: CaptchaCacheStore.php:9
BagOStuff\set
set( $key, $value, $exptime=0, $flags=0)
Set an item.
CaptchaCacheStore
Definition: CaptchaCacheStore.php:5
BagOStuff\delete
delete( $key, $flags=0)
Delete an item.