A Drupal core change #2429617: Make D8 2x as fast: Dynamic Page Cache: context-dependent page caching (for *all* users!) broke some of our tests:

Drupal\uc_cart\Tests\CartCheckoutTest
Drupal\uc_cart_links\Tests\CartLinksTest
Drupal\uc_payment_pack\Tests\PaymentPackTest
Drupal\uc_product_kit\Tests\ProductKitTest

Leaving this open as a tracking issue until we figure out how to address this core change.

Comments

TR created an issue. See original summary.

longwave’s picture

I did make a start on this but don't have a fully working patch yet. We need to add cache tags and contexts to our cart output. As a stopgap we could disable caching entirely for the cart and checkout pages and then incrementally improve this, though we really need to at least allow the cart block to be cached correctly.

We also should add further tests to ensure the output is cached correctly and that users cannot see other user's cached carts etc.

  • longwave committed 2853ed7 on 8.x-4.x
    Issue #2567549: Add cacheable dependencies to cart.
    
longwave’s picture

Useful documentation is at https://www.drupal.org/developing/api/8/render/arrays/cacheability and https://www.drupal.org/developing/api/8/cache

I think I've correctly added the necessary contexts and tags to the cart pages in http://cgit.drupalcode.org/ubercart/commit/?id=2853ed7

longwave’s picture

I think we also need getCacheContexts() and getCacheTags() methods adding to CartBlock, along with some tests.

longwave’s picture

Title: Tests broken by core change » Tests broken by core Dynamic Page Cache introduction

  • longwave committed 740f8b8 on 8.x-4.x
    Issue #2567549: Disable caching for the checkout form.
    
  • longwave committed 8f55173 on 8.x-4.x
    Issue #2567549: Invalidate order entity cache after a payment is...
longwave’s picture

I pushed some more fixes for the remaining failures. The checkout form has a lot of dependencies and I couldn't figure out how to cache it safely so it is marked to never be cached; I think this is good enough for now.

The catalog test failure turned out to be unrelated to the dynamic page cache and is actually a consequence of #2492839: Views replacement token bc layer allows for Twig template injection via arguments.

longwave’s picture

Status: Active » Fixed

Tests are running green again.

Status: Fixed » Closed (fixed)

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