Problem/Motivation

Google's NoCAPTCHA ReCAPTCHA failed to verify even though everything was correct on the front end. Upon further investigation, the error returned by Google is missing-input-response. The issue is caused by the call to http_build_query on line 101 of RequestParameters.php. The default argument separator is the one specified by the PHP ini directive: arg_separator.output. PHP's default is & but Drupal's is &. When using the & separator, the verification querystring becomes something similar to ...../?blah&response= which submits a parameter called amp;response to Google instead of response.

Drupal sets arg_separator.output in settings.php to &. If you change this to &, everything works fine.

Proposed resolution

Change return http_build_query($this->toArray()); to return http_build_query($this->toArray(), null, '&'); to force using the correct argument separator, since it doesn't really make sense to use an argument separator other than &.

Comments

spadusa’s picture

Issue summary: View changes
hass’s picture

WTF is this? Why does Drupal change this? We can do a quick fix here, but we need to fix this in the lib...

How can I repro the issue? Until now I have not seen any fail in over 100 tests.

hass’s picture

Status: Active » Postponed (maintainer needs more info)

It looks like this ini sets have been removed over 6 years ago from settings.php, see #303154: Document ini_set() calls in default.settings.php.

How old is your settings.php? You may like to cleanup your setting.php and the issue is solved.

We should document this as a known issue in readme.txt.

hass’s picture

After some investigation on D5/D6 code I can confirm that arg_separator.output is set there as you reported. I cannot find it in D7 as Dries removed it in the linked case. It was also not moved into .htaccess. I also checked all my sites and found one site that was upgraded from D6 to D7 that still has these directives set in settings.php. Another site has not.

Moving forward, I will add a check to hook_requirement and link the case and tell users to remove the complete ini_set() code block if it is still there.

Replace the following code in settings.php (settings still required by D7 are set in .htaccess just as a note):

/**
 * PHP settings:
 *
 * To see what PHP settings are possible, including whether they can
 * be set at runtime (ie., when ini_set() occurs), read the PHP
 * documentation at http://www.php.net/manual/en/ini.php#ini.list
 * and take a look at the .htaccess file to see which non-runtime
 * settings are used there. Settings defined here should not be
 * duplicated there so as to avoid conflict issues.
 */
ini_set('arg_separator.output',     '&');
ini_set('magic_quotes_runtime',     0);
ini_set('magic_quotes_sybase',      0);
ini_set('session.cache_expire',     200000);
ini_set('session.cache_limiter',    'none');
ini_set('session.cookie_lifetime',  2000000);
ini_set('session.gc_maxlifetime',   200000);
ini_set('session.save_handler',     'user');
ini_set('session.use_only_cookies', 1);
ini_set('session.use_trans_sid',    0);
ini_set('url_rewriter.tags',        '');

with this code and you have a D7 settings.php

/**
 * PHP settings:
 *
 * To see what PHP settings are possible, including whether they can be set at
 * runtime (by using ini_set()), read the PHP documentation:
 * http://www.php.net/manual/en/ini.list.php
 * See drupal_initialize_variables() in includes/bootstrap.inc for required
 * runtime settings and the .htaccess file for non-runtime settings. Settings
 * defined there should not be duplicated here so as to avoid conflict issues.
 */

/**
 * Some distributions of Linux (most notably Debian) ship their PHP
 * installations with garbage collection (gc) disabled. Since Drupal depends on
 * PHP's garbage collection for clearing sessions, ensure that garbage
 * collection occurs by using the most common settings.
 */
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 100);

/**
 * Set session lifetime (in seconds), i.e. the time from the user's last visit
 * to the active session may be deleted by the session garbage collector. When
 * a session is deleted, authenticated users are logged out, and the contents
 * of the user's $_SESSION variable is discarded.
 */
ini_set('session.gc_maxlifetime', 200000);

/**
 * Set session cookie lifetime (in seconds), i.e. the time from the session is
 * created to the cookie expires, i.e. when the browser is expected to discard
 * the cookie. The value 0 means "until the browser is closed".
 */
ini_set('session.cookie_lifetime', 2000000);

Thank you very much for reporting this issue.

hass’s picture

Version: 7.x-2.0-beta1 » 7.x-2.x-dev
Category: Bug report » Feature request
Status: Postponed (maintainer needs more info) » Active

It's not a bug, it's a feature... :-(

hass’s picture

  • hass committed c660397 on 7.x-2.x
    Issue #2476057 by hass, spadusa: reCaptcha Verification fails when...
hass’s picture

Status: Active » Fixed

  • hass committed c660397 on 6.x-2.x
    Issue #2476057 by hass, spadusa: reCaptcha Verification fails when...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

zach.bimson’s picture

I ran into this issue when pushing code to pantheon, my local was set up and was working (i assume due to the settings file config) yet when i pushed, it was breaking.. i implemented the proposed solution and it works perfectly.

Can we get this committed ? shall i make a quick patch ?

drupal-son’s picture

Same issue.
I'm running the site on Pantheon.
I can't change the php.ini.
My settings.php there isn't any of those lines.
Adding ini_set('arg_separator.output', '&'); to my settings.php solve the issue.

Thanks.

martini9011’s picture

Created a patch for the 2.0 version of the module since I am unable to switch to dev at the moment, might be handy for anyone else with this same case.

The patch contains the proposed resolution by spadusa, and as confirmed in #11 works correctly.

issa.haddadin’s picture

Category: Feature request » Bug report
Status: Closed (fixed) » Active

I'm still facing the same problem, it is still happening on the dev version or using the stable version with comment #13 patch.

hass’s picture

Category: Bug report » Feature request
Status: Active » Closed (fixed)
  1. Patch in #13 is not supported.
  2. Configure your setting.php and documented in the documenation
  3. or run latest DEV.