We need to make sure ProductVariationContext properly implements ContextProviderInterface and doesn't return a populated context value in getAvailableContexts


Original summary

Dummy orphans paragraphs are generated when adding a product

We have discovered that dummy orphans paragraphs are generated from this class whenever visiting the page for adding a new product ex "product/add/my_product": "modules/contrib/commerce/modules/product/src/ContextProvider/ProductVariationContext.php".
$value = $this->productVariationStorage->createWithSampleValues($product_type->getVariationTypeId());

Could you please let me know what purpose this class has?

Backtrace

  "69: call_user_func_array()" => array:1 [▶]
  "68: Drupal\Core\Extension\ModuleHandler->invokeAll()" => array:2 [▶]
  "67: Drupal\Core\Entity\EntityStorageBase->invokeHook()" => array:2 [▶]
  "66: Drupal\Core\Entity\ContentEntityStorageBase->invokeHook()" => array:2 [▶]
  "65: Drupal\Core\Entity\EntityStorageBase->doPostSave()" => array:2 [▶]
  "64: Drupal\Core\Entity\ContentEntityStorageBase->doPostSave()" => array:2 [▶]
  "63: Drupal\Core\Entity\EntityStorageBase->save()" => array:2 [▶]
  "62: Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()" => array:2 [▶]
  "61: Drupal\Core\Entity\EntityBase->save()" => array:1 [▶]
  "60: Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem::generateSampleValue()" => array:2 [▶]
  "59: Drupal\Core\Field\FieldItemList->generateSampleItems()" => array:1 [▶]
  "58: Drupal\Core\Entity\ContentEntityStorageBase->createWithSampleValues()" => array:2 [▶]
  "57: Drupal\commerce_product\ContextProvider\ProductVariationContext->getRuntimeContexts()" => array:2 [▼
    "file" => "modules/contrib/commerce/modules/product/src/ContextProvider/ProductVariationContext.php:68"
    "args" => array:1 [▶]
  ]
  "56: Drupal\commerce_product\ContextProvider\ProductVariationContext->getAvailableContexts()" => array:1 [▼
    "file" => "modules/contrib/commerce/modules/product/src/ContextProvider/ProductVariationContext.php:108"
  ]
  "55: Drupal\Core\Plugin\Context\LazyContextRepository->getAvailableContexts()" => array:1 [▼
    "file" => "core/lib/Drupal/Core/Plugin/Context/LazyContextRepository.php:97"
  ]
  "54: Drupal\Core\ParamConverter\EntityConverter->convert()" => array:2 [▼
    "file" => "core/lib/Drupal/Core/ParamConverter/EntityConverter.php:137"
    "args" => array:4 [▶]
  ]
  "53: Drupal\Core\ParamConverter\ParamConverterManager->convert()" => array:2 [▶]
  "52: Drupal\Core\Routing\Enhancer\ParamConversionEnhancer->enhance()" => array:2 [▶]
  "51: Drupal\Core\Routing\Router->applyRouteEnhancers()" => array:2 [▶]
  "50: Drupal\Core\Routing\Router->matchRequest()" => array:2 [▶]
  "49: Drupal\Core\Routing\AccessAwareRouter->matchRequest()" => array:2 [▶]
  "48: Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->getRequestForPath()" => array:2 [▶]
  "47: Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->setRouteContextFromRouteMatch()" => array:2 [▶]
  "46: Drupal\easy_breadcrumb\EasyBreadcrumbBuilder->build()" => array:2 [▶]
  "45: Drupal\Core\Breadcrumb\BreadcrumbManager->build()" => array:2 [▶]
  "44: Drupal\system\Plugin\Block\SystemBreadcrumbBlock->build()" => array:1 [▶]
  "43: Drupal\block\BlockViewBuilder::preRender()" => array:2 [▶]
  "42: call_user_func_array()" => array:1 [▶]
  "41: Drupal\Core\Render\Renderer->doTrustedCallback()" => array:2 [▶]
  "40: Drupal\Core\Render\Renderer->doCallback()" => array:2 [▶]
  "39: Drupal\Core\Render\Renderer->doRender()" => array:2 [▶]
  "38: Drupal\Core\Render\Renderer->doRender()" => array:2 [▶]
  "37: Drupal\Core\Render\Renderer->render()" => array:2 [▶]
  "36: Drupal\Core\Template\TwigExtension->escapeFilter()" => array:2 [▶]
  "35: __TwigTemplate_fc9a7a0fd32477138130107a3402b8fc3d20ad5942e433f078f6542c4f355847->doDisplay()" => array:2 [▶]
  "34: Twig\Template->displayWithErrorHandling()" => array:2 [▶]
  "33: Twig\Template->display()" => array:2 [▶]
  "32: Twig\Template->render()" => array:2 [▶]
  "31: twig_render_template()" => array:2 [▶]
  "30: Drupal\Core\Theme\ThemeManager->render()" => array:2 [▶]
  "29: Drupal\Core\Render\Renderer->doRender()" => array:2 [▶]
  "28: Drupal\Core\Render\Renderer->render()" => array:2 [▶]
  "27: Drupal\Core\Template\TwigExtension->escapeFilter()" => array:2 [▶]
  "26: __TwigTemplate_9344828e5a1144cf2a4a5b4597d4abfc38a6b9311b6adbae0902880d49e082fc->doDisplay()" => array:2 [▶]
  "25: Twig\Template->displayWithErrorHandling()" => array:2 [▶]
  "24: Twig\Template->display()" => array:2 [▶]
  "23: Twig\Template->render()" => array:2 [▶]
  "22: twig_render_template()" => array:2 [▶]
  "21: Drupal\Core\Theme\ThemeManager->render()" => array:2 [▶]
  "20: Drupal\Core\Render\Renderer->doRender()" => array:2 [▶]
  "19: Drupal\Core\Render\Renderer->render()" => array:2 [▶]
  "18: Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()" => array:1 [▶]
  "17: Drupal\Core\Render\Renderer->executeInRenderContext()" => array:2 [▶]
  "16: Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()" => array:2 [▶]
  "15: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()" => array:2 [▶]
  "14: call_user_func()" => array:1 [▶]
  "13: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()" => array:2 [▶]
  "12: Symfony\Component\HttpKernel\HttpKernel->handleRaw()" => array:2 [▶]
  "11: Symfony\Component\HttpKernel\HttpKernel->handle()" => array:2 [▶]
  "10: Drupal\Core\StackMiddleware\Session->handle()" => array:2 [▶]
  " 9: Drupal\Core\StackMiddleware\KernelPreHandle->handle()" => array:2 [▶]
  " 8: Drupal\page_cache\StackMiddleware\PageCache->pass()" => array:2 [▶]
  " 7: Drupal\page_cache\StackMiddleware\PageCache->handle()" => array:2 [▶]
  " 6: Drupal\ban\BanMiddleware->handle()" => array:2 [▶]
  " 5: Drupal\shield\ShieldMiddleware->handle()" => array:2 [▶]
  " 4: Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()" => array:2 [▶]
  " 3: Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()" => array:2 [▶]
  " 2: Stack\StackedHttpKernel->handle()" => array:2 [▶]
  " 1: Drupal\Core\DrupalKernel->handle()" => array:2 [▶]
  " 0: main()" => array:2 [▶]
]

