Enable setting of $wgReCaptchaPublicKey and $wgReCaptchaPrivateKey before including ConfirmEdit

Jump to: navigation, search

With the current SVN revision of ConfirmEdit, if you set any of the key variables ('wgReCaptchaPublicKey', 'wgReCaptchaPrivateKey', 'recaptcha_public_key', and 'recaptcha_private_key') before including ReCaptcha.php, they are overwritten and set to an empty string, causing ReCaptcha to cause an error. I have created a patch (below and http://blucoders.net/wiki/images/7/79/ConfirmEdit-ReCaptcha-fix.diff) that checks to see if they are set or not before initializing them to a blank string.

Index: ReCaptcha.php
===================================================================
--- ReCaptcha.php       (revision 107720)
+++ ReCaptcha.php       (working copy)
@@ -22,11 +22,10 @@
 require_once( 'recaptchalib.php' );

 // Set these in LocalSettings.php
-$wgReCaptchaPublicKey = '';
-$wgReCaptchaPrivateKey = '';
-// For backwards compatibility
-$recaptcha_public_key = '';
-$recaptcha_private_key = '';
+// The last two are for backwards compatibility
+$blank_vars = array('wgReCaptchaPublicKey', 'wgReCaptchaPrivateKey', 'recaptcha_public_key', 'recaptcha_private_key');
+foreach ($blank_vars as $varname)
+        if (!isset($$varname)) $$varname = '';

 /**
  * Sets the theme for ReCaptcha

79.160.59.72 15:04, 31 December 2011 (UTC)

79.160.59.7215:04, 31 December 2011

Generally, it's better to set such variables after the inclusion of the extension in LocalSettings.php - I believe that's true for most extensions.

Yaron Koren18:33, 3 January 2012
 

That's expected. You need to include the extension, then fill any required variables. Otherwise would open for explotation if register_globals was active.

Platonides12:48, 7 January 2012
 
Personal tools

Variants
Actions
Navigation
Support
Download
Development
Communication
Toolbox