In ::getDefaultVariation we check if the variation is active, but not if the user has access.

    foreach ($this->getVariations() as $variation) {
      // Return the first active variation.
      if ($variation->isActive()) {
        return $variation;
      }
    }

Incoming patch to add check.

CommentFileSizeAuthor
#6 2826485-6.patch637 bytescasey
#2 2826485-2.patch593 bytesmglaman

Comments

mglaman created an issue. See original summary.

mglaman’s picture

Status: Active » Needs review
StatusFileSize
new593 bytes

Make sure that the default variation is active and user has access.

  • bojanz committed 8c2aa63 on 8.x-2.x authored by mglaman
    Issue #2826485 by mglaman: Product::getDefaultVariation does not check...
bojanz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

casey’s picture

StatusFileSize
new637 bytes

This seems to introduce recursion errors; the ProductVariationAccessControlHandler uses ProductVariationInterface::getProduct() which calls ComputedDefaultVariation::computeValue() which calls ProductInterface::getDefaultVariation(). This happens when the product is not yet cached via ContentEntityStorageBase::setPersistentCache(). If the user has no admin permissions, the access('view') call will be recursive.

Attached a patch to test without access check.