Describe your bug or feature request.

We are seeing a PHP warning repeatedly in our logs on different URLs. An example of the stack trace is below.

<pre><code>Warning: Undefined array key "target_bundles" in Drupal\commerce_product\Plugin\Commerce\Condition\OrderProductCategory->getVocabularyIds() (line 107 of /app/path/docroot/modules/contrib/commerce/modules/product/src/Plugin/Commerce/Condition/ProductCategoryTrait.php) #0 /app/path/docroot/core/includes/bootstrap.inc(347): _drupal_error_handler_real(2, 'Undefined array...', '/app/yr7j26hzhz...', 107)
#1 /app/path/docroot/modules/contrib/commerce/modules/product/src/Plugin/Commerce/Condition/ProductCategoryTrait.php(107): _drupal_error_handler(2, 'Undefined array...', '/app/yr7j26hzhz...', 107)
#2 /app/path/docroot/modules/contrib/commerce/modules/product/src/Plugin/Commerce/Condition/ProductCategoryTrait.php(61): Drupal\commerce_product\Plugin\Commerce\Condition\OrderProductCategory->getVocabularyIds()
#3 /app/path/docroot/modules/contrib/commerce/src/Plugin/Commerce/InlineForm/PluginConfiguration.php(104): Drupal\commerce_product\Plugin\Commerce\Condition\OrderProductCategory->buildConfigurationForm(Array, Object(Drupal\Core\Form\FormState))
#4 /app/path/docroot/modules/contrib/commerce/src/Element/Conditions.php(183): Drupal\commerce\Plugin\Commerce\InlineForm\PluginConfiguration->buildInlineForm(Array, Object(Drupal\Core\Form\FormState))
#5 [internal function]: Drupal\commerce\Element\Conditions::processConditions(Array, Object(Drupal\Core\Form\FormState), Array)
#6 /app/path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(1007): call_user_func_array(Array, Array)
#7 /app/path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(1070): Drupal\Core\Form\FormBuilder->doBuildForm('commerce_promot...', Array, Object(Drupal\Core\Form\FormState))
#8 /app/path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(1070): Drupal\Core\Form\FormBuilder->doBuildForm('commerce_promot...', Array, Object(Drupal\Core\Form\FormState))
#9 /app/path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(1070): Drupal\Core\Form\FormBuilder->doBuildForm('commerce_promot...', Array, Object(Drupal\Core\Form\FormState))
#10 /app/path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(574): Drupal\Core\Form\FormBuilder->doBuildForm('commerce_promot...', Array, Object(Drupal\Core\Form\FormState))
#11 /app/path/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(320): Drupal\Core\Form\FormBuilder->processForm('commerce_promot...', Array, Object(Drupal\Core\Form\FormState))
#12 /app/path/docroot/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\commerce_promotion\Form\PromotionForm), Object(Drupal\Core\Form\FormState))
#13 /app/path/docroot/core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php(39): Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#14 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#15 /app/path/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#16 /app/path/docroot/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#17 /app/path/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#18 /app/path/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#19 /app/path/vendor/symfony/http-kernel/HttpKernel.php(159): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 /app/path/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#21 /app/path/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/path/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/path/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/path/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/path/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/path/docroot/core/lib/Drupal/Core/DrupalKernel.php(709): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /app/path/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#28 {main}.

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

Unsure under what circumstances the array key is not defined.
An MR is to follow.

CommentFileSizeAuthor
#2 3326059-2.patch1.11 KBjsacksick

Issue fork commerce-3326059

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:

Comments

tcrawford created an issue. See original summary.

jsacksick’s picture

Status: Active » Needs review
StatusFileSize
new1.11 KB

The attached patch should do the trick.

tcrawford’s picture

Thank you. Wow that was fast. I was about to create an MR, but had to go into a meeting and when I came back a patch was waiting. Thanks again.

  • jsacksick committed 6070751 on 8.x-2.x
    Issue #3326059 by tcrawford, jsacksick: Warning: Undefined array key "...

  • jsacksick committed ecb31cb on 3.0.x
    Issue #3326059 by tcrawford, jsacksick: Warning: Undefined array key "...
jsacksick’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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