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 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
HCaptchaAuthenticationRequest
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 3
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 loadFromSubmission
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFieldInfo
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace MediaWiki\Extension\ConfirmEdit\hCaptcha;
4
5use MediaWiki\Auth\AuthenticationRequest;
6use MediaWiki\Extension\ConfirmEdit\Auth\CaptchaAuthenticationRequest;
7use MediaWiki\MediaWikiServices;
8
9class HCaptchaAuthenticationRequest extends CaptchaAuthenticationRequest {
10    public function __construct() {
11        parent::__construct( '', [] );
12    }
13
14    /** @inheritDoc */
15    public function loadFromSubmission( array $data ) {
16        // unhack the hack in parent
17        return AuthenticationRequest::loadFromSubmission( $data );
18    }
19
20    /** @inheritDoc */
21    public function getFieldInfo() {
22        $ret = [
23            'captchaWord' => [
24                'type' => 'string',
25            ],
26        ];
27
28        // Only display if there's potentially a captcha to solve or interact with...
29
30        if ( defined( 'MW_API' ) ||
31            !MediaWikiServices::getInstance()->getMainConfig()->get( 'HCaptchaInvisibleMode' ) ) {
32            $fieldInfo = parent::getFieldInfo();
33            $ret['captchaWord']['label'] = $fieldInfo['captchaWord']['label'];
34            $ret['captchaWord']['help'] = \wfMessage( 'hcaptcha-help' );
35        }
36
37        return $ret;
38    }
39}