Found when reviewing #2835629: Allow altering the default variation.
We call ProductInterface::getDefaultVariation in several places. Each time we loop through the product's variations and pick the first variation that is published and accessible. After the first check we already have the variations in the storage's static cache and should have access check static cache available.
This is probably a micro-optimization as the entity type manager has a static cache of handlers, the access checks are in the static cache, along with the previously loaded variations.
But it wouldn't hurt to explore.
Comments
Comment #2
mglamanDiscussed with rszrama. We should use a
defaultVariationproperty on the product class. If we usedstaticinside of the method, it would be used across instances 😱.Comment #3
mglamanHere's a patch. Property documentation to be bikeshedded. First, I want to see if this breaks anything.
Comment #5
mglamanTest failures are due to #3135949: Inline Entity Form rc4+ causing test regressions
Comment #6
mglamanIEF fixed
Comment #8
mglamanCommitted, so we now we can just fetch from the property after the first check.