CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • 500 error when reCAPTCHA enabled in profile
Pages: [1]

Author Topic: 500 error when reCAPTCHA enabled in profile  (Read 2348 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
500 error when reCAPTCHA enabled in profile
January 27, 2011, 02:38:45 am
I am using a profile for online event registration. When I enable reCAPTCHA in the profile, the server throws a 500 error when I visit the online registration page. The Apache error log contains ...

Code: [Select]
PHP Fatal error:  Cannot redeclare _recaptcha_qsencode() (previously declared in /var/www/citybibleforum/sites/all/modules/civicrm/packages/recaptcha/recaptchalib.php:47) in /var/www/citybibleforum/sites/all/modules/recaptcha/recaptcha/recaptchalib.php on line 55, referer: https://www.citybibleforum.org/civicrm/event/info?id=546&reset=1
I'm assuming that the reCAPTCHA package in CiviCRM is not playing nice with the Drupal reCAPTCHA module.

I could disable the Drupal reCAPTCHA module, but it would be nice to not have to.

Does anyone have any thoughts?

Ken

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: 500 error when reCAPTCHA enabled in profile
January 27, 2011, 08:01:31 am

you'll need to modify both civicrm's recaptcha code AND the recaptcha modules code to not include the recapatcha lib if already included

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: 500 error when reCAPTCHA enabled in profile
January 29, 2011, 01:31:31 am
Lobo,

I'm not a PHP programmer. Would ...

Code: [Select]
if ( ! function_exists( '_recaptcha_qsencode' ) ) {
    require_once '.../recaptchalib.php';
}

... do the trick?

I guess another option would be to change line 82 of CRM/Utils/reCAPTCHA.php as follows ...

Code: [Select]
         $error  = null;
         $config = CRM_Core_Config::singleton( );
         $useSSL = false;
-        require_once 'packages/recaptcha/recaptchalib.php';
+        module_load_include('php', 'recaptcha', 'recaptcha/recaptchalib');

       
         // See if we are using SSL
         if ( isset( $_SERVER['HTTPS'] ) &&

... so that the CiviCRM and reCAPTCHA modules both use the same library. (The differences between the libraries are only cosmetic.)

Ken

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: 500 error when reCAPTCHA enabled in profile
January 29, 2011, 06:36:09 am

yes option 1 is the preferred option. u'll need to do it for both civicrm and recaptcha modules since the order in which they are loaded differs in different sites

option 2 will not work in joomla/wordpress and in installs where recaptcha module is not installed

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

shayaknyc

  • I post occasionally
  • **
  • Posts: 74
  • Karma: 0
Re: 500 error when reCAPTCHA enabled in profile
August 23, 2012, 11:10:46 am
Quote from: ken on January 29, 2011, 01:31:31 am

Code: [Select]
if ( ! function_exists( '_recaptcha_qsencode' ) ) {
    require_once '.../recaptchalib.php';
}

... do the trick?

I'm having the same issue with Civi 4.2 installed on a Wordpress Site (3.4.1). Where would I implement the code above so that I don't have conflicting errors? I'd really like to include a reCaptcha for a profile sign-up but I also use a reCaptcha plugin for Wordpress. Where would this code go? On the page that I want to implement the profile sign-up with recaptcha on it?

Thanks!

--shayaknyc

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • 500 error when reCAPTCHA enabled in profile

This forum was archived on 2017-11-26.