If a bug, provide steps to reproduce it from a clean install.

@todo

Issue fork commerce-3220015

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lexsoft created an issue. See original summary.

jsacksick’s picture

jsacksick’s picture

Status: Closed (duplicate) » Active

Actually, going to reopen this as I'm not entirely sure this is a duplicate.

It looks like this code is kicking off even when Layout builder is not used...

mglaman’s picture

Version: 8.x-2.24 » 8.x-2.x-dev
Priority: Normal » Major

@jsacksick thanks for re-opening, this is a problem of its own.

We generated a sample variation for when using the Default Layout manager. This shouldn't be happening when adding a new product. Definitely a big bug.

Thanks for the backtrace, super helpful!

mglaman’s picture

Status: Active » Postponed (maintainer needs more info)

I wasn't able to reproduce on the latest 8.x-2.x. In the backtrace, I noticed Easy Breadcrumb builder. I wonder if #3200588: Core BreadcrumbBuilder might lead to fatal PHP error in ProductVariationContext fixed this.

Have you tried on the latest 2.x or only on 8.x-2.24?

mglaman’s picture

Title: Dummy orphans paragraphs are generated when adding a product » ProductVariationContext improperly implements ContextProviderInterface
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

The problem is that ContextProviderInterface is improperly implemented. ::getAvailableContexts always returns a populated context value, when it should be a stub.

