Please could we have a way to avoid having to repeatedly do captchas during multiple previews of comments? Either the captcha could be necessary on the first completion of the comment form and not thereafter, or the Preview button could not require validation of the captcha (or both, I guess).

CommentFileSizeAuthor
#10 previewing_2.patch1.97 KBsoxofaan
#8 previewing.patch1.97 KBsoxofaan

Comments

Paul Natsuo Kishimoto’s picture

Version: 5.x-2.2 » 5.x-3.x-dev

I just installed 5.x-3.x-dev, and it seems this is still relevant after the rewrite. The correct response to the first captcha reappears in the text field, but a new captcha (image_captcha) is displayed with the preview. The user is forced to correctly answer the second captcha as well in order to post their comment.

Blogger also has this behaviour and I find it highly annoying. It would be great if it could be avoided in Drupal.

wundo’s picture

Priority: Normal » Critical
bryansd’s picture

+1 on this idea. Have a number of users at my site (ie http://cmsreport.com/node/1087#comment-2196 ) complaining at the end of their comments about perceived problems with captcha. Overall though...version 3 is still a big plus over previous versions.

soxofaan’s picture

I looked into this problem and it seems difficult to solve it in a clean way (not adding to much extra code that polutes the current code).

I found a hackish but contained workaround however. The idea is to solve the captcha and hide it with CSS when the comment is previewed. For those who are interested:

  • look for the function captcha_pre_render($form_id, $form) in captcha.module, change this signature to function captcha_pre_render($form_id, &$form) { (add prefix & to $form)
  • add this to the end of the function body:
      // Workaround for removing the captcha on comment forms after preview:
      // solve the captcha and hide it
      if (!form_get_errors() && $form_id == 'comment_form' && $_POST['form_id'] == 'comment_form' && $_POST['op'] == t('Preview comment')) {
        // put the captcha solution in the captcha_answer field
        $form['captcha']['captcha_answer']['#value'] = $form['captcha']['captcha_solution']['#value'];
        // hide the captcha form element with css
        $form['captcha']['#attributes'] = array('style' => 'display: none;');
      } 

    I won't supply this as patch, because I think this code should not make it in the official branch.

soxofaan’s picture

Priority: Critical » Normal

Please could we have a way to avoid having to repeatedly do captchas during multiple previews of comments?

There is already a way to do this: disable the 'Persistent captchas' option on the captcha settings page. As the description of this option says:

If checked, the user will always have to solve a captcha. If not checked, the captcha check for a form will be omitted during the rest of the session once the user has successfully solved a captcha for that form.

I think this makes this issue not 'critical' anymore.

soxofaan’s picture

The correct response to the first captcha reappears in the text field, but a new captcha (image_captcha) is displayed with the preview.

The patch from issue http://drupal.org/node/165530 should make this better (it empties the captcha text field).

The user is forced to correctly answer the second captcha as well in order to post their comment. Blogger also has this behaviour and I find it highly annoying.

What do you find annoying? That a new captcha is generated (you want the same captcha challenge for each preview)? Or that there you have to solve a captcha on each preview/submit?
In the latter case: disable the 'persistent captchas' option, see #5 (http://drupal.org/node/156503#comment-285563)

Paul Natsuo Kishimoto’s picture

#5 … There is already a way to do this: disable the 'Persistent captchas' option on the captcha settings page.

... only this doesn't have the intended effect. To be explicit: when 'Persistent captchas' is off, the captchas do disappear, for both authenticated and anonymous users, once a form has been submitted. If both the 'Preview comment' and 'Post comment' buttons are available, correctly solving the captcha and clicking 'Post comments' results in no captcha being shown when adding subsequent comments. This is as it should be.

However, if the 'Post comment' button is not available, or a user elects to click 'Preview comment', then—because the form has not been 'fully' submitted, or for some other reason—a new captcha appears with the preview, even if the first one was answered correctly. This is contrary to the description of the 'Persistent captchas' option.

Hopefully that clarifies the source of 'annoyance' vis-a-vis #6. If a visitor to my site correctly solves one captcha, I do not want to penalize careful editing and forcing him or her to repeatedly solve new captchas on each preview. I agree that this issue is non-critical, but it remains unfixed.

soxofaan’s picture

StatusFileSize
new1.97 KB

However, if the 'Post comment' button is not available, or a user elects to click 'Preview comment', then—because the form has not been 'fully' submitted, or for some other reason—a new captcha appears with the preview, even if the first one was answered correctly. This is contrary to the description of the 'Persistent captchas' option.

Thanks for this clarification. I made a patch that should solve this issue of persistence+previewing. Now "non-persistence" works with previewing of comments and nodes.

The problem with previewing is that new form is generated *before* the submission and captcha are validated. Consequently a captcha is added to the new form even if the captcha from the previous form was correctly answered. With this patch, the captcha is removed again in the pre_render phase (which happens *after* validation). This only happens when persistence is off of course.

soxofaan’s picture

Status: Active » Needs review
soxofaan’s picture

StatusFileSize
new1.97 KB

I updated the patch from #8 (http://drupal.org/node/156503#comment-285642)
to make it against captcha.module version 1.42.2.15

Paul Natsuo Kishimoto’s picture

Status: Needs review » Reviewed & tested by the community

Applied the patch and Captcha now works as advertised; setting RTBC. Thanks for the quick fix, soxofaan!

wundo’s picture

Status: Reviewed & tested by the community » Fixed

Thanks,
Committed!
:)

Anonymous’s picture

Status: Fixed » Closed (fixed)