Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
CaptchaCacheStore
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 5
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 store
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 retrieve
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 clear
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 cookiesNeeded
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\ConfirmEdit\Store;
4
5use BagOStuff;
6use MediaWiki\MediaWikiServices;
7
8class CaptchaCacheStore extends CaptchaStore {
9    /** @var BagOStuff */
10    private $store;
11
12    public function __construct() {
13        parent::__construct();
14        $this->store = MediaWikiServices::getInstance()->getMicroStash();
15    }
16
17    /**
18     * @inheritDoc
19     */
20    public function store( $index, $info ) {
21        global $wgCaptchaSessionExpiration;
22
23        $this->store->set(
24            $this->store->makeKey( 'captcha', $index ),
25            $info,
26            $wgCaptchaSessionExpiration,
27            // Assume the write will reach the master DC before the user sends the
28            // HTTP POST request attempted to solve the captcha and perform an action
29            $this->store::WRITE_BACKGROUND
30        );
31    }
32
33    /**
34     * @inheritDoc
35     */
36    public function retrieve( $index ) {
37        return $this->store->get( $this->store->makeKey( 'captcha', $index ) );
38    }
39
40    /**
41     * @inheritDoc
42     */
43    public function clear( $index ) {
44        $this->store->delete( $this->store->makeKey( 'captcha', $index ) );
45    }
46
47    public function cookiesNeeded() {
48        return false;
49    }
50}
51
52class_alias( CaptchaCacheStore::class, 'CaptchaCacheStore' );