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.
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff3061280.txt | 1.84 KB | eiriksm |
#14 | 3061280-14.patch | 5.78 KB | eiriksm |
#10 | 3061280-10.patch | 6.04 KB | eiriksm |
| |||
#10 | 3061280-10-test-only.patch | 4.45 KB | eiriksm |
Comments
Comment #2
eiriksmJust trying to prove it in a test for now
Comment #3
eiriksmForgot to add the actual assertions :(
Did not have time to run it locally again, so let's see if it fails as expected.
Comment #5
eiriksmRushing patches before leaving the sprint makes for bad titles I guess. Updating accordingly. :)
Also, the patch did not really prove anything, it would have failed anyway. Here are two patches: One that is expected to fail (proves the bug). One that is expected to pass (also proves the bug, since it shows you have to clear the caches to get the expected output).
I will split it into its own test class once I can actually prove it with a test :p
Comment #7
eiriksmSo here is a patch that invalidates caches on entity save of price list items. In theory, we should probably invalidate all products in a price list on price list entity saves as well, since that could for example change their "active" state (or condition, or date, or whatever). But this fixes the issue in question at least.
Comment #10
eiriksmComment #12
bojanz CreditAttribution: bojanz at Centarro commented1. Drupal core tends to invalidate caches in postSave(). Any reason why we can't do the same? Would simplify this code.
2. Instead of the method_exists() call could we check $purchasable_entity->getEntityTypeId()? Seems cleaner.
3. As a Commerce followup it would probably make sense to have $variation->getCacheTags() start returning the product cache tags as well, removing the need for this workaround here.
Comment #13
mglamanhttps://git.drupalcode.org/project/commerce/blob/8.x-2.x/modules/product...
We should assert getPurchasableEntity is an instance of \Drupal\commerce\PurchasableEntityInterface and then we can get cache tags.
Comment #14
eiriksmAwesome review, thanks!
Re 12:
1. Moved to ::postSave (good call).
2 and 3 are fixed by Matts suggestion,
Comment #15
eiriksmSorry, posted the same patch twice, meant to post the interdiff
Comment #16
eiriksmComment #17
bojanz CreditAttribution: bojanz at Centarro commentedThat postSave can be a lot simpler, by calling the parent only once, on top of the method. And we should keep the variable as $purchasable_entity, there's no need to assume it's a variation.
We can do something like this:
PriceListProductCacheTest can be just ProductCacheTest.
Should be just $variation, since we don't have two.
None of this is true :)
Comment #19
bojanz CreditAttribution: bojanz at Centarro commentedAddressed #17 and committed. Thanks!