Call to a member function id() on null

Created on 28 July 2025, 8 days ago

Problem/Motivation

There is a crash for /jsonapi/carts endpoint when this module is enabled. It looks like there might be arrays with entities, but the entity item might be NULL.
See, createCollectionDataFromEntities and $entities array for more context.
Here is the crash result:

Steps to reproduce

1. Enable the module jsonapi_resource
2. Enable the module commerce_api
3. Use the API endpoint jsonapi/carts when the cart is empty
4. See the crash with the message above.

Proposed resolution

Write a patch for covering then the $entity variable from createCollectionDataFromEntities, which is NULL instead of an actual entity. This validation should be covered here and not inside the commerce_api module.

Remaining tasks

Write the patch.

User interface changes

No.

API changes

No.

Data model changes

No.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇲🇩Moldova andrei.vesterli Chisinau

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024