r104873 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104872‎ | r104873 | r104874 >
Date:16:51, 1 December 2011
Author:mah
Status:ok
Tags:
Comment:
moar w/s fixups
Modified paths:
  • /trunk/extensions/ConfirmEdit/ReCaptcha.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ConfirmEdit/ReCaptcha.php
@@ -55,8 +55,8 @@
5656
5757 if ($wgReCaptchaPublicKey == '' || $wgReCaptchaPrivateKey == '') {
5858 die ('You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' .
59 - "use the reCAPTCHA plugin. You can sign up for a key <a href='" .
60 - htmlentities(recaptcha_get_signup_url ($wgServerName, "mediawiki")) . "'>here</a>.");
 59+ "use the reCAPTCHA plugin. You can sign up for a key <a href='" .
 60+ htmlentities(recaptcha_get_signup_url ($wgServerName, "mediawiki")) . "'>here</a>.");
6161 }
6262 }
6363
@@ -68,9 +68,9 @@
6969
7070 /**
7171 * Displays the reCAPTCHA widget.
72 - * If $this->recaptcha_error is set, it will display an error in the widget.
 72+ * If $this->recaptcha_error is set, it will display an error in the widget.
7373 *
74 - */
 74+ */
7575 function getForm() {
7676 global $wgReCaptchaPublicKey, $wgReCaptchaTheme;
7777 $useHttps = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' );
@@ -82,21 +82,24 @@
8383 /**
8484 * Calls the library function recaptcha_check_answer to verify the users input.
8585 * Sets $this->recaptcha_error if the user is incorrect.
86 - * @return boolean
87 - *
88 - */
 86+ * @return boolean
 87+ *
 88+ */
8989 function passCaptcha() {
9090 global $wgReCaptchaPrivateKey;
91 - $recaptcha_response = recaptcha_check_answer ($wgReCaptchaPrivateKey,
92 - wfGetIP (),
93 - $_POST['recaptcha_challenge_field'],
94 - $_POST['recaptcha_response_field']);
95 - if (!$recaptcha_response->is_valid) {
 91+ $recaptcha_response =
 92+ recaptcha_check_answer (
 93+ $wgReCaptchaPrivateKey,
 94+ wfGetIP (),
 95+ $_POST['recaptcha_challenge_field'],
 96+ $_POST['recaptcha_response_field']
 97+ );
 98+ if (!$recaptcha_response->is_valid) {
9699 $this->recaptcha_error = $recaptcha_response->error;
97100 return false;
98 - }
 101+ }
99102 $recaptcha_error = null;
100 - return true;
 103+ return true;
101104
102105 }
103106
@@ -108,17 +111,17 @@
109112 if( $this->shouldCheck( $editPage, $newtext, $section ) ) {
110113
111114 if (!isset($_POST['recaptcha_response_field'])) {
112 - //User has not yet been presented with Captcha, show the widget.
113 - $editPage->showEditForm( array( &$this, 'editCallback' ) );
114 - return false;
 115+ //User has not yet been presented with Captcha, show the widget.
 116+ $editPage->showEditForm( array( &$this, 'editCallback' ) );
 117+ return false;
115118 }
116119
117120 if( $this->passCaptcha() ) {
118 - return true;
 121+ return true;
119122 } else {
120 - //Try again - show the widget
121 - $editPage->showEditForm( array( &$this, 'editCallback' ) );
122 - return false;
 123+ //Try again - show the widget
 124+ $editPage->showEditForm( array( &$this, 'editCallback' ) );
 125+ return false;
123126 }
124127
125128 } else {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r104871w/s fixups before real changes.mah16:42, 1 December 2011

Status & tagging log