With a form set to captcha only I get "The website encountered an unexpected error. Please try again later." when trying to display the comment form.

The log shows:

LogicException: Form state caching on GET requests is not allowed. in Drupal\Core\Form\FormState->setCached() (line 494 of /home/ross/devel/d8test/www/core/lib/Drupal/Core/Form/FormState.php).

I may not understand the full implications but I guess you shouldn't cache a GET request containing a form because of the CSRF token among other things.

I solved this in Element/Mollom.php by removing this at line 298:

$form_state->setCached(TRUE);

I'm happy to create but I though I'd see if there are any more correct solutions first.

Comments

tetranz created an issue. See original summary.

eshta’s picture

Yes - this ability was recently removed in Drupal core. The reason this was necessary for Mollom in the past had to do with the way that Captchas are managed across the form request life. The result is that we need to update the Captchas to work with AJAX callbacks when requesting a new captcha or changing from visual to audio. I'm currently in the process of working through this - but am happy to incorporate the work of others if you'd like to take a stab at it.

eshta’s picture

Status: Active » Closed (duplicate)
Related issues: +#2527756: D8: Convert refresh captcha ajax to remove setCached().

This is actually a duplicate of an existing issue so closing in favor of keeping things all in one place.
https://www.drupal.org/node/2527756