mediawiki-extensions-Confir.../ReCaptchaNoCaptcha/includes/ReCaptchaNoCaptchaAuthenticationRequest.php
Daimona Eaytoy 7297235b2a Pass correct type to constructor
Although there was no docblock on CaptchaAuthenticationRequest::__construct,
the method is supposed to get a string and an array, as that's how the
class members are documented and used. Trying to access offsets of null
resulted in PHP notices on PHP 7.4, as seen in the experimental job
for various repos.

Bug: T239726
Change-Id: Idd073ebf3d560543ec225479de060e3c198847eb
2019-12-03 19:30:55 +00:00

31 lines
802 B
PHP

<?php
use MediaWiki\Auth\AuthenticationRequest;
/**
* Authentication request for ReCaptcha v2. Unlike the parent class, no session storage is used
* and there is no ID; Google provides a single proof string after successfully solving a captcha.
*/
class ReCaptchaNoCaptchaAuthenticationRequest extends CaptchaAuthenticationRequest {
public function __construct() {
parent::__construct( '', [] );
}
public function loadFromSubmission( array $data ) {
// unhack the hack in parent
return AuthenticationRequest::loadFromSubmission( $data );
}
public function getFieldInfo() {
$fieldInfo = parent::getFieldInfo();
return [
'captchaWord' => [
'type' => 'string',
'label' => $fieldInfo['captchaInfo']['label'],
'help' => wfMessage( 'renocaptcha-help' ),
],
];
}
}