Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Summary
Domain Access module prevents REST file upload due to NULL exception in domain_access.module (domain_access_entity_field_access).
Proposed solution
Check whether $items is NULL before accssing it, in accordance to function signature (see attached patch).
Comment | File | Size | Author |
---|---|---|---|
#6 | 3066051-domain_access-field-access-6.patch | 907 bytes | agentrickard |
#2 | domain-check_items_null-3066051-1-D8.patch | 1008 bytes | pvbergen |
Comments
Comment #2
pvbergen CreditAttribution: pvbergen at iqual AG commentedComment #3
agentrickardI need reliable steps to reproduce and test this bug report.
Comment #4
pvbergen CreditAttribution: pvbergen at iqual AG commentedSorry for keeping this issue abandoned so long.
We encounter this issue when we want to use the /file/upload/{entity_type_id}/{bundle}/{field_name} endpoint to upload images (see https://www.drupal.org/node/2941420).
Problem
The response of an upload to the file upload REST endpoint is empty due to an error in domain_access.module:
Error: Call to a member function getEntity() on null in modules/contrib/domain/domain_access/domain_access.module on line 433
Steps to reproduce
Side note
According to the definition of the hook_entity_field_access, the $items parameter is optional, so we should check $items before accessing it.
Comment #5
agentrickardGreat report, thank you.
Comment #6
agentrickardSlight patch for clarity of documentation. Tests all pass.
Comment #8
agentrickardCommitted and credited!