mglaman’s picture

mglaman’s picture

Actually, I think this fix would be the proper fix for #3200588: Core BreadcrumbBuilder might lead to fatal PHP error in ProductVariationContext as well.

mglaman’s picture

Status: Active » Needs review
mglaman’s picture

mkalkbrenner’s picture

We'll test it after the weekend. Thanks for your work!

jsacksick’s picture

I'm confused, I don't get how reverting the commit that fixes #3200588: Core BreadcrumbBuilder might lead to fatal PHP error in ProductVariationContext could fix this bug, considering the fix in in dev only and the bug was originally reported against 2.24.

Additionally, the fix from from #3200588: Core BreadcrumbBuilder might lead to fatal PHP error in ProductVariationContext only ensures that even if the route parameter type isn't specified (which could be the case when the route is defined by a view for example), the logic doesn't crash.

I think support product IDS is "ok", considering how views defines its routes, otherwise that would require people using views to write a route subscriber that's altering the route.

lexsoft’s picture

In our case the context module https://www.drupal.org/project/context, where we had a context on product variations and whenever we were going to product variation display it was creating dummy paragraphs.

And with https://www.drupal.org/project/easy_breadcrumb we had a few field paragraphs in the variation and whenever visiting the add/product page dummy orphans paragraphs are generated.

We have applied patch 4 from here https://www.drupal.org/project/commerce/issues/3190799 and it seems the issue has stopped.

From our investigation, it seemed that anything connected to commerce that uses Drupal context new RequestContext(); will trigger modules/contrib/commerce/modules/product/src/ContextProvider/ProductVariationContext.php.

lexsoft’s picture

Backtrace for context contrib module:

