Error: Call to a member function getPurchasableEntityTypeId() on null in Drupal\commerce_order\Entity\OrderItem::bundleFieldDefinitions() (line 326 of modules/commerce/modules/order/src/Entity/OrderItem.php).
Drupal\commerce_order\Entity\OrderItem::bundleFieldDefinitions(Object, NULL, Array) (Line: 331)
Drupal\Core\Entity\EntityFieldManager->buildBundleFieldDefinitions('commerce_order_item', NULL, Array) (Line: 298)
Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions('commerce_order_item', NULL) (Line: 68)
Drupal\og\OgGroupAudienceHelper->getAllGroupAudienceFields('commerce_order_item', NULL) (Line: 46)
Drupal\og\OgGroupAudienceHelper->hasGroupAudienceField('commerce_order_item', NULL) (Line: 269)
Drupal\og\Og::isGroupContent('commerce_order_item', NULL) (Line: 151)
Drupal\og_ui\BundleFormAlter->addGroupContent(Array, Object) (Line: 73)
Comment | File | Size | Author |
---|---|---|---|
#15 | order_item_entity_issue-2898668-15.patch | 4.12 KB | elaman |
|
Comments
Comment #2
IIAasattler CreditAttribution: IIAasattler commentedI get this same error message when I attempt to click "Add view from template", even though what I want to do has nothing to do with Commerce (I'm adding a calendar to my site.) I have uninstalled and reinstalled the Calendar and Views Template modules, but this continues to prevent me from adding a new view to my site, but I cannot uninstall and reinstall Commerce as the shopping cart is fully functional. Not sure what is interfering here.
Comment #3
nydragondad CreditAttribution: nydragondad commentedI face the similar issue, but I did not install OG, instead, I have the group module, I guess it has something to do with the group feature, if possible, can someone share your solution here, thanks.
Comment #4
otarza CreditAttribution: otarza as a volunteer commentedI have same problem and it's not related to OG or group module because I don't have any of those installed.
I just have all Commerce core modules enabled and Calendar module.
When I try to "Add view from template" I get this error.
Comment #5
joachim CreditAttribution: joachim at Torchbox commentedMy bug at least is caused by OG, which doesn't check in its form alterations whether the current entity actually has a non-NULL id before going off to get fields.
The crash doesn't occur on other forms to add entity types because those don't have a bundleFieldDefinitions() method in their entity class.
Comment #6
jwjoshuawalker CreditAttribution: jwjoshuawalker as a volunteer commentedSame here, happens with Calendar module on and visiting "Add view from template".
No error with Calendar module off.
This is the line in OrderItem.php:
$order_item_type is NULL when it tries.
Comment #7
joachim CreditAttribution: joachim as a volunteer commentedMight be the same problem as this bug: #2911542: "Add payment" and "Add order" routes need to use _entity_create_any_access, not _entity_create_access?
Comment #8
jwjoshuawalker CreditAttribution: jwjoshuawalker as a volunteer commented@joachim,
Not sure, as far as I can tell, the core and Webform modules (for reference) do it in the same way Commerce is.
Taxonomy being an oddball, see below example:
Comment #9
mglamanCan we identify what Calendar module is doing to cause this crash? Before Workbench Moderation did the same and we found a fix.
I don't want to add a test which includes Calendar due to how the Drupal.org facade works. It'll then add test_dependencies as require-dev (effectively adding it to all sites who run composer without --no-dev)
Comment #10
dkolarevic CreditAttribution: dkolarevic at Proultima commentedSame problem here with Calendar module. I removed line 71 in ViewsFieldTemplate.php. Not sure if this is the best way but in my case that worked.
Comment #11
pimok3000 CreditAttribution: pimok3000 commentedI can confirm that the patch from #10 is working for me with no side effects (so far ... :) )
Comment #12
snsblvd CreditAttribution: snsblvd as a volunteer commentedThe patch needed to modified the calendar module file "/src/Plugin/ViewsTemplateBuilder/ViewsFieldTemplate.php", that's why I had to adjust the patch a bit. In my case the OG Module is not installed (only commerce, calendar, views_templates). And its working (but I have no idea what the patch has for impact). Im a newbie about coding/modules.
But should this issue not go into the calendar module or is this just an ugly fix?
Comment #13
pyxio CreditAttribution: pyxio commentedi have the same issue but i am not using calendar. does anybody have any idea what is causing my errors? it happens when i click the uninstall tab
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getPurchasableEntityTypeId() on null in Drupal\commerce_order\Entity\OrderItem::bundleFieldDefinitions() (line 377 of modules/contrib/commerce/modules/order/src/Entity/OrderItem.php).
Drupal\commerce_order\Entity\OrderItem::bundleFieldDefinitions(Object, 'addon', Array) (Line: 362)
Drupal\Core\Entity\EntityFieldManager->buildBundleFieldDefinitions('commerce_order_item', 'addon', Array) (Line: 329)
Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions('commerce_order_item', 'addon') (Line: 195)
Drupal\Core\Entity\EntityManager->getFieldDefinitions('commerce_order_item', 'addon') (Line: 427)
Drupal\Core\Entity\EntityDisplayBase->getFieldDefinitions() (Line: 181)
Drupal\Core\Entity\EntityDisplayBase->init() (Line: 143)
Drupal\Core\Entity\EntityDisplayBase->__construct(Array, 'entity_view_display') (Line: 175)
Drupal\Core\Entity\Entity\EntityViewDisplay->__construct(Array, 'entity_view_display') (Line: 322)
Drupal\Core\Entity\EntityStorageBase->mapFromStorageRecords(Array, Array) (Line: 189)
Drupal\Core\Config\Entity\ConfigEntityStorage->doLoadMultiple(NULL) (Line: 242)
Drupal\Core\Entity\EntityStorageBase->loadMultiple(NULL) (Line: 534)
Drupal\Core\Entity\Entity::loadMultiple(NULL) (Line: 21)
Drupal\bootstrap_layouts\Plugin\BootstrapLayouts\Ds->loadInstances() (Line: 41)
Drupal\bootstrap_layouts\BootstrapLayoutsUninstallValidator->validate('bootstrap_layouts') (Line: 560)
Drupal\Core\Extension\ModuleInstaller->validateUninstall(Array) (Line: 99)
Drupal\Core\ProxyClass\Extension\ModuleInstaller->validateUninstall(Array) (Line: 123)
Drupal\system\Form\ModulesUninstallForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('system_modules_uninstall', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('system_modules_uninstall', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 664)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment #14
elamanI have this issue when using Default Content Deploy module.
Probable cause:
method doesn't check if bundle is empty. Other modules all have checks. I will check this and provide the patch.
Comment #15
elamanProvided patch should fix the issue. I've tested my use case, please help to test.
Comment #16
joachim CreditAttribution: joachim as a volunteer commentedThat patch is babysitting broken code. The $bundle parameter should never be empty.
Comment #17
pyxio CreditAttribution: pyxio commented@Elaman - thank you. this patch fixes the issue.
Comment #18
mglamanWhy would
bundleFieldDefinitions
receive an empty bundle? Other contrib are doing things wrong if this is happening. All entities have bundles, even if they don't have support for configurable bundles (ie: users. The bundle is just "user').Comment #19
joachim CreditAttribution: joachim as a volunteer commentedIndeed. Restoring the original title.
Comment #20
shabana.navas CreditAttribution: shabana.navas commentedI just enabled the Calendar module and getting the same exact behavior going to Add view from template. The bundle we're getting here is the 'event' type.
Comment #21
lithiumlab CreditAttribution: lithiumlab commentedThe following error comes out when trying to add a new Calendar view using the Add View from Template button in the views page.
Steps to reproduce:
Enable Commerce 2.x
Enable Calendar
location:
/admin/structure/views/template/list
message:
Applying #15 patch to Commerce 2.8.0 generates another error:
Any suggestions or workaround given that #15 patch generates another error?
Comment #22
Naitschi CreditAttribution: Naitschi commentedGot the same Problem as mentioned in #21
Comment #23
andsigno82 CreditAttribution: andsigno82 commentedpatch #15 worked perfectly in my case. thanks @elaman
Comment #24
mglamanThere hasn't been much traction here, and the problem is in OG/Calendar. Closing as outdated.