spree
spree copied to clipboard
Fix caching issues with nested models
Due to a Rails bug (https://github.com/rails/rails/issues/26726), cache is not correctly invalidated when updating child models. For example, if updating a product price in admin, the variant and product updated_at is not touch-ed, but should be. Fix by not using TouchLater.
Basically, explained on example, if we update 2 Variants at the same time, without TouchLater, the Product will be touched twice. With TouchLater, it would be only touched once. I think in the case of Spree, we don't have a case where we are updating many (hundreds) of child models at once, so TouchLater would have little performance gain. Besides, it does not work correctly, so we can just turn it off until it's fixed.
Better fix for: https://github.com/spree/spree/pull/11621
Also, after admittedly nagging a bit about https://github.com/rails/rails/issues/26726 I managed to duke this thing out with rafaelfranca and it seems like he found the solution to this bug in Rails. See https://github.com/rails/rails/issues/26726#issuecomment-1320435118 He said that should land in Rails early next week. So with that, if Spree can support the latest Rails version, this issue should be fixed without the need for a patch!
@mrbrdo as we support Rails 7, I'm closing this, thanks!