Currently the code assumes that $order_item->getPurchasedEntity() will always return an entity, but this can return NULL:
/**
* Gets the purchased entity.
*
* @return \Drupal\commerce\PurchasableEntityInterface|null
* The purchased entity, or NULL.
*/
public function getPurchasedEntity();This can easily happen in practice, especially taking https://www.drupal.org/project/commerce/issues/3047357 into consideration. For anyone with off-site payment methods having hundreds or even thousands of old, locked draft orders that have been abandoned in the payment step is not uncommon. And currently all these orders go through the order processors. If the referenced product variation of such an order has been deleted in the meantime then getPurchasedEntity() will return NULL.
The resolver should check to see if it has an entity and just bail out if there isn't one.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3115093-2.patch | 647 bytes | twiik |
Comments
Comment #2
twiik commentedPatch attached.
Comment #3
jsacksick commentedCommitted, thanks!