After updating, I get the following error when viewing an order (that doesn't have a shipment on it):

RuntimeException: Could not load the "" shipment type. in Drupal\commerce_shipping\Entity\Shipment::bundleFieldDefinitions() (line 708 of modules/contrib/commerce_shipping/src/Entity/Shipment.php).

Drupal\Core\Entity\EntityFieldManager->buildBundleFieldDefinitions('commerce_shipment', '', Array) (Line: 350)
Drupal\Core\Entity\EntityFieldManager->getFieldDefinitions('commerce_shipment', '') (Line: 68)
Drupal\og\OgGroupAudienceHelper->getAllGroupAudienceFields('commerce_shipment', '') (Line: 46)
Drupal\og\OgGroupAudienceHelper->hasGroupAudienceField('commerce_shipment', '') (Line: 287)
Drupal\og\Og::isGroupContent('commerce_shipment', '') (Line: 237)
og_entity_create_access(Object, Array, '')
call_user_func_array('og_entity_create_access', Array) (Line: 403)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_create_access', Array) (Line: 251)
Drupal\Core\Entity\EntityAccessControlHandler->createAccess('', Object) (Line: 60)
Drupal\commerce_shipping\Access\ShipmentCollectionAccessCheck->access(Object, Object, Object)

From stepping through the code, I don't think OG is at fault here. The problem is ShipmentCollectionAccessCheck is invoking Drupal's access with NULL as a bundle key. It appears to be related to the change in #3174306: Viewing shipments requires the "administer commerce_shipment" permission.

I have a fix for this, which is basically to not try to do access check if there is not a shipment.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Rob230 created an issue. See original summary.

Rob230’s picture

Rob230’s picture

Status: Active » Needs review

Status: Needs review » Needs work
Rob230’s picture

Sometimes $shipment_type_id can be an empty string rather than NULL.

Rob230’s picture

Ugh editor ate my bracket.

jsacksick’s picture

Status: Needs work » Fixed

Committed!

  • jsacksick committed 98631e8 on 8.x-2.x authored by Rob230
    Issue #3259808 by Rob230: RuntimeException: Could not load the ""...

  • jsacksick committed 5aaa0dd on 8.x-2.x
    Issue #3259808 followup by jsacksick: Fix the...

Status: Fixed » Closed (fixed)

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