Problem/Motivation

Ajax forms (e.g. product attributes in on the commerce add-to-cart form) do not work properly for anonymous users. After the form was submitted for the first time, every subsequent attempt of any other user to reuse the form fails.

Authenticated users are not affected by this problem. Authcache Form has a mechanism built-in capable of cloning the form cache entries required by Ajax forms for authenticated users (see #1946022: Problem with ajax forms for more details).

Proposed resolution

The simplest way to resolve this problem would be to also allow cloning of form cache entries for anonymous users. However this will likely increase the form cache table even further. Also this problem only affects Ajax-enabled forms and therefore this is only a problem for clients having JavaScript enabled. Therefore a better approach would be to try and tap into the Ajax framework and only clone form cache entries when necessary (e.g. only during the first form-related Ajax request). This has the benefit that no work is done unless the user triggers a callback.

Remaining tasks

  • Implementation
  • Tests

User interface changes

None.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

znerol’s picture

Status: Active » Needs review
FileSize
11.29 KB

Sorry for the delay. This turned out to be a security issue in Drupal core. Version 7.27 is going to be published in this minutes, let's see whether tests pass for the corresponding authcache patch.

Note that Cache Object API will be required in an upcoming release, otherwise pages with ajax forms will not be cached for authenticated users.

  • Commit a1a69cb on 7.x-2.x by znerol:
    Issue #2171129 by znerol: Update for Drupal 7.27 (SA-CORE-2014-002)
    

Status: Needs review » Needs work

The last submitted patch, 1: 2171129-ajax-not-working-for-anonymous-users.diff, failed testing.

znerol’s picture

Status: Needs work » Fixed

Fixed.

Status: Fixed » Closed (fixed)

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

RAWDESK’s picture

I am not running Authcache on my site, but having a similar symptom as described in this issue's title.

To make it clear, i've captured the scenario in this short video :
http://castabo.rawdesk.be/temp/uc-ajax-first-request-not-executed-for-an...

As can be seen, the first AJAX request to my pricing component returns without a (visible) result.
PS. The colour option has no price change defined.
If i execute this scenerio with a logged in user (any role will do), the first request is always successful.

Any idea what might cause this ?

znerol’s picture

Please try the issue tracker of the commerce package you are using (Drupal Commerce, Ubercart).

Thanks.

RAWDESK’s picture

Thanks for the referal.
Posted the issue in this thread : https://www.drupal.org/node/1380772#comment-9307151