mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-23 15:56:50 +00:00
Update API parameter injection
The ReCaptcha module was not injecting its parameters at all, so they were not showing up in the auto-generated help. This is now fixed. Also, the API recently added a new parameter to the APIGetAllowedParams hook to differentiate between fetching the allowed parameter list for help output and fetching it for processing within the module. ConfirmEdit only needs to inject the parameters for the former, so it should check this parameter if available. Change-Id: Ia8c9a8b882ee3480b71bfb3f2345475506549819
This commit is contained in:
parent
c7680cef4a
commit
c9f99cca38
27
Captcha.php
27
Captcha.php
|
@ -577,15 +577,23 @@ class SimpleCaptcha {
|
|||
|
||||
/**
|
||||
* @param $module ApiBase
|
||||
* @param $params array
|
||||
* @return bool
|
||||
*/
|
||||
public function APIGetAllowedParams( &$module, &$params ) {
|
||||
if ( !$module instanceof ApiEditPage ) {
|
||||
return true;
|
||||
protected function isAPICaptchaModule( $module ) {
|
||||
return $module instanceof ApiEditPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $module ApiBase
|
||||
* @param $params array
|
||||
* @param $flags int
|
||||
* @return bool
|
||||
*/
|
||||
public function APIGetAllowedParams( &$module, &$params, $flags ) {
|
||||
if ( $flags && $this->isAPICaptchaModule( $module ) ) {
|
||||
$params['captchaword'] = null;
|
||||
$params['captchaid'] = null;
|
||||
}
|
||||
$params['captchaword'] = null;
|
||||
$params['captchaid'] = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -596,11 +604,10 @@ class SimpleCaptcha {
|
|||
* @return bool
|
||||
*/
|
||||
public function APIGetParamDescription( &$module, &$desc ) {
|
||||
if ( !$module instanceof ApiEditPage ) {
|
||||
return true;
|
||||
if ( $this->isAPICaptchaModule( $module ) ) {
|
||||
$desc['captchaid'] = 'CAPTCHA ID from previous request';
|
||||
$desc['captchaword'] = 'Answer to the CAPTCHA';
|
||||
}
|
||||
$desc['captchaid'] = 'CAPTCHA ID from previous request';
|
||||
$desc['captchaword'] = 'Answer to the CAPTCHA';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,9 @@ class ConfirmEditHooks {
|
|||
return self::getInstance()->confirmEmailUser( $from, $to, $subject, $text, $error );
|
||||
}
|
||||
|
||||
public static function APIGetAllowedParams( &$module, &$params ) {
|
||||
return self::getInstance()->APIGetAllowedParams( $module, $params );
|
||||
// Default $flags to 1 for backwards-compatible behavior
|
||||
public static function APIGetAllowedParams( &$module, &$params, $flags = 1 ) {
|
||||
return self::getInstance()->APIGetAllowedParams( $module, $params, $flags );
|
||||
}
|
||||
|
||||
public static function APIGetParamDescription( &$module, &$desc ) {
|
||||
|
|
|
@ -81,11 +81,21 @@ class ReCaptcha extends SimpleCaptcha {
|
|||
return wfMessage( $name, $text )->isDisabled() ? wfMessage( 'recaptcha-edit' )->text() : $text;
|
||||
}
|
||||
|
||||
public function APIGetAllowedParams( &$module, &$params ) {
|
||||
public function APIGetAllowedParams( &$module, &$params, $flags ) {
|
||||
if ( $flags && $this->isAPICaptchaModule( $module ) ) {
|
||||
$params['recaptcha_challenge_field'] = null;
|
||||
$params['recaptcha_response_field'] = null;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function APIGetParamDescription( &$module, &$desc ) {
|
||||
if ( $this->isAPICaptchaModule( $module ) ) {
|
||||
$desc['recaptcha_challenge_field'] = 'Field from the ReCaptcha widget';
|
||||
$desc['recaptcha_response_field'] = 'Field from the ReCaptcha widget';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue