I get this error when try to add views support to a product variations computed field

  Error: Call to a member function getType() on null in commerce_price_form_views_ui_config_item_form_alter()
CommentFileSizeAuthor
#2 3150380-2.patch903 bytesfacine
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

facine created an issue. See original summary.

facine’s picture

Status: Active » Needs review
FileSize
903 bytes
amateescu’s picture

I think this could be related to #3138565: \Drupal\commerce\CommerceEntityViewsData::getViewsData() shouldn't try to generate views data for computed fields, could you try that patch instead and see if it helps?

facine’s picture

Hi @amateescu, I've tried your patch but it doesn't fix this issue.

loze’s picture

Patch in #2 worked for me.

facine’s picture

Status: Needs review » Reviewed & tested by the community
Spokje’s picture

Reproducible by: (Using latest Drupal Core 9.3.x and Commerce 2.25.0)

- Enable Content Moderation
- Enable Commerce Price
- Enable Workflow on Content Type (I've choosen `page`) here: /admin/config/workflow/workflows/manage/editorial
- Create node of type `page`
- Go to /admin/structure/views/view/moderated_content/edit/moderated_content
- Edit/Click Field Content revision: Moderation state (Moderation state)
- Ajax error occurs, watchdog shows one notice and one error:

Notice: Undefined index: moderation_state in commerce_price_form_views_ui_config_item_form_alter() (line 64 of drupal\modules\contrib\commerce\modules\price\commerce_price.module)

#0 drupal\core\includes\bootstrap.inc(326): _drupal_error_handler_real(8, 'Undefined index...', 'D:\\htdocs\\drupa...', 64)
#1 drupal\modules\contrib\commerce\modules\price\commerce_price.module(64): _drupal_error_handler(8, 'Undefined index...', 'D:\\htdocs\\drupa...', 64, Array)
#2 drupal\core\lib\Drupal\Core\Extension\ModuleHandler.php(539): commerce_price_form_views_ui_config_item_form_alter(Array, Object(Drupal\Core\Form\FormState), 'views_ui_config...')
#3 drupal\core\lib\Drupal\Core\Form\FormBuilder.php(835): Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object(Drupal\Core\Form\FormState), 'views_ui_config...')
#4 drupal\core\lib\Drupal\Core\Form\FormBuilder.php(279): Drupal\Core\Form\FormBuilder->prepareForm('views_ui_config...', Array, Object(Drupal\Core\Form\FormState))
#5 drupal\core\modules\views_ui\src\Form\Ajax\ViewsFormBase.php(215): Drupal\Core\Form\FormBuilder->buildForm('Drupal\\views_ui...', Object(Drupal\Core\Form\FormState))
#6 drupal\core\lib\Drupal\Core\Render\Renderer.php(578): Drupal\views_ui\Form\Ajax\ViewsFormBase->Drupal\views_ui\Form\Ajax\{closure}()
#7 drupal\core\modules\views_ui\src\Form\Ajax\ViewsFormBase.php(217): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#8 drupal\core\modules\views_ui\src\Form\Ajax\ViewsFormBase.php(127): Drupal\views_ui\Form\Ajax\ViewsFormBase->ajaxFormWrapper('Drupal\\views_ui...', Object(Drupal\Core\Form\FormState))
#9 drupal\core\modules\views_ui\src\Form\Ajax\ConfigHandler.php(39): Drupal\views_ui\Form\Ajax\ViewsFormBase->getForm(Object(Drupal\views_ui\ViewUI), 'moderated_conte...', 'ajax')
#10 [internal function]: Drupal\views_ui\Form\Ajax\ConfigHandler->getForm(Object(Drupal\views_ui\ViewUI), 'moderated_conte...', 'ajax', 'field', 'moderation_stat...')
#11 drupal\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#12 drupal\core\lib\Drupal\Core\Render\Renderer.php(578): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 drupal\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#14 drupal\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#15 drupal\vendor\symfony\http-kernel\HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 drupal\vendor\symfony\http-kernel\HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#17 drupal\core\lib\Drupal\Core\StackMiddleware\Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 drupal\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 drupal\core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 drupal\core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 drupal\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 drupal\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 drupal\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 drupal\core\lib\Drupal\Core\DrupalKernel.php(716): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 drupal\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#26 {main}

and

Error: Call to a member function getType() on null in commerce_price_form_views_ui_config_item_form_alter() (line 65 of drupal\modules\contrib\commerce\modules\price\commerce_price.module)

#0 drupal\core\lib\Drupal\Core\Extension\ModuleHandler.php(539): commerce_price_form_views_ui_config_item_form_alter(Array, Object(Drupal\Core\Form\FormState), 'views_ui_config...')
#1 drupal\core\lib\Drupal\Core\Form\FormBuilder.php(835): Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object(Drupal\Core\Form\FormState), 'views_ui_config...')
#2 drupal\core\lib\Drupal\Core\Form\FormBuilder.php(279): Drupal\Core\Form\FormBuilder->prepareForm('views_ui_config...', Array, Object(Drupal\Core\Form\FormState))
#3 drupal\core\modules\views_ui\src\Form\Ajax\ViewsFormBase.php(215): Drupal\Core\Form\FormBuilder->buildForm('Drupal\\views_ui...', Object(Drupal\Core\Form\FormState))
#4 drupal\core\lib\Drupal\Core\Render\Renderer.php(578): Drupal\views_ui\Form\Ajax\ViewsFormBase->Drupal\views_ui\Form\Ajax\{closure}()
#5 drupal\core\modules\views_ui\src\Form\Ajax\ViewsFormBase.php(217): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#6 drupal\core\modules\views_ui\src\Form\Ajax\ViewsFormBase.php(127): Drupal\views_ui\Form\Ajax\ViewsFormBase->ajaxFormWrapper('Drupal\\views_ui...', Object(Drupal\Core\Form\FormState))
#7 drupal\core\modules\views_ui\src\Form\Ajax\ConfigHandler.php(39): Drupal\views_ui\Form\Ajax\ViewsFormBase->getForm(Object(Drupal\views_ui\ViewUI), 'moderated_conte...', 'ajax')
#8 [internal function]: Drupal\views_ui\Form\Ajax\ConfigHandler->getForm(Object(Drupal\views_ui\ViewUI), 'moderated_conte...', 'ajax', 'field', 'moderation_stat...')
#9 drupal\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#10 drupal\core\lib\Drupal\Core\Render\Renderer.php(578): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 drupal\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#12 drupal\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#13 drupal\vendor\symfony\http-kernel\HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 drupal\vendor\symfony\http-kernel\HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#15 drupal\core\lib\Drupal\Core\StackMiddleware\Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 drupal\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 drupal\core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 drupal\core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 drupal\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 drupal\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 drupal\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 drupal\core\lib\Drupal\Core\DrupalKernel.php(716): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 drupal\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#24 {main}

  • jsacksick committed 2bbdb2e on 8.x-2.x authored by facine
    Issue #3150380 by facine, amateescu, loze, Spokje: PHP error adding...
jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

Committed! Thanks everyone!

Status: Fixed » Closed (fixed)

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