Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
In #2702423: Commerce Add to Cart Form ajax and ESI / Varnish fails a change has been made that makes it possible to have different expire values in {cache_form} for $form an $form_state. This is obviously bad:
- If we have only $form_state but no $form in {cache_form} then we simply get an "Invalid form POST data" from ajax_get_form(). (Note that this is the case if the $form and $form_state cache_form entries expire at the same time, so it's not a big deal.)
- The bigger problem occurs if we have only $form but no $form_state. In this case some contrib modules might unexpectedly break (e.g. the add to cart form AJAX), see commerce_cart_add_to_cart_form_validate().
Proposed resolution
Enforce equal expire timestamps for $form and $form_state in cache_form.
Comment | File | Size | Author |
---|---|---|---|
#7 | authcache-2825813-7-cache_form_expiry.patch | 7.13 KB | znerol |
#7 | 2825813-7-TEST-ONLY.patch | 6.44 KB | znerol |
#5 | 2825813-4-TEST-ONLY.patch | 5.14 KB | znerol |
#2 | authcache-2825813-2-cache_form_expiry.patch | 710 bytes | czigor |
Comments
Comment #2
czigor CreditAttribution: czigor at Liip for FREITAG lab. AG commentedComment #3
czigor CreditAttribution: czigor at Liip for FREITAG lab. AG commentedIncreasing priority as this is actually breaking ajax forms.
Comment #4
znerol CreditAttribution: znerol commentedThanks for reporting this problem and for providing a patch, and sorry for the late answer (was AFK for a looong time).
This is definitely a very ugly problem. I will try to come up with some test-cases in order to lower the risk of more screw-ups in the future :/
Comment #5
znerol CreditAttribution: znerol commentedSimple test case. I'd like to add another test for forms which were rebuilt (i.e., forms without the immutable flag). I'd like to ensure that on those cache entries the expiry time is not increased.
Comment #7
znerol CreditAttribution: znerol commentedComment #13
znerol CreditAttribution: znerol commentedThanks @czigor for reporting the issue and submitting a patch.
Comment #15
ordermind CreditAttribution: ordermind commentedI'm still seeing the problem even with the patch applied, so I'd like this issue to be reopened.
Comment #16
znerol CreditAttribution: znerol commented@ordermind please do not comment on closed issue. Instead open a new support request describing the problem and the steps to reproduce.
For the record, this patch has been included into 7.x-2.1 a year ago. Please upgrade your installation to at least that version.