Topic on Project:Support desk

Summary by Florianschmidtwelzow
EFFemeer (talkcontribs)

I'm a bit confused by the following:

My contact form works fine when logged in. But when not logged in, I get

Catchable fatal error: Argument 1 passed to ReCaptcha::getForm() must be an instance of OutputPage, none given, called in /www/htdocs/drebbel/wiki/extensions/ContactPage/ContactPage_body.php on line 488 and defined in/www/htdocs/drebbel/wiki/extensions/ConfirmEdit/ReCaptcha/ReCaptcha.class.php on line 12

___

My LocalSettings.php:

wfLoadExtensions( array( 'ConfirmEdit', 'ConfirmEdit/ReCaptcha' ) );

require_once "$IP/extensions/ContactPage/ContactPage.php";

$wgContactUser = 'xxxx';

$wgContactSender = $wgPasswordSender;

$wgContactSenderName = 'Contact Form on ' . $wgSitename;

$wgContactConfig['default'] = array(

'RecipientUser' => 'xxxx', // Must be the name of a valid account which also has a verified e-mail-address added to it.

'SenderName' => 'Contact Form on ' . $wgSitename, // "Contact Form on" needs to be translated

'SenderEmail' => null, // Defaults to $wgPasswordSender, may be changed as required

'RequireDetails' => true, // Either "true" or "false" as required

'IncludeIP' => true, // Either "true" or "false" as required

'AdditionalFields' => array(

'Text' => array(

'label-message' => 'emailmessage',

'type' => 'textarea',

'rows' => 10,

'cols' => 80,

'required' => true,  // Either "true" or "false" as required

),

),

        // Added in MW 1.26

        'DisplayFormat' => 'table',  // See HTMLForm documentation for available values.

        'RLModules' => array(),  // Resource loader modules to add to the form display page.

        'RLStyleModules' => array(),  // Resource loader CSS modules to add to the form display page.

);

$wgCaptchaClass = 'ReCaptcha';

$wgReCaptchaPublicKey = '6xxxxK';

$wgReCaptchaPrivateKey = '6xxxxi';

$wgGroupPermissions['*'            ]['skipcaptcha'] = false;

$wgGroupPermissions['user'         ]['skipcaptcha'] = true;

$wgGroupPermissions['autoconfirmed']['skipcaptcha'] = true;

$wgGroupPermissions['bot'          ]['skipcaptcha'] = true; // registered bots

$wgGroupPermissions['sysop'        ]['skipcaptcha'] = true;

$wgCaptchaTriggers['edit']          = true;

$wgCaptchaTriggers['create']        = true;

$wgCaptchaTriggers['createaccount'] = true;

$wgCaptchaTriggers['contactpage'] = true; // Adds reCAPTCHA to the contact page if created

_________________

I've changed the function getForm( OutputPage $out ) into getform() {in ReCaptcha.class.php} and now it works fine apart from the fact that one often has to refresh the contactpage for the Captcha to appear.

87.123.31.241 (talkcontribs)

The code of the ReCaptcha plugin and of the ContactPage extension are not compatible currently.

For ReCaptcha, the first parameter in the call to getForm() must be an instance of OutputPage like so:

getForm( OutputPage $out, $tabIndex = 1 )  

ContactPage_body.php line 488 however calls it like so:

$captcha->getForm()

without providing any parameters.

Does it work, if you change this call as follows?

$captcha->getForm( OutputPage $out )
EFFemeer (talkcontribs)

Thanks for the prompt reaction.

Unfortunately this gives Parse error: syntax error, unexpected T_VARIABLE in /www/htdocs/drebbel/wiki/extensions/ContactPage/ContactPage_body.php on line 488

Changing the function getForm( OutputPage $out ) into getform() {in ReCaptcha.class.php} works better, but the Captcha window generally doesn't appear until the page is refreshed. http://drebbel.net/wiki/Special:Contact

It seems that other Captcha's aren't doing any better?

87.123.38.25 (talkcontribs)

I would still try to fix this error in ContactPage_body.php on line 488.

Oh, there is an error in my code. Sorry for that! Maybe try this way:

Old:

 return '<div class="captcha">' .
     $captcha->getForm() .
     "</div>\n";

New:

 global $wgOut;
 return '<div class="captcha">' .
     $captcha->getForm( $wgOut ) .
     "</div>\n";
EFFemeer (talkcontribs)

This works fine apart from the fact that the captcha rectangle isn't shown automatically. In other words, upon first access of the contactpage one only gets the text CAPTCHA without the image. The user has to refresh the page to get the image displayed.

http://drebbel.net/wiki/Special:Contact

Florianschmidtwelzow (talkcontribs)

It does appear when I open the page the first time, at least for me :)

Btw.: This should be fixed in the ContactPage extension directly, editing the code of ConfirmEdit isn't the solution you want ;) See phabricator:T123222.

EFFemeer (talkcontribs)

Thanks for helping me out, Florian.

This morning it did appear for me also. But after a login - logout sequence it doesn't anymore. Probably a problem with caching?

Let's wait and see what the extension update will do.