Merge "Update API parameter injection"

This commit is contained in:
jenkins-bot 2013-03-26 16:40:39 +00:00 committed by Gerrit Code Review
commit b99e833d91
3 changed files with 31 additions and 13 deletions

View file

@ -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;
}

View file

@ -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 ) {

View file

@ -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;
}
}