"33: Drupal\Core\Entity\EntityStorageBase->save()" => array:2 [
    "file" => "core/lib/Drupal/Core/Entity/EntityStorageBase.php:460"
    "args" => array:1 [
      0 => Drupal\paragraph_blocks\Entity\ParagraphBlocksEntity {#1828}
    ]
  ]
  "32: Drupal\Core\Entity\Sql\SqlContentEntityStorage->save()" => array:2 [
    "file" => "core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:837"
    "args" => array:1 [
      0 => Drupal\paragraph_blocks\Entity\ParagraphBlocksEntity {#1828}
    ]
  ]
  "31: Drupal\Core\Entity\EntityBase->save()" => array:1 [
    "file" => "core/lib/Drupal/Core/Entity/EntityBase.php:395"
  ]
  "30: Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem::generateSampleValue()" => array:2 [
    "file" => "modules/contrib/entity_reference_revisions/src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php:527"
  ]
  "29: Drupal\Core\Field\FieldItemList->generateSampleItems()" => array:1 [
    "file" => "core/lib/Drupal/Core/Field/FieldItemList.php:253"
  ]
  "28: Drupal\Core\Entity\ContentEntityStorageBase->createWithSampleValues()" => array:2 [
    "file" => "core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:162"
    "args" => array:1 [
      0 => "assessment"
    ]
  ]
  "27: Drupal\commerce_product\ContextProvider\ProductRouteContext->getRuntimeContexts()" => array:2 [
    "file" => "modules/contrib/commerce/modules/product/src/ContextProvider/ProductRouteContext.php:62"
    "args" => array:1 [
      0 => array:1 [
        0 => "commerce_product"
      ]
    ]
  ]
  "26: Drupal\Core\Plugin\Context\LazyContextRepository->getRuntimeContexts()" => array:2 [
    "file" => "core/lib/Drupal/Core/Plugin/Context/LazyContextRepository.php:79"
    "args" => array:1 [
      0 => array:1 [
        0 => "@commerce_product.product_route_context:commerce_product"
      ]
    ]
  ]
  "25: Drupal\context\ContextManager->applyContexts()" => array:2 [
    "file" => "modules/contrib/context/src/ContextManager.php:321"
    "args" => array:1 [
      0 => Drupal\Core\Condition\ConditionPluginCollection {#4157
        #conditionContexts: []
        #manager: Drupal\Core\Condition\ConditionManager {#1092
          #cacheKey: "condition_plugins"
          #cacheTags: []
          #alterHook: "condition_info"
          #subdir: "Plugin/Condition"
          #moduleHandler: Drupal\Core\Extension\ModuleHandler {#1151}
          #defaults: []
          #pluginDefinitionAnnotationName: "Drupal\Core\Condition\Annotation\Condition"
          #pluginInterface: "Drupal\Core\Condition\ConditionInterface"
          #namespaces: ArrayObject {#3718}
          #additionalAnnotationNamespaces: []
          #discovery: Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator {#4197
            #derivers: array:11 [ …11]
            #decorated: Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery {#1093 …8}
          }
          #factory: Drupal\Core\Plugin\Factory\ContainerFactory {#1094
            #discovery: Drupal\Core\Condition\ConditionManager {#1092}
            #interface: "Drupal\Core\Condition\ConditionInterface"
          }
          #mapper: null
          #cacheBackend: Drupal\Core\Cache\ChainedFastBackend {#1809}
          #useCaches: true
          #stringTranslation: null
          +"_serviceId": "plugin.manager.condition"
        }
        #configurations: array:1 [
          "entity_bundle:commerce_product" => array:5 [
            "id" => "entity_bundle:commerce_product"
            "bundles" => array:6 [ …6]
            "negate" => false
            "uuid" => "984eae68-932d-4a6d-b176-1bb4581d0148"
            "context_mapping" => array:1 [ …1]
          ]
        ]
        #pluginKey: "id"
        #originalOrder: array:1 [
          "entity_bundle:commerce_product" => "entity_bundle:commerce_product"
        ]
        #pluginInstances: array:1 [
          "entity_bundle:commerce_product" => Drupal\ctools\Plugin\Condition\EntityBundle {#4159
            #entityTypeBundleInfo: Drupal\Core\Entity\EntityTypeBundleInfo {#3019 …8}
            #bundleOf: Drupal\Core\Entity\ContentEntityType {#2415 …42}
            #executableManager: Drupal\Core\Condition\ConditionManager {#1092}
            #context: []
            -contexts: []
            #pluginId: "entity_bundle:commerce_product"
            #pluginDefinition: array:7 [ …7]
            #configuration: array:5 [ …5]
            #typedDataManager: null
            #stringTranslation: null
            #_serviceIds: []
            #_entityStorages: []
          }
        ]
        #instanceIds: array:1 [
          "entity_bundle:commerce_product" => "entity_bundle:commerce_product"
        ]
        #_serviceIds: []
        #_entityStorages: []
      }
    ]
  ]
  "24: Drupal\context\ContextManager->evaluateContextConditions()" => array:2 [
    "file" => "modules/contrib/context/src/ContextManager.php:282"
    "args" => array:1 [
      0 => Drupal\context\Entity\Context {#1102
        #name: "products"
        #label: "products"
        #description: ""
        #group: "Layouts"
        #requireAllConditions: false
        #conditionsCollection: Drupal\Core\Condition\ConditionPluginCollection {#4157}
        #reactionsCollection: null
        #conditions: array:1 [
          "entity_bundle:commerce_product" => array:5 [
            "id" => "entity_bundle:commerce_product"
            "bundles" => array:6 [ …6]
            "negate" => false
            "uuid" => "984eae68-932d-4a6d-b176-1bb4581d0148"
            "context_mapping" => array:1 [ …1]
          ]
        ]
        #reactions: array:1 [
          "blocks" => array:5 [
            "blocks" => array:2 [ …2]
            "id" => "blocks"
            "saved" => false
            "uuid" => "19585cdc-d1e8-442d-8ca8-06def74386b5"
            "include_default_blocks" => 1
          ]
        ]
        #disabled: true
        #weight: 0
        #originalId: "products"
        #status: true
        #uuid: "23d028f1-a33c-40ff-a10e-69452c587e34"
        -isUninstalling: false
        #langcode: "en"
        #third_party_settings: []
        #_core: []
        #trustedData: false
        #entityTypeId: "context"
        #enforceIsNew: null
        #typedData: null
        #cacheContexts: array:1 [
          0 => "languages:language_interface"
        ]
        #cacheTags: []
        #cacheMaxAge: -1
        #_serviceIds: []
        #_entityStorages: []
        #dependencies: array:1 [
          "module" => array:1 [
            0 => "ctools"
          ]
        ]
        #isSyncing: false
      }
    ]
  ]
  "23: Drupal\context\ContextManager->evaluateContexts()" => array:1 [
    "file" => "modules/contrib/context/src/ContextManager.php:199"
  ]
  "22: Drupal\context\ContextManager->getActiveContexts()" => array:1 [
    "file" => "modules/contrib/context/src/ContextManager.php:187"
  ]
  "21: Drupal\context\ContextManager->getActiveReactions()" => array:1 [
    "file" => "modules/contrib/context/src/ContextManager.php:219"
  ]
  "20: Drupal\context\EventSubscriber\BlockPageDisplayVariantSubscriber->onSelectPageDisplayVariant()" => array:2 [
    "file" => "modules/contrib/context/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php:44"
    "args" => array:3 [
      0 => Drupal\Core\Render\PageDisplayVariantSelectionEvent {#1129
        #pluginId: "block_page"
        #pluginConfiguration: []
        #routeMatch: Drupal\Core\Routing\CurrentRouteMatch {#3670
          #requestStack: Symfony\Component\HttpFoundation\RequestStack {#4959
            -requests: array:2 [
              0 => Symfony\Component\HttpFoundation\Request {#8
                +attributes: Symfony\Component\HttpFoundation\ParameterBag {#11
                  #parameters: array:11 [
                    "_drupal_request_sanitized" => true
                    "_controller" => "\Drupal\field_ui\Controller\FieldConfigListController::listing"
                    "_title" => "Manage fields"
                    "entity_type_id" => "commerce_product"
                    "bundle" => "assessment"
                    "commerce_product_type" => Drupal\commerce_product\Entity\ProductType {#2910 …26}
                    "_route" => "entity.commerce_product.field_ui_fields"
                    "_route_object" => Symfony\Component\Routing\Route {#3899 …9}
                    "_raw_variables" => Symfony\Component\HttpFoundation\ParameterBag {#2916 …1}
                    "_access_result" => Drupal\Core\Access\AccessResultAllowed {#2964 …3}
                    "_route_params" => array:8 [ …8]
                  ]
                }
                #content: null
                #languages: null
                #charsets: null
                #encodings: null
                #acceptableContentTypes: null
                #pathInfo: "/admin/commerce/config/product-types/assessment/edit/fields"
                #requestUri: "/admin/commerce/config/product-types/assessment/edit/fields"
                #baseUrl: ""
                #basePath: ""
                #method: "GET"
                #format: "html"
                #session: Symfony\Component\HttpFoundation\Session\Session {#3824
                  -flashName: "flashes"
                  -attributeName: "attributes"
                  -data: & array:2 [
                    "_sf2_attributes" => & array:2 [ …2]
                    "_symfony_flashes" => & array:1 [ …1]
                  ]
                  -usageIndex: & 6
                  +"_serviceId": "session"
                }
                #locale: null
                #defaultLocale: "en"
                -isHostValid: true
                -isForwardedValid: true
              }
              1 => Symfony\Component\HttpFoundation\Request {#8}
            ]
            +"_serviceId": "request_stack"
          }
          #routeMatches: SplObjectStorage {#3654
            storage: array:1 [
              0 => array:2 [ …2]
            ]
          }
          +"_serviceId": "current_route_match"
        }
        #contexts: []
        -propagationStopped: false
        #cacheContexts: []
        #cacheTags: []
        #cacheMaxAge: -1
      }
      1 => "render.page_display_variant.select"
      2 => Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher {#3851 …4}
    ]
  ]
  "19: call_user_func()" => array:1 [
  ]
  "18: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()" => array:2 [
    "file" => "core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111"
    "args" => array:2 [
      0 => "render.page_display_variant.select"
      1 => Drupal\Core\Render\PageDisplayVariantSelectionEvent {#1129}
    ]
  ]
  "17: Drupal\Core\Render\MainContent\HtmlRenderer->prepare()" => array:2 [
    "file" => "core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php:209"
  ]
  "16: Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()" => array:2 [
    "file" => "core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php:117"
  ]
  "15: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()" => array:2 [
    "file" => "core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php:90"
  ]
  "14: call_user_func()" => array:1 [
  ]
  "13: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()" => array:2 [
    "file" => "core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111"
  ]
  "12: Symfony\Component\HttpKernel\HttpKernel->handleRaw()" => array:2 [
    "file" => "/var/www/commerce_test/vendor/symfony/http-kernel/HttpKernel.php:156"
  ]
  "11: Symfony\Component\HttpKernel\HttpKernel->handle()" => array:2 [
    "file" => "/var/www/commerce_test/vendor/symfony/http-kernel/HttpKernel.php:68"
  ]
  "10: Drupal\Core\StackMiddleware\Session->handle()" => array:2 [
    "file" => "core/lib/Drupal/Core/StackMiddleware/Session.php:57"
  ]
  " 9: Drupal\Core\StackMiddleware\KernelPreHandle->handle()" => array:2 [
    "file" => "core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php:47"
  ]
  " 8: Drupal\page_cache\StackMiddleware\PageCache->pass()" => array:2 [
    "file" => "core/modules/page_cache/src/StackMiddleware/PageCache.php:106"
  ]
  " 7: Drupal\page_cache\StackMiddleware\PageCache->handle()" => array:2 [
    "file" => "core/modules/page_cache/src/StackMiddleware/PageCache.php:85"
  ]
  " 6: Drupal\ban\BanMiddleware->handle()" => array:2 [
    "file" => "core/modules/ban/src/BanMiddleware.php:50"
  ]
  " 5: Drupal\shield\ShieldMiddleware->handle()" => array:2 [
    "file" => "modules/contrib/shield/src/ShieldMiddleware.php:91"
  ]
  " 4: Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()" => array:2 [
    "file" => "core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php:47"
  ]
  " 3: Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()" => array:2 [
    "file" => "core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php:52"
  ]
  " 2: Stack\StackedHttpKernel->handle()" => array:2 [
    "file" => "/var/www/commerce_test/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23"
  ]
  " 1: Drupal\Core\DrupalKernel->handle()" => array:2 [
    "file" => "core/lib/Drupal/Core/DrupalKernel.php:708"
  ]
  " 0: main()" => array:2 [
    "file" => "index.php:19"
    "args" => []
  ]
]

jsacksick’s picture

@mglaman: As discussed on Slack, If we can confirm that:

        // If commerce_product has an entity reference to a custom translatable
        // entity that has its translations overview available under
        // product/{commerce_product}/custom_entity/{custom_entity}/translations
        // $product passed by the breadcrumb builder when testing route
        // candidates is just the product ID as string not the loaded entity.
        // @see PathBasedBreadcrumbBuilder::getRequestForPath().
        if (is_scalar($product)) {
          $product_storage = $this->entityTypeManager->getStorage('commerce_product');
          $product = $product_storage->load($product);
        }

This is no longer needed, we can safely revert.

mglaman’s picture

@lexsoft yeah, it's due to the ContextProviderInterface not being implemented properly due to a bug in LayoutBuilder. The getAvailableContexts should not return the values from runtime. But basically empty-value context definitions. That is what this issue aims to resolve.

Random content will be fixed in #3190799: ProductVariationContext is causing extra generate sample images to be generated

mglaman’s picture

Status: Needs review » Needs work

I just mered #3190799: ProductVariationContext is causing extra generate sample images to be generated, which means this probably has conflicts.

https://git.drupalcode.org/issue/commerce-3220015/-/tree/3220015-dummy-o... is still viable to test, just patching to 8.x-2.x HEAD will probably error until I rebase.

cspitzlay’s picture

I've tried to reproduce the problem from #3200588: Core BreadcrumbBuilder might lead to fatal PHP error in ProductVariationContext with the 3220015-dummy-orphans-paragraphs branch and our project code and migrated data. No crash, seems to work.

mglaman’s picture

Status: Needs work » Needs review

Rebased.

@lexsoft your backtrace shows issues with ProductRouteContext not ProductVariationContext in the backtrace. Is this the case?

  • mglaman committed 18a3020 on 8.x-2.x
    Issue #3220015 by mglaman, lexsoft, jsacksick, mkalkbrenner, cspitzlay:...
mglaman’s picture

Status: Needs review » Fixed

Committed the MR. I'm sure there are more gremlins – like in ProductRouteContext, even. But it is a good step forward.

Thanks, everyone!

lexsoft’s picture

@mglaman Yes, when used with https://www.drupal.org/project/context contrib module it was the ProductRouteContext that was triggered.

We used the contrib context module for layouts display conditions. After visiting any product type page, like manage display form or manage display. The context was triggered.

Status: Fixed » Closed (fixed)

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