0

This seems to be related to Commerce orders and the Symfony Mailer module. I intermittently see this error when a user attempts to complete the checkout process using Commerce PayPal:

Blockquote User error: "funding_source" is an invalid render array key in Drupal\Core\Render\Element::children() (line 98 of /var/www/site/web/core/lib/Drupal/Core/Render/Element.php) #0 /var/www/site/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real() #1 [internal function]: _drupal_error_handler() #2 /var/www/site/web/core/lib/Drupal/Core/Render/Element.php(98): trigger_error() #3 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(404): Drupal\Core\Render\Element::children() #4 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender() #5 /var/www/site/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render() #6 /var/www/site/web/sites/default/files/php/twig/6529302194f2f_commerce-order.html.twig_2p-K4ggEbyH1Y08LLASzZvkUF/lEl50_59oVkz1bTgwQDbm4t-UDXyh-LQi70GrCZvt-Y.php(44): Drupal\Core\Template\TwigExtension->escapeFilter() #7 /var/www/site/vendor/twig/twig/src/Template.php(405): __TwigTemplate_a737a4a270bc020c6c35483b73b12bb8->doDisplay() #8 /var/www/site/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling() #9 /var/www/site/vendor/twig/twig/src/Template.php(390): Twig\Template->display() #10 /var/www/site/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render() #11 /var/www/site/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template() #12 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render() #13 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender() #14 /var/www/site/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render() #15 /var/www/site/web/sites/default/files/php/twig/6529302194f2f___string_template__c0e1ea_CN1J_WKEj7CUghI835RNG-N3T/QGF5E63NnWsxeN7rwaH9gK3ZBMZdwdU_71Pac_bLOP8.php(52): Drupal\Core\Template\TwigExtension->escapeFilter() #16 /var/www/site/vendor/twig/twig/src/Template.php(405): __TwigTemplate_4798832cb62276a94273997f6ae59d7e->doDisplay() #17 /var/www/site/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling() #18 /var/www/site/vendor/twig/twig/src/Template.php(390): Twig\Template->display() #19 /var/www/site/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render() #20 /var/www/site/web/core/lib/Drupal/Core/Template/TwigEnvironment.php(234): Twig\TemplateWrapper->render() #21 /var/www/site/web/modules/contrib/symfony_mailer/src/Plugin/EmailAdjuster/BodyEmailAdjuster.php(75): Drupal\Core\Template\TwigEnvironment->renderInline() #22 [internal function]: Drupal\symfony_mailer\Plugin\EmailAdjuster\BodyEmailAdjuster->preRenderVariables() #23 /var/www/site/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array() #24 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback() #25 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback() #26 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender() #27 /var/www/site/web/core/lib/Drupal/Core/Template/TwigExtension.php(479): Drupal\Core\Render\Renderer->render() #28 /var/www/site/web/sites/default/files/php/twig/6529302194f2f_email.html.twig_Be65fSN2NURPnSHvFrCJkJ-VJ/J8ORnB2UzlbntcueOpSzbuv92fcZzaqOq2p2BZO7rJo.php(42): Drupal\Core\Template\TwigExtension->escapeFilter() #29 /var/www/site/vendor/twig/twig/src/Template.php(405): __TwigTemplate_25218f115be83ddbfa265487c92c8563->doDisplay() #30 /var/www/site/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling() #31 /var/www/site/vendor/twig/twig/src/Template.php(390): Twig\Template->display() #32 /var/www/site/web/core/themes/engines/twig/twig.engine(55): Twig\Template->render() #33 /var/www/site/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template() #34 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(433): Drupal\Core\Theme\ThemeManager->render() #35 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender() #36 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(160): Drupal\Core\Render\Renderer->render() #37 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\Renderer->Drupal\Core\Render{closure}() #38 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(161): Drupal\Core\Render\Renderer->executeInRenderContext() #39 /var/www/site/web/modules/contrib/symfony_mailer/src/Email.php(538): Drupal\Core\Render\Renderer->renderPlain() #40 /var/www/site/web/modules/contrib/symfony_mailer/src/Mailer.php(233): Drupal\symfony_mailer\Email->render() #41 /var/www/site/web/modules/contrib/symfony_mailer/src/Mailer.php(149): Drupal\symfony_mailer\Mailer->doSend() #42 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\symfony_mailer\Mailer->Drupal\symfony_mailer{closure}() #43 /var/www/site/web/modules/contrib/symfony_mailer/src/Mailer.php(158): Drupal\Core\Render\Renderer->executeInRenderContext() #44 /var/www/site/web/modules/contrib/symfony_mailer/src/Email.php(292): Drupal\symfony_mailer\Mailer->send() #45 /var/www/site/web/modules/contrib/symfony_mailer/src/MailManagerReplacement.php(92): Drupal\symfony_mailer\Email->send() #46 /var/www/site/web/modules/contrib/commerce/src/MailHandler.php(105): Drupal\symfony_mailer\MailManagerReplacement->mail() #47 /var/www/site/web/modules/contrib/commerce/modules/order/src/Mail/OrderReceiptMail.php(76): Drupal\commerce\MailHandler->sendMail() #48 /var/www/site/web/modules/contrib/commerce/modules/order/src/EventSubscriber/OrderReceiptSubscriber.php(63): Drupal\commerce_order\Mail\OrderReceiptMail->send() #49 [internal function]: Drupal\commerce_order\EventSubscriber\OrderReceiptSubscriber->sendOrderReceipt() #50 /var/www/site/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(142): call_user_func() #51 /var/www/site/web/modules/contrib/state_machine/src/Plugin/Field/FieldType/StateItem.php(422): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() #52 /var/www/site/web/modules/contrib/state_machine/src/Plugin/Field/FieldType/StateItem.php(389): Drupal\state_machine\Plugin\Field\FieldType\StateItem->dispatchTransitionEvent() #53 [internal function]: Drupal\state_machine\Plugin\Field\FieldType\StateItem->postSave() #54 /var/www/site/web/core/lib/Drupal/Core/Field/FieldItemList.php(233): call_user_func_array() #55 /var/www/site/web/core/lib/Drupal/Core/Field/FieldItemList.php(198): Drupal\Core\Field\FieldItemList->delegateMethod() #56 [internal function]: Drupal\Core\Field\FieldItemList->postSave() #57 /var/www/site/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(938): call_user_func_array() #58 /var/www/site/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(970): Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod() #59 /var/www/site/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(896): Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldPostSave() #60 /var/www/site/web/modules/contrib/commerce/src/CommerceContentEntityStorage.php(56): Drupal\Core\Entity\ContentEntityStorageBase->invokeHook() #61 /var/www/site/web/modules/contrib/commerce/modules/order/src/OrderStorage.php(81): Drupal\commerce\CommerceContentEntityStorage->invokeHook() #62 /var/www/site/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(598): Drupal\commerce_order\OrderStorage->invokeHook() #63 /var/www/site/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php(781): Drupal\Core\Entity\EntityStorageBase->doPostSave() #64 /var/www/site/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(523): Drupal\Core\Entity\ContentEntityStorageBase->doPostSave() #65 /var/www/site/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(804): Drupal\Core\Entity\EntityStorageBase->save() #66 /var/www/site/web/modules/contrib/commerce/modules/order/src/OrderStorage.php(159): Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() #67 /var/www/site/web/core/lib/Drupal/Core/Entity/EntityBase.php(339): Drupal\commerce_order\OrderStorage->save() #68 /var/www/site/web/modules/contrib/commerce/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowBase.php(220): Drupal\Core\Entity\EntityBase->save() #69 /var/www/site/web/modules/contrib/commerce/modules/payment/src/Plugin/Commerce/CheckoutPane/PaymentProcess.php(180): Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowBase->redirectToStep() #70 /var/www/site/web/modules/contrib/commerce/modules/checkout/src/Plugin/Commerce/CheckoutFlow/CheckoutFlowWithPanesBase.php(546): Drupal\commerce_payment\Plugin\Commerce\CheckoutPane\PaymentProcess->buildPaneForm() #71 [internal function]: Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowWithPanesBase->buildForm() #72 /var/www/site/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array() #73 /var/www/site/web/core/lib/Drupal/Core/Form/FormBuilder.php(283): Drupal\Core\Form\FormBuilder->retrieveForm() #74 /var/www/site/web/core/lib/Drupal/Core/Form/FormBuilder.php(224): Drupal\Core\Form\FormBuilder->buildForm() #75 /var/www/site/web/modules/contrib/commerce/modules/checkout/src/Controller/CheckoutController.php(143): Drupal\Core\Form\FormBuilder->getForm() #76 [internal function]: Drupal\commerce_checkout\Controller\CheckoutController->formPage() #77 /var/www/site/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array() #78 /var/www/site/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() #79 /var/www/site/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext() #80 /var/www/site/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() #81 /var/www/site/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() #82 /var/www/site/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #83 /var/www/site/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle() #84 /var/www/site/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #85 /var/www/site/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #86 /var/www/site/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass() #87 /var/www/site/web/modules/contrib/cleantalk/src/EventSubscriber/BootSubscriber.php(193): Drupal\page_cache\StackMiddleware\PageCache->handle() #88 /var/www/site/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\cleantalk\EventSubscriber\BootSubscriber->handle() #89 /var/www/site/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle() #90 /var/www/site/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #91 /var/www/site/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #92 /var/www/site/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle() #93 /var/www/site/web/index.php(19): Drupal\Core\DrupalKernel->handle() #94 {main}

Is this an order email twig template issue, or something else?

2
  • This is an array key with no render child. It can be anywhere, in templates but also in variables the templates render. I would set a breakpoint in a debugger, or you could try a full-text search for the invalid key, this doesn't look like it will get you too many search hits.
    – 4uk4
    Oct 31, 2023 at 12:07
  • There are only a few places in the code where I can find 'funding_source' used as an array index: modules/contrib/commerce_paypal/commerce_paypal.module: return $funding_sources[$funding_source] ?? ''; modules/contrib/commerce_paypal/commerce_paypal.module: if (!empty($data['funding_source'])) { modules/contrib/commerce_paypal/commerce_paypal.module: $variables['order']['funding_source'] = commerce_paypal_funding_source_label($data['funding_source']); Oct 31, 2023 at 14:11

1 Answer 1

0

To create a valid render array, put the string the function returns in a markup render element:

$variables['order']['funding_source'] = ['#markup' => commerce_paypal_funding_source_label($data['funding_source'])];
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.