Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/54138
Change subject: Update API parameter injection
......................................................................
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
---
M Captcha.php
M ConfirmEditHooks.php
M ReCaptcha.class.php
3 files changed, 31 insertions(+), 13 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ConfirmEdit
refs/changes/38/54138/1
diff --git a/Captcha.php b/Captcha.php
index 0f78d36..2d6afbf 100644
--- a/Captcha.php
+++ b/Captcha.php
@@ -577,15 +577,23 @@
/**
* @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 @@
* @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;
}
diff --git a/ConfirmEditHooks.php b/ConfirmEditHooks.php
index 66e5199..bc85138 100644
--- a/ConfirmEditHooks.php
+++ b/ConfirmEditHooks.php
@@ -55,8 +55,9 @@
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 ) {
diff --git a/ReCaptcha.class.php b/ReCaptcha.class.php
index 59b31f4..cd274a9 100644
--- a/ReCaptcha.class.php
+++ b/ReCaptcha.class.php
@@ -81,11 +81,21 @@
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;
}
}
--
To view, visit https://gerrit.wikimedia.org/r/54138
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia8c9a8b882ee3480b71bfb3f2345475506549819
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ConfirmEdit
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits