Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -176,6 +176,8 @@ |
177 | 177 | * wlexcludeuser parameter added to ApiFeedWatchlist. |
178 | 178 | * (bug 7304) Links on redirect pages no longer cause the redirect page to show |
179 | 179 | up as a redirect to the linked page on Special:Whatlinkshere. |
| 180 | +* (bug 32609) API: Move captchaid/captchaword of action=edit from core |
| 181 | + to Captcha extension(s) |
180 | 182 | |
181 | 183 | === Languages updated in 1.19 === |
182 | 184 | |
Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -239,15 +239,15 @@ |
240 | 240 | $ep->setContextTitle( $titleObj ); |
241 | 241 | $ep->importFormData( $req ); |
242 | 242 | |
243 | | - // Run hooks |
244 | | - // Handle CAPTCHA parameters |
245 | | - if ( !is_null( $params['captchaid'] ) ) { |
| 243 | + if ( isset( $params['captchaid'] ) && !is_null( $params['captchaid'] ) ) { |
246 | 244 | $wgRequest->setVal( 'wpCaptchaId', $params['captchaid'] ); |
247 | 245 | } |
248 | | - if ( !is_null( $params['captchaword'] ) ) { |
| 246 | + if ( isset( $params['captchaword'] ) && !is_null( $params['captchaword'] ) ) { |
249 | 247 | $wgRequest->setVal( 'wpCaptchaWord', $params['captchaword'] ); |
250 | 248 | } |
251 | 249 | |
| 250 | + // Run hooks |
| 251 | + // Handle APIEditBeforeSave parameters |
252 | 252 | $r = array(); |
253 | 253 | if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) ) { |
254 | 254 | if ( count( $r ) ) { |
— | — | @@ -422,8 +422,6 @@ |
423 | 423 | 'recreate' => false, |
424 | 424 | 'createonly' => false, |
425 | 425 | 'nocreate' => false, |
426 | | - 'captchaword' => null, |
427 | | - 'captchaid' => null, |
428 | 426 | 'watch' => array( |
429 | 427 | ApiBase::PARAM_DFLT => false, |
430 | 428 | ApiBase::PARAM_DEPRECATED => true, |
— | — | @@ -482,8 +480,6 @@ |
483 | 481 | 'watch' => 'Add the page to your watchlist', |
484 | 482 | 'unwatch' => 'Remove the page from your watchlist', |
485 | 483 | 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch', |
486 | | - 'captchaid' => 'CAPTCHA ID from previous request', |
487 | | - 'captchaword' => 'Answer to the CAPTCHA', |
488 | 484 | 'md5' => array( "The MD5 hash of the {$p}text parameter, or the {$p}prependtext and {$p}appendtext parameters concatenated.", |
489 | 485 | 'If set, the edit won\'t be done unless the hash is correct' ), |
490 | 486 | 'prependtext' => "Add this text to the beginning of the page. Overrides {$p}text", |
Index: trunk/extensions/ConfirmEdit/ReCaptcha.php |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Captcha class using the reCAPTCHA widget. |
6 | | - * Stop Spam. Read Books. |
| 5 | + * Captcha class using the reCAPTCHA widget. |
| 6 | + * Stop Spam. Read Books. |
7 | 7 | * |
8 | 8 | * @addtogroup Extensions |
9 | 9 | * @author Mike Crawford <mike.crawford@gmail.com> |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | die ('You need to set $wgReCaptchaPrivateKey and $wgReCaptchaPublicKey in LocalSettings.php to ' . |
59 | 59 | "use the reCAPTCHA plugin. You can sign up for a key <a href='" . |
60 | 60 | htmlentities(recaptcha_get_signup_url ($wgServerName, "mediawiki")) . "'>here</a>."); |
61 | | - } |
| 61 | + } |
62 | 62 | } |
63 | 63 | |
64 | 64 | |
— | — | @@ -142,4 +142,11 @@ |
143 | 143 | return wfEmptyMsg( $name, $text ) ? wfMsg( 'recaptcha-edit' ) : $text; |
144 | 144 | } |
145 | 145 | |
| 146 | + public function APIGetAllowedParams( &$module, &$params ) { |
| 147 | + return true; |
| 148 | + } |
| 149 | + |
| 150 | + public function APIGetParamDescription( &$module, &$desc ) { |
| 151 | + return true; |
| 152 | + } |
146 | 153 | } |
Index: trunk/extensions/ConfirmEdit/Captcha.php |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Instantiate a new Captcha object for a given Id |
48 | | - * |
| 48 | + * |
49 | 49 | * @param $id Int |
50 | 50 | * @return Captcha |
51 | 51 | */ |
— | — | @@ -305,7 +305,7 @@ |
306 | 306 | wfDebug( "ConfirmEdit: user group allows skipping captcha on email sending\n" ); |
307 | 307 | return true; |
308 | 308 | } |
309 | | - $form->addFooterText( |
| 309 | + $form->addFooterText( |
310 | 310 | "<div class='captcha'>" . |
311 | 311 | $wgOut->parse( $this->getMessage( 'sendemail' ) ) . |
312 | 312 | $this->getForm() . |
— | — | @@ -692,6 +692,7 @@ |
693 | 693 | $this->addCaptchaAPI( $resultArr ); |
694 | 694 | return false; |
695 | 695 | } |
| 696 | + |
696 | 697 | return true; |
697 | 698 | } |
698 | 699 | |
— | — | @@ -742,7 +743,7 @@ |
743 | 744 | } |
744 | 745 | |
745 | 746 | /** |
746 | | - * Check the captcha on Special:EmailUser |
| 747 | + * Check the captcha on Special:EmailUser |
747 | 748 | * @param $from MailAddress |
748 | 749 | * @param $to MailAddress |
749 | 750 | * @param $subject String |
— | — | @@ -759,7 +760,7 @@ |
760 | 761 | } |
761 | 762 | if ( $this->isIPWhitelisted() ) |
762 | 763 | return true; |
763 | | - |
| 764 | + |
764 | 765 | if ( defined( 'MW_API' ) ) { |
765 | 766 | # API mode |
766 | 767 | # Asking for captchas in the API is really silly |
— | — | @@ -776,6 +777,36 @@ |
777 | 778 | } |
778 | 779 | |
779 | 780 | /** |
| 781 | + * @param $module ApiBase |
| 782 | + * @param $params array |
| 783 | + * @return bool |
| 784 | + */ |
| 785 | + public function APIGetAllowedParams( &$module, &$params ) { |
| 786 | + if ( !$module instanceof ApiEditPage ) { |
| 787 | + return true; |
| 788 | + } |
| 789 | + $params['captchaword'] = null; |
| 790 | + $params['captchaid'] = null; |
| 791 | + |
| 792 | + return true; |
| 793 | + } |
| 794 | + |
| 795 | + /** |
| 796 | + * @param $module ApiBae |
| 797 | + * @param $desc array |
| 798 | + * @return bool |
| 799 | + */ |
| 800 | + public function APIGetParamDescription( &$module, &$desc ) { |
| 801 | + if ( !$module instanceof ApiEditPage ) { |
| 802 | + return true; |
| 803 | + } |
| 804 | + $desc['captchaid'] = 'CAPTCHA ID from previous request'; |
| 805 | + $desc['captchaword'] = 'Answer to the CAPTCHA'; |
| 806 | + |
| 807 | + return true; |
| 808 | + } |
| 809 | + |
| 810 | + /** |
780 | 811 | * Given a required captcha run, test form input for correct |
781 | 812 | * input on the open session. |
782 | 813 | * @return bool if passed, false if failed or new session |
Index: trunk/extensions/ConfirmEdit/ConfirmEdit.php |
— | — | @@ -199,6 +199,8 @@ |
200 | 200 | $wgHooks['EmailUser'][] = 'ConfirmEditHooks::confirmEmailUser'; |
201 | 201 | # Register API hook |
202 | 202 | $wgHooks['APIEditBeforeSave'][] = 'ConfirmEditHooks::confirmEditAPI'; |
| 203 | +$wgHooks['APIGetAllowedParams'][] = 'ConfirmEditHooks::APIGetAllowedParams'; |
| 204 | +$wgHooks['APIEditBeforeSave'][] = 'ConfirmEditHooks::APIEditBeforeSave'; |
203 | 205 | |
204 | 206 | $wgAutoloadClasses['ConfirmEditHooks'] = "$wgConfirmEditIP/ConfirmEditHooks.php"; |
205 | 207 | $wgAutoloadClasses['Captcha']= "$wgConfirmEditIP/Captcha.php"; |
Index: trunk/extensions/ConfirmEdit/ConfirmEditHooks.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | /** |
7 | 7 | * Get the global Captcha instance |
8 | 8 | * |
9 | | - * @return Captcha |
| 9 | + * @return Captcha|SimpleCaptcha |
10 | 10 | */ |
11 | 11 | static function getInstance() { |
12 | 12 | global $wgCaptcha, $wgCaptchaClass; |
— | — | @@ -56,6 +56,14 @@ |
57 | 57 | static function confirmEmailUser( $from, $to, $subject, $text, &$error ) { |
58 | 58 | return self::getInstance()->confirmEmailUser( $from, $to, $subject, $text, $error ); |
59 | 59 | } |
| 60 | + |
| 61 | + public static function APIGetAllowedParams( &$module, &$params ) { |
| 62 | + return self::getInstance()->APIGetAllowedParams( $module, $params ); |
| 63 | + } |
| 64 | + |
| 65 | + public static function APIGetParamDescription( &$module, &$desc ) { |
| 66 | + return self::getInstance()->APIGetParamDescription( $module, $desc ); |
| 67 | + } |
60 | 68 | } |
61 | 69 | |
62 | 70 | class CaptchaSpecialPage extends UnlistedSpecialPage { |