jenkins-bot has submitted this change and it was merged. Change subject: Expose equivalent functionality for passCaptcha ......................................................................
Expose equivalent functionality for passCaptcha passCaptcha was made protected in I0da671a546700110d789b79a3089460abd9cce3b, but some other extensions used it, provide passCaptchaFromRequest as a replacement. Bug: T135477 Change-Id: I47b2e2fbe3e063cd86e8a2d6bc17ca939472dbe1 (cherry picked from commit f97212acbfcbc43c4c13cff0c22598e3b7dc7871) --- M ReCaptcha/ReCaptcha.class.php M ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php M SimpleCaptcha/Captcha.php 3 files changed, 26 insertions(+), 7 deletions(-) Approvals: Gergő Tisza: Looks good to me, approved jenkins-bot: Verified diff --git a/ReCaptcha/ReCaptcha.class.php b/ReCaptcha/ReCaptcha.class.php index 9e6cffb..e92791a 100644 --- a/ReCaptcha/ReCaptcha.class.php +++ b/ReCaptcha/ReCaptcha.class.php @@ -27,13 +27,12 @@ recaptcha_get_html( $wgReCaptchaPublicKey, $this->recaptcha_error, $useHttps ); } - function passCaptchaLimitedFromRequest( WebRequest $request, User $user ) { + protected function getCaptchaParamsFromRequest( WebRequest $request ) { // API is hardwired to return captchaId and captchaWord, // so use that if the standard two are empty $challenge = $request->getVal( 'recaptcha_challenge_field', $request->getVal( 'captchaId' ) ); $response = $request->getVal( 'recaptcha_response_field', $request->getVal( 'captchaWord' ) ); - - return $this->passCaptchaLimited( $challenge, $response, $user ); + return [ $challenge, $response ]; } /** diff --git a/ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php b/ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php index 759c5da..1d9130b 100644 --- a/ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php +++ b/ReCaptchaNoCaptcha/ReCaptchaNoCaptcha.class.php @@ -70,11 +70,11 @@ wfDebugLog( 'captcha', 'Unable to validate response: ' . $error ); } - public function passCaptchaLimitedFromRequest( WebRequest $request, User $user ) { + protected function getCaptchaParamsFromRequest( WebRequest $request ) { $index = 'not used'; // ReCaptchaNoCaptcha combines captcha ID + solution into a single value // API is hardwired to return captchaWord, so use that if the standard isempty $response = $request->getVal( 'g-recaptcha-response', $request->getVal( 'captchaWord' ) ); - return $this->passCaptchaLimited( $index, $response, $user ); + return [ $index, $response ]; } /** diff --git a/SimpleCaptcha/Captcha.php b/SimpleCaptcha/Captcha.php index 9b58259..63ed6d6 100755 --- a/SimpleCaptcha/Captcha.php +++ b/SimpleCaptcha/Captcha.php @@ -1059,10 +1059,18 @@ * @return bool */ public function passCaptchaLimitedFromRequest( WebRequest $request, User $user ) { + list( $index, $word ) = $this->getCaptchaParamsFromRequest( $request ); + return $this->passCaptchaLimited( $index, $word, $user ); + } + + /** + * @param WebRequest $request + * @return array [ captcha ID, captcha solution ] + */ + protected function getCaptchaParamsFromRequest( WebRequest $request ) { $index = $request->getVal( 'wpCaptchaId' ); $word = $request->getVal( 'wpCaptchaWord' ); - - return $this->passCaptchaLimited( $index, $word, $user ); + return [ $index, $word ]; } /** @@ -1095,6 +1103,18 @@ /** * Given a required captcha run, test form input for correct * input on the open session. + * @param WebRequest $request + * @param User $user + * @return bool if passed, false if failed or new session + */ + public function passCaptchaFromRequest( WebRequest $request, User $user ) { + list( $index, $word ) = $this->getCaptchaParamsFromRequest( $request ); + return $this->passCaptcha( $index, $word, $user ); + } + + /** + * Given a required captcha run, test form input for correct + * input on the open session. * @param string $index Captcha idenitifier * @param string $word Captcha solution * @return bool if passed, false if failed or new session -- To view, visit https://gerrit.wikimedia.org/r/289326 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I47b2e2fbe3e063cd86e8a2d6bc17ca939472dbe1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ConfirmEdit Gerrit-Branch: REL1_27 Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits