Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
C
Core
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 979
    • Issues 979
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • Core
  • Issues
  • #2302

Closed
Open
Opened Jan 15, 2021 by ddsystems@ddsystems

Recaptcha causing contribution forms to fail due to duplicate recaptcha submission.

I’ve tracked down the captcha issue on the contribution form, it is related to the fact that the recaptcha rules are being set twice, so the first one succeed, but the second one fails. What I’ve found is in this file:

./wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Contribution/Main.php starting at line 284 $this->buildCustom($this->_values['custom_pre_id'], 'customPre'); $this->buildCustom($this->_values['custom_post_id'], 'customPost');

These functions reference the buildCustom function found in: ./wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/ContributionBase.php at line 612

At the bottom of this function (around line 766) there is the following logic

if ($addCaptcha && !$viewOnly) { $this->enableCaptchaOnForm(); }

The function this references is just a few lines below this call.

Since Civicrm seems to store the rules in a non-associative array you can have multiple rules with the same name, and it ends up checking each one of them, and due to the nature of recaptcha, a validation is only good once, so when it tries to validate the second time it will inevitably fail and throw the captcha error.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: dev/core